LLVM 20.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 | |
StringTableBuilder (Kind K, Align Alignment=Align(1)) | |
~StringTableBuilder () | |
size_t | add (CachedHashStringRef S) |
Add a string to the builder. | |
size_t | add (StringRef S) |
void | finalize () |
Analyze the strings and build the final table. | |
void | finalizeInOrder () |
Finalize the string table without reording it. | |
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 |
size_t | getSize () const |
void | clear () |
void | write (raw_ostream &OS) const |
void | write (uint8_t *Buf) const |
bool | isFinalized () const |
Utility for building string tables with deduplicated suffixes.
Definition at line 24 of file StringTableBuilder.h.
Enumerator | |
---|---|
ELF | |
WinCOFF | |
MachO | |
MachO64 | |
MachOLinked | |
MachO64Linked | |
RAW | |
DWARF | |
XCOFF | |
DXContainer |
Definition at line 26 of file StringTableBuilder.h.
Definition at line 56 of file StringTableBuilder.cpp.
|
default |
size_t StringTableBuilder::add | ( | CachedHashStringRef | S | ) |
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.
Definition at line 202 of file StringTableBuilder.cpp.
References llvm::alignTo(), assert(), isFinalized(), llvm::COFF::NameSize, P, RAW, llvm::CachedHashStringRef::size(), and WinCOFF.
Referenced by 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().
|
inline |
void StringTableBuilder::clear | ( | ) |
Definition at line 190 of file StringTableBuilder.cpp.
Referenced by llvm::WinCOFFWriter::reset().
|
inline |
Definition at line 78 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 77 of file StringTableBuilder.h.
References contains().
Referenced by contains(), and llvm::gsym::GsymCreator::insertString().
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 195 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 70 of file StringTableBuilder.h.
References getOffset().
|
inline |
Definition at line 80 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 86 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.