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 19namespace llvm { 20 21class MCSymbol; 22class MCSection; 23class StringRef; 24 25// Collection of strings for this unit and assorted symbols. 26// A String->Symbol mapping of strings used by indirect 27// references. 28class DwarfStringPool { 29 StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool; 30 StringRef Prefix; 31 MCSymbol *SectionSymbol; 32 33public: 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 56