29 void StringTableBuilder::initSize() {
50 : K(K), Alignment(Alignment) {
62 using StringPair = std::pair<CachedHashStringRef, size_t>;
81 return (
unsigned char)S[S.
size() - Pos - 1];
96 size_t J = Vec.
size();
97 for (
size_t K = 1; K < J;) {
113 Vec = Vec.
slice(I, J - I);
121 finalizeStringTable(
true);
125 finalizeStringTable(
false);
128 void StringTableBuilder::finalizeStringTable(
bool Optimize) {
132 std::vector<StringPair *> Strings;
133 Strings.reserve(StringIndexMap.size());
135 Strings.push_back(&
P);
144 size_t Pos = Size - S.
size() - (K !=
RAW);
145 if (!(Pos & (Alignment - 1))) {
151 Size =
alignTo(Size, Alignment);
167 StringIndexMap.clear();
172 auto I = StringIndexMap.find(S);
173 assert(
I != StringIndexMap.end() &&
"String is not in table!");
182 auto P = StringIndexMap.insert(std::make_pair(S, 0));
184 size_t Start =
alignTo(Size, Alignment);
185 P.first->second = Start;
186 Size = Start + S.
size() + (K !=
RAW);
188 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.
This class represents lattice values for constants.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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...
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).
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
void write(raw_ostream &OS) const
size_t add(CachedHashStringRef S)
Add a string to the builder.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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.
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())
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.