29void StringTableBuilder::initSize() {
57 : K(K), Alignment(Alignment) {
69using StringPair = std::pair<CachedHashStringRef, size_t>;
76 memcpy(Buf +
P.second,
Data.data(),
Data.size());
91 return (
unsigned char)S[S.
size() - Pos - 1];
106 size_t J = Vec.
size();
107 for (
size_t K = 1; K < J;) {
131 finalizeStringTable(
true);
135 finalizeStringTable(
false);
138void StringTableBuilder::finalizeStringTable(
bool Optimize) {
142 std::vector<StringPair *> Strings;
143 Strings.reserve(StringIndexMap.size());
145 Strings.push_back(&
P);
154 size_t Pos = Size - S.
size() - (K !=
RAW);
161 Size =
alignTo(Size, Alignment);
192 StringIndexMap.clear();
197 auto I = StringIndexMap.find(S);
198 assert(
I != StringIndexMap.end() &&
"String is not in table!");
207 auto P = StringIndexMap.insert(std::make_pair(S, 0));
209 size_t Start =
alignTo(Size, Alignment);
210 P.first->second = Start;
211 Size = Start + S.
size() + (K !=
RAW);
213 return P.first->second;
This file defines CachedHashString and CachedHashStringRef.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static int charTailAt(StringPair *P, size_t Pos)
std::pair< CachedHashStringRef, size_t > StringPair
static void multikeySort(MutableArrayRef< StringPair * > Vec, int Pos)
size_t size() const
size - Get the array size.
A container which contains a StringRef plus a precomputed hash.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
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.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
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.
void write(raw_ostream &OS) const
size_t add(CachedHashStringRef S)
Add a string to the builder.
void finalize()
Analyze the strings and build the final table.
StringTableBuilder(Kind K, Align Alignment=Align(1))
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
void write32le(void *P, uint32_t V)
void write32be(void *P, uint32_t V)
This is an optimization pass for GlobalISel generic memory operations.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.