Go to the documentation of this file.
23 ShouldCreateSymbols(
Asm.MAI->doesDwarfUseRelocationsAcrossSections()) {}
27 auto I = Pool.insert(std::make_pair(Str, EntryTy()));
28 auto &Entry =
I.first->second;
31 Entry.Offset = NumBytes;
32 Entry.Symbol = ShouldCreateSymbols ?
Asm.createTempSymbol(Prefix) :
nullptr;
34 NumBytes += Str.
size() + 1;
41 auto &MapEntry = getEntryImpl(
Asm, Str);
47 auto &MapEntry = getEntryImpl(
Asm, Str);
48 if (!MapEntry.getValue().isIndexed())
49 MapEntry.getValue().Index = NumIndexedStrings++;
59 unsigned EntrySize =
Asm.getDwarfOffsetByteSize();
65 "Length of String Offsets Set");
66 Asm.emitInt16(
Asm.getDwarfVersion());
72 Asm.OutStreamer->emitLabel(StartSym);
76 MCSection *OffsetSection,
bool UseRelativeOffsets) {
81 Asm.OutStreamer->SwitchSection(StrSection);
85 Entries.reserve(Pool.size());
87 for (
const auto &
E : Pool)
88 Entries.push_back(&
E);
92 return A->getValue().Offset < B->getValue().
Offset;
95 for (
const auto &Entry : Entries) {
96 assert(ShouldCreateSymbols ==
static_cast<bool>(Entry->getValue().Symbol) &&
97 "Mismatch between setting and entry");
100 if (ShouldCreateSymbols)
101 Asm.OutStreamer->emitLabel(Entry->getValue().Symbol);
104 Asm.OutStreamer->AddComment(
"string offset=" +
105 Twine(Entry->getValue().Offset));
106 Asm.OutStreamer->emitBytes(
107 StringRef(Entry->getKeyData(), Entry->getKeyLength() + 1));
114 Entries.resize(NumIndexedStrings);
115 for (
const auto &Entry : Pool) {
116 if (Entry.getValue().isIndexed())
117 Entries[Entry.getValue().Index] = &Entry;
120 Asm.OutStreamer->SwitchSection(OffsetSection);
121 unsigned size =
Asm.getDwarfOffsetByteSize();
122 for (
const auto &Entry : Entries)
123 if (UseRelativeOffsets)
124 Asm.emitDwarfStringOffset(Entry->getValue());
126 Asm.OutStreamer->emitIntValue(Entry->getValue().Offset,
size);
EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DwarfStringPoolEntryRef EntryRef
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str)
Same as getEntry, except that you can use EntryRef::getIndex to obtain a unique ID of this entry (e....
String pool entry reference.
static constexpr unsigned NotIndexed
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, MCSymbol *StartSym)
Allocate memory in an ever growing pool, as if by bump-pointer.
unsigned getNumIndexedStrings() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
void emit(AsmPrinter &Asm, MCSection *StrSection, MCSection *OffsetSection=nullptr, bool UseRelativeOffsets=false)
Instances of this class represent a uniqued identifier for a section in the current translation unit.
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void sort(IteratorTy Start, IteratorTy End)
This class is intended to be used as a driving class for all asm writers.
LLVM_NODISCARD size_t size() const
size - Get the string size.