1 //===-- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework -*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CODEGEN_ASMPRINTER_STRINGPOOL_H__
11 #define CODEGEN_ASMPRINTER_STRINGPOOL_H__
13 #include "llvm/ADT/StringMap.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/Support/Allocator.h"
25 // Collection of strings for this unit and assorted symbols.
26 // A String->Symbol mapping of strings used by indirect
28 class DwarfStringPool {
29 StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool;
31 MCSymbol *SectionSymbol;
34 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
35 : Pool(A), Prefix(Prefix), SectionSymbol(Asm.GetTempSymbol(Prefix)) {}
37 void emit(AsmPrinter &Asm, const MCSection *StrSection,
38 const MCSection *OffsetSection = nullptr,
39 const MCSymbol *StrSecSym = nullptr);
41 /// \brief Returns the entry into the start of the pool.
42 MCSymbol *getSectionSymbol();
44 /// \brief Returns an entry into the string pool with the given
46 MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str);
48 /// \brief Returns the index into the string pool with the given
50 unsigned getIndex(AsmPrinter &Asm, StringRef Str);
52 bool empty() const { return Pool.empty(); }