Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame^] | 1 | //===-- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework -*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef CODEGEN_ASMPRINTER_STRINGPOOL_H__ |
| 11 | #define CODEGEN_ASMPRINTER_STRINGPOOL_H__ |
| 12 | |
| 13 | #include "llvm/ADT/StringMap.h" |
| 14 | #include "llvm/CodeGen/AsmPrinter.h" |
| 15 | #include "llvm/Support/Allocator.h" |
| 16 | |
| 17 | #include <utility> |
| 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | class MCSymbol; |
| 22 | class MCSection; |
| 23 | class StringRef; |
| 24 | |
| 25 | // Collection of strings for this unit and assorted symbols. |
| 26 | // A String->Symbol mapping of strings used by indirect |
| 27 | // references. |
| 28 | class DwarfStringPool { |
| 29 | StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool; |
| 30 | StringRef Prefix; |
| 31 | MCSymbol *SectionSymbol; |
| 32 | |
| 33 | public: |
| 34 | DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix) |
| 35 | : Pool(A), Prefix(Prefix), SectionSymbol(Asm.GetTempSymbol(Prefix)) {} |
| 36 | |
| 37 | void emit(AsmPrinter &Asm, const MCSection *StrSection, |
| 38 | const MCSection *OffsetSection = nullptr, |
| 39 | const MCSymbol *StrSecSym = nullptr); |
| 40 | |
| 41 | /// \brief Returns the entry into the start of the pool. |
| 42 | MCSymbol *getSectionSymbol(); |
| 43 | |
| 44 | /// \brief Returns an entry into the string pool with the given |
| 45 | /// string text. |
| 46 | MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str); |
| 47 | |
| 48 | /// \brief Returns the index into the string pool with the given |
| 49 | /// string text. |
| 50 | unsigned getIndex(AsmPrinter &Asm, StringRef Str); |
| 51 | |
| 52 | bool empty() const { return Pool.empty(); } |
| 53 | }; |
| 54 | } |
| 55 | #endif |