LLVM 22.0.0git
|
Utility for building string tables with deduplicated suffixes. More...
#include "llvm/MC/StringTableBuilder.h"
Public Types | |
enum | Kind { ELF , WinCOFF , MachO , MachO64 , MachOLinked , MachO64Linked , RAW , DWARF , XCOFF , DXContainer } |
Public Member Functions | |
LLVM_ABI | StringTableBuilder (Kind K, Align Alignment=Align(1)) |
LLVM_ABI | ~StringTableBuilder () |
LLVM_ABI size_t | add (CachedHashStringRef S, uint8_t Priority=0) |
Add a string to the builder. | |
size_t | add (StringRef S, uint8_t Priority=0) |
LLVM_ABI void | finalize () |
Analyze the strings and build the final table. | |
LLVM_ABI void | finalizeInOrder () |
Finalize the string table without reording it. | |
LLVM_ABI size_t | getOffset (CachedHashStringRef S) const |
Get the offest of a string in the string table. | |
size_t | getOffset (StringRef S) const |
bool | contains (StringRef S) const |
Check if a string is contained in the string table. | |
bool | contains (CachedHashStringRef S) const |
bool | empty () const |
size_t | getSize () const |
LLVM_ABI void | clear () |
LLVM_ABI void | write (raw_ostream &OS) const |
LLVM_ABI void | write (uint8_t *Buf) const |
bool | isFinalized () const |
Utility for building string tables with deduplicated suffixes.
Definition at line 25 of file StringTableBuilder.h.
Enumerator | |
---|---|
ELF | |
WinCOFF | |
MachO | |
MachO64 | |
MachOLinked | |
MachO64Linked | |
RAW | |
DWARF | |
XCOFF | |
DXContainer |
Definition at line 27 of file StringTableBuilder.h.
Definition at line 56 of file StringTableBuilder.cpp.
|
default |
size_t StringTableBuilder::add | ( | CachedHashStringRef | S, |
uint8_t | Priority = 0 |
||
) |
Add a string to the builder.
Returns the position of S in the table. The position will be changed if finalize is used. Can only be used before the table is finalized. Priority is only useful with reordering. Strings with the same priority will be put together. Strings with higher priority are placed closer to the begin of string table. When adding same string with different priority, the maximum priority win.
Definition at line 220 of file StringTableBuilder.cpp.
References llvm::alignTo(), assert(), isFinalized(), llvm::COFF::NameSize, P, RAW, llvm::CachedHashStringRef::size(), and WinCOFF.
Referenced by add(), llvm::objcopy::elf::StringTableSection::addString(), llvm::MCDwarfLineStr::addString(), llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::gsym::GsymCreator::insertString(), ProcessElementList(), llvm::object::OffloadBinary::write(), llvm::mcdxbc::Signature::write(), llvm::WinCOFFWriter::writeObject(), writeTypeIdCompatibleVtableSummaryRecord(), writeTypeIdSummaryRecord(), and writeWholeProgramDevirtResolution().
Definition at line 63 of file StringTableBuilder.h.
References add().
void StringTableBuilder::clear | ( | ) |
Definition at line 208 of file StringTableBuilder.cpp.
Referenced by llvm::WinCOFFWriter::reset().
|
inline |
Definition at line 86 of file StringTableBuilder.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count().
Check if a string is contained in the string table.
Since this class doesn't store the string values, this function can be used to check if storage needs to be done prior to adding the string.
Definition at line 85 of file StringTableBuilder.h.
References contains().
Referenced by contains(), and llvm::gsym::GsymCreator::insertString().
|
inline |
Definition at line 88 of file StringTableBuilder.h.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty().
void StringTableBuilder::finalize | ( | ) |
Analyze the strings and build the final table.
No more strings can be added after this point.
Definition at line 129 of file StringTableBuilder.cpp.
References assert(), and DWARF.
Referenced by llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::objcopy::elf::StringTableSection::prepareForLayout(), llvm::object::OffloadBinary::write(), and llvm::WinCOFFWriter::writeObject().
void StringTableBuilder::finalizeInOrder | ( | ) |
Finalize the string table without reording it.
In this mode, offsets returned by add will still be valid.
Definition at line 134 of file StringTableBuilder.cpp.
Referenced by llvm::gsym::GsymCreator::finalize(), llvm::MCDwarfLineStr::getFinalizedData(), upgrade(), llvm::mcdxbc::Signature::write(), and llvm::BitcodeWriter::writeStrtab().
size_t StringTableBuilder::getOffset | ( | CachedHashStringRef | S | ) | const |
Get the offest of a string in the string table.
Can only be used after the table is finalized.
Definition at line 213 of file StringTableBuilder.cpp.
References assert(), I, and isFinalized().
Referenced by llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::objcopy::elf::StringTableSection::findIndex(), getOffset(), and llvm::object::OffloadBinary::write().
|
inline |
Definition at line 78 of file StringTableBuilder.h.
References getOffset().
|
inline |
Definition at line 89 of file StringTableBuilder.h.
Referenced by llvm::MCDwarfLineStr::getFinalizedData(), llvm::objcopy::elf::StringTableSection::prepareForLayout(), upgrade(), llvm::objcopy::elf::SRECSectionWriterBase::visit(), llvm::objcopy::elf::IHexSectionWriterBase::visit(), llvm::objcopy::elf::IHexSectionWriter::visit(), llvm::objcopy::elf::SRECSectionWriter::visit(), llvm::object::OffloadBinary::write(), write(), llvm::mcdxbc::PSVRuntimeInfo::write(), and llvm::BitcodeWriter::writeStrtab().
|
inline |
Definition at line 95 of file StringTableBuilder.h.
Referenced by add(), llvm::MCDwarfLineStr::getFinalizedData(), getOffset(), and write().
void StringTableBuilder::write | ( | raw_ostream & | OS | ) | const |
Definition at line 61 of file StringTableBuilder.cpp.
References assert(), llvm::Data, getSize(), isFinalized(), OS, and write().
Referenced by llvm::gsym::GsymCreator::encode(), llvm::MCDwarfLineStr::getFinalizedData(), upgrade(), llvm::objcopy::elf::SectionWriter::visit(), llvm::objcopy::elf::IHexSectionWriter::visit(), llvm::objcopy::elf::SRECSectionWriter::visit(), llvm::object::OffloadBinary::write(), llvm::mcdxbc::Signature::write(), write(), llvm::mcdxbc::PSVRuntimeInfo::write(), llvm::WinCOFFWriter::writeObject(), and llvm::BitcodeWriter::writeStrtab().
void StringTableBuilder::write | ( | uint8_t * | Buf | ) | const |
Definition at line 71 of file StringTableBuilder.cpp.
References assert(), llvm::Data, isFinalized(), P, WinCOFF, llvm::support::endian::write32be(), llvm::support::endian::write32le(), and XCOFF.