16e07bfd0SEugene Zelenko //===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===// 2daefdbf3SDavid Blaikie // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6daefdbf3SDavid Blaikie // 7daefdbf3SDavid Blaikie //===----------------------------------------------------------------------===// 8daefdbf3SDavid Blaikie 9a7c40ef0SBenjamin Kramer #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 10a7c40ef0SBenjamin Kramer #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 11daefdbf3SDavid Blaikie 12daefdbf3SDavid Blaikie #include "llvm/ADT/StringMap.h" 136e07bfd0SEugene Zelenko #include "llvm/ADT/StringRef.h" 1403b7a1cfSDuncan P. N. Exon Smith #include "llvm/CodeGen/DwarfStringPoolEntry.h" 15daefdbf3SDavid Blaikie #include "llvm/Support/Allocator.h" 16daefdbf3SDavid Blaikie 17daefdbf3SDavid Blaikie namespace llvm { 18daefdbf3SDavid Blaikie 199d50e82fSDuncan P. N. Exon Smith class AsmPrinter; 20daefdbf3SDavid Blaikie class MCSection; 217bfa5d65SPavel Labath class MCSymbol; 22daefdbf3SDavid Blaikie 23daefdbf3SDavid Blaikie // Collection of strings for this unit and assorted symbols. 24daefdbf3SDavid Blaikie // A String->Symbol mapping of strings used by indirect 25daefdbf3SDavid Blaikie // references. 26daefdbf3SDavid Blaikie class DwarfStringPool { 276e07bfd0SEugene Zelenko using EntryTy = DwarfStringPoolEntry; 286e07bfd0SEugene Zelenko 291a65e4adSDuncan P. N. Exon Smith StringMap<EntryTy, BumpPtrAllocator &> Pool; 30daefdbf3SDavid Blaikie StringRef Prefix; 31*8c19ac23SIgor Kudrin uint64_t NumBytes = 0; 322f088116SPavel Labath unsigned NumIndexedStrings = 0; 33882a2b5aSDuncan P. N. Exon Smith bool ShouldCreateSymbols; 34daefdbf3SDavid Blaikie 352f088116SPavel Labath StringMapEntry<EntryTy> &getEntryImpl(AsmPrinter &Asm, StringRef Str); 362f088116SPavel Labath 37daefdbf3SDavid Blaikie public: 386e07bfd0SEugene Zelenko using EntryRef = DwarfStringPoolEntryRef; 3903b7a1cfSDuncan P. N. Exon Smith 40882a2b5aSDuncan P. N. Exon Smith DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix); 41daefdbf3SDavid Blaikie 427bfa5d65SPavel Labath void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, 437bfa5d65SPavel Labath MCSymbol *StartSym); 447bfa5d65SPavel Labath 450709a7bdSRafael Espindola void emit(AsmPrinter &Asm, MCSection *StrSection, 46456b555fSWolfgang Pieb MCSection *OffsetSection = nullptr, 47456b555fSWolfgang Pieb bool UseRelativeOffsets = false); 48daefdbf3SDavid Blaikie empty()49daefdbf3SDavid Blaikie bool empty() const { return Pool.empty(); } 508c6499faSDuncan P. N. Exon Smith size()51456b555fSWolfgang Pieb unsigned size() const { return Pool.size(); } 52456b555fSWolfgang Pieb getNumIndexedStrings()532f088116SPavel Labath unsigned getNumIndexedStrings() const { return NumIndexedStrings; } 542f088116SPavel Labath 5503b7a1cfSDuncan P. N. Exon Smith /// Get a reference to an entry in the string pool. 5603b7a1cfSDuncan P. N. Exon Smith EntryRef getEntry(AsmPrinter &Asm, StringRef Str); 572f088116SPavel Labath 582f088116SPavel Labath /// Same as getEntry, except that you can use EntryRef::getIndex to obtain a 592f088116SPavel Labath /// unique ID of this entry (e.g., for use in indexed forms like 602f088116SPavel Labath /// DW_FORM_strx). 612f088116SPavel Labath EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str); 62daefdbf3SDavid Blaikie }; 636e07bfd0SEugene Zelenko 646e07bfd0SEugene Zelenko } // end namespace llvm 656e07bfd0SEugene Zelenko 666e07bfd0SEugene Zelenko #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 67