1*0b57cec5SDimitry Andric //===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 10*0b57cec5SDimitry Andric #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric #include "llvm/ADT/StringMap.h" 13*0b57cec5SDimitry Andric #include "llvm/ADT/StringRef.h" 14*0b57cec5SDimitry Andric #include "llvm/CodeGen/DwarfStringPoolEntry.h" 15*0b57cec5SDimitry Andric #include "llvm/Support/Allocator.h" 16*0b57cec5SDimitry Andric 17*0b57cec5SDimitry Andric namespace llvm { 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric class AsmPrinter; 20*0b57cec5SDimitry Andric class MCSection; 21*0b57cec5SDimitry Andric class MCSymbol; 22*0b57cec5SDimitry Andric 23*0b57cec5SDimitry Andric // Collection of strings for this unit and assorted symbols. 24*0b57cec5SDimitry Andric // A String->Symbol mapping of strings used by indirect 25*0b57cec5SDimitry Andric // references. 26*0b57cec5SDimitry Andric class DwarfStringPool { 27*0b57cec5SDimitry Andric using EntryTy = DwarfStringPoolEntry; 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andric StringMap<EntryTy, BumpPtrAllocator &> Pool; 30*0b57cec5SDimitry Andric StringRef Prefix; 31*0b57cec5SDimitry Andric unsigned NumBytes = 0; 32*0b57cec5SDimitry Andric unsigned NumIndexedStrings = 0; 33*0b57cec5SDimitry Andric bool ShouldCreateSymbols; 34*0b57cec5SDimitry Andric 35*0b57cec5SDimitry Andric StringMapEntry<EntryTy> &getEntryImpl(AsmPrinter &Asm, StringRef Str); 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric public: 38*0b57cec5SDimitry Andric using EntryRef = DwarfStringPoolEntryRef; 39*0b57cec5SDimitry Andric 40*0b57cec5SDimitry Andric DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix); 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, 43*0b57cec5SDimitry Andric MCSymbol *StartSym); 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andric void emit(AsmPrinter &Asm, MCSection *StrSection, 46*0b57cec5SDimitry Andric MCSection *OffsetSection = nullptr, 47*0b57cec5SDimitry Andric bool UseRelativeOffsets = false); 48*0b57cec5SDimitry Andric 49*0b57cec5SDimitry Andric bool empty() const { return Pool.empty(); } 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andric unsigned size() const { return Pool.size(); } 52*0b57cec5SDimitry Andric 53*0b57cec5SDimitry Andric unsigned getNumIndexedStrings() const { return NumIndexedStrings; } 54*0b57cec5SDimitry Andric 55*0b57cec5SDimitry Andric /// Get a reference to an entry in the string pool. 56*0b57cec5SDimitry Andric EntryRef getEntry(AsmPrinter &Asm, StringRef Str); 57*0b57cec5SDimitry Andric 58*0b57cec5SDimitry Andric /// Same as getEntry, except that you can use EntryRef::getIndex to obtain a 59*0b57cec5SDimitry Andric /// unique ID of this entry (e.g., for use in indexed forms like 60*0b57cec5SDimitry Andric /// DW_FORM_strx). 61*0b57cec5SDimitry Andric EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str); 62*0b57cec5SDimitry Andric }; 63*0b57cec5SDimitry Andric 64*0b57cec5SDimitry Andric } // end namespace llvm 65*0b57cec5SDimitry Andric 66*0b57cec5SDimitry Andric #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 67