23 void StringTableBuilder::initSize() {
43 : K(K), Alignment(Alignment) {
51 write((uint8_t *)&Data[0]);
55 typedef std::pair<CachedHashStringRef, size_t>
StringPair;
62 memcpy(Buf +
P.second, Data.
data(), Data.
size());
74 return (
unsigned char)S[S.
size() - Pos - 1];
111 finalizeStringTable(
true);
115 finalizeStringTable(
false);
118 void StringTableBuilder::finalizeStringTable(
bool Optimize) {
122 std::vector<StringPair *> Strings;
123 Strings.reserve(StringIndexMap.size());
125 Strings.push_back(&
P);
127 if (!Strings.empty()) {
139 size_t Pos = Size - S.
size() - (K !=
RAW);
140 if (!(Pos & (Alignment - 1))) {
146 Size =
alignTo(Size, Alignment);
162 StringIndexMap.clear();
167 auto I = StringIndexMap.find(S);
168 assert(
I != StringIndexMap.end() &&
"String is not in table!");
177 auto P = StringIndexMap.insert(std::make_pair(S, 0));
179 size_t Start =
alignTo(Size, Alignment);
180 P.first->second = Start;
181 Size = Start + S.
size() + (K !=
RAW);
183 return P.first->second;
A container which contains a StringRef plus a precomputed hash.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
void write32le(void *P, uint32_t V)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
size_t add(CachedHashStringRef S)
Add a string to the builder.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static int charTailAt(StringPair *P, size_t Pos)
void finalizeInOrder()
Finalize the string table without reording it.
static const unsigned End
static void multikey_qsort(StringPair **Begin, StringPair **End, int Pos)
void finalize()
Analyze the strings and build the final table.
std::pair< CachedHashStringRef, size_t > StringPair
void write(raw_ostream &OS) const
size_t getOffset(CachedHashStringRef S) const
Get the offest of a string in the string table.
StringTableBuilder(Kind K, unsigned Alignment=1)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
StringRef - Represent a constant reference to a string, i.e.