28 void StringTableBuilder::initSize() {
50 : K(K), Alignment(Alignment) {
62 using StringPair = std::pair<CachedHashStringRef, size_t>;
69 memcpy(Buf +
P.second, Data.
data(), Data.
size());
84 return (
unsigned char)S[S.
size() - Pos - 1];
99 size_t J = Vec.
size();
100 for (
size_t K = 1; K < J;) {
116 Vec = Vec.
slice(I, J - I);
124 finalizeStringTable(
true);
128 finalizeStringTable(
false);
131 void StringTableBuilder::finalizeStringTable(
bool Optimize) {
135 std::vector<StringPair *> Strings;
136 Strings.reserve(StringIndexMap.size());
138 Strings.push_back(&
P);
147 size_t Pos = Size - S.
size() - (K !=
RAW);
148 if (!(Pos & (Alignment - 1))) {
154 Size =
alignTo(Size, Alignment);
177 StringIndexMap.clear();
182 auto I = StringIndexMap.find(S);
183 assert(
I != StringIndexMap.end() &&
"String is not in table!");
192 auto P = StringIndexMap.insert(std::make_pair(S, 0));
194 size_t Start =
alignTo(Size, Alignment);
195 P.first->second = Start;
196 Size = Start + S.
size() + (K !=
RAW);
198 return P.first->second;
MutableArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
A container which contains a StringRef plus a precomputed hash.
void write32be(void *P, uint32_t V)
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
This class represents lattice values for constants.
void write32le(void *P, uint32_t V)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void write(raw_ostream &OS) const
size_t add(CachedHashStringRef S)
Add a string to the builder.
LLVM_NODISCARD size_t size() const
size - Get the string size.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
static int charTailAt(StringPair *P, size_t Pos)
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void finalizeInOrder()
Finalize the string table without reording it.
size_t size() const
size - Get the array size.
void finalize()
Analyze the strings and build the final table.
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
pointer data()
Return a pointer to the vector's buffer, even if empty().
std::pair< CachedHashStringRef, size_t > StringPair
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void multikeySort(MutableArrayRef< StringPair *> Vec, int Pos)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.