22 : Pool(
A), Prefix(Prefix),
23 ShouldCreateSymbols(Asm.doesDwarfUseRelocationsAcrossSections()) {}
27 auto I = Pool.try_emplace(Str);
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++;
58 Asm.OutStreamer->switchSection(Section);
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);
89 return A->getValue().Offset <
B->getValue().Offset;
93 for (
const auto &Entry : Entries) {
94 assert(ShouldCreateSymbols ==
static_cast<bool>(Entry->getValue().Symbol) &&
95 "Mismatch between setting and entry");
98 if (ShouldCreateSymbols)
99 Asm.OutStreamer->emitLabel(Entry->getValue().Symbol);
104 if (Asm.isVerbose()) {
107 CommentOS <<
"string offset=" << Entry->getValue().Offset <<
" ; ";
109 StringRef(Entry->getKeyData(), Entry->getKeyLength()),
111 Asm.OutStreamer->AddComment(Comment);
115 Asm.OutStreamer->emitBytes(
116 StringRef(Entry->getKeyData(), Entry->getKeyLength() + 1));
123 Entries.
resize(NumIndexedStrings);
124 for (
const auto &Entry : Pool) {
125 if (Entry.getValue().isIndexed())
126 Entries[Entry.getValue().Index] = &Entry;
129 Asm.OutStreamer->switchSection(OffsetSection);
130 unsigned size = Asm.getDwarfOffsetByteSize();
131 for (
const auto &Entry : Entries)
132 if (UseRelativeOffsets)
133 Asm.emitDwarfStringOffset(Entry->getValue());
135 Asm.OutStreamer->emitIntValue(Entry->getValue().Offset,
size);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the SmallString class.
This file defines the SmallVector class.
This class is intended to be used as a driving class for all asm writers.
LLVM_ABI_FOR_TEST EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
LLVM_ABI_FOR_TEST 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....
DwarfStringPoolEntryRef EntryRef
unsigned getNumIndexedStrings() const
LLVM_ABI_FOR_TEST void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, MCSymbol *StartSym)
LLVM_ABI_FOR_TEST DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
LLVM_ABI_FOR_TEST 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.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Represent a constant reference to a string, i.e.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
A raw_ostream that writes to an SmallVector or SmallString.
This is an optimization pass for GlobalISel generic memory operations.
void sort(IteratorTy Start, IteratorTy End)
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
static constexpr unsigned NotIndexed