28void StringTableBuilder::initSize() {
56 : K(K), Alignment(Alignment) {
75 memcpy(Buf +
P.second,
Data.data(),
Data.size());
90 return (
unsigned char)S[S.
size() - Pos - 1];
105 size_t J = Vec.
size();
106 for (
size_t K = 1;
K < J;) {
130 finalizeStringTable(
true);
134 finalizeStringTable(
false);
137void StringTableBuilder::finalizeStringTable(
bool Optimize) {
140 if (
Optimize && StringIndexMap.size()) {
141 std::vector<StringPair *> Strings;
142 Strings.reserve(StringIndexMap.size());
144 Strings.push_back(&
P);
146 size_t RangeBegin = 0;
148 if (StringPriorityMap.size()) {
151 return StringPriorityMap.lookup(LHS->first) >
152 StringPriorityMap.lookup(RHS->first);
154 uint8_t RangePriority = StringPriorityMap.lookup(Strings[0]->first);
155 for (
size_t I = 1,
E = Strings.size();
I !=
E && RangePriority; ++
I) {
156 uint8_t Priority = StringPriorityMap.lookup(Strings[
I]->first);
157 if (Priority != RangePriority) {
158 multikeySort(StringsRef.slice(RangeBegin,
I - RangeBegin), 0);
159 RangePriority = Priority;
169 StringRef S =
P->first.val();
171 size_t Pos = Size - S.
size() - (K !=
RAW);
178 Size =
alignTo(Size, Alignment);
197 StringIndexMap[CachedHashStringRef(
" ")] = 0;
204 StringIndexMap[CachedHashStringRef(
"")] = 0;
209 StringIndexMap.clear();
214 auto I = StringIndexMap.find(S);
215 assert(
I != StringIndexMap.end() &&
"String is not in table!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines CachedHashString and CachedHashStringRef.
This file defines the SmallString class.
static int charTailAt(StringPair *P, size_t Pos)
static void multikeySort(MutableArrayRef< StringPair * > Vec, int Pos)
DenseMap< CachedHashStringRef, size_t >::value_type StringPair
size_t size() const
Get the array size.
A container which contains a StringRef plus a precomputed hash.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
MutableArrayRef< T > slice(size_t N, size_t M) const
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...
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
LLVM_ABI void finalizeInOrder()
Finalize the string table without reording it.
LLVM_ABI size_t getOffset(CachedHashStringRef S) const
Get the offest of a string in the string table.
LLVM_ABI ~StringTableBuilder()
LLVM_ABI void write(raw_ostream &OS) const
LLVM_ABI void finalize()
Analyze the strings and build the final table.
LLVM_ABI StringTableBuilder(Kind K, Align Alignment=Align(1))
This class implements an extremely fast bulk output stream that can only output to a stream.
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.
void sort(IteratorTy Start, IteratorTy End)
constexpr 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.