29 void StringTableBuilder::initSize() {
49 : K(K), Alignment(Alignment) {
61 using StringPair = std::pair<CachedHashStringRef, size_t>;
68 memcpy(Buf +
P.second, Data.
data(), Data.
size());
80 return (
unsigned char)S[S.
size() - Pos - 1];
117 finalizeStringTable(
true);
121 finalizeStringTable(
false);
124 void StringTableBuilder::finalizeStringTable(
bool Optimize) {
128 std::vector<StringPair *> Strings;
129 Strings.reserve(StringIndexMap.size());
131 Strings.push_back(&
P);
133 if (!Strings.empty()) {
145 size_t Pos = Size - S.
size() - (K !=
RAW);
146 if (!(Pos & (Alignment - 1))) {
152 Size =
alignTo(Size, Alignment);
168 StringIndexMap.clear();
173 auto I = StringIndexMap.find(S);
174 assert(
I != StringIndexMap.end() &&
"String is not in table!");
183 auto P = StringIndexMap.insert(std::make_pair(S, 0));
185 size_t Start =
alignTo(Size, Alignment);
186 P.first->second = Start;
187 Size = Start + S.
size() + (K !=
RAW);
189 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.
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)
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.
pointer data()
Return a pointer to the vector's buffer, even if empty().
std::pair< CachedHashStringRef, size_t > StringPair
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.