42 unsigned NumBuckets) {
43 return reinterpret_cast<unsigned *
>(TheTable + NumBuckets + 1);
49 : ItemSize(itemSize) {
60 assert((InitSize & (InitSize - 1)) == 0 &&
61 "Init Size must be a power of 2 or zero!");
63 unsigned NewNumBuckets = InitSize ? InitSize : 16;
80#ifdef EXPENSIVE_CHECKS
87 FullHashValue = ~FullHashValue;
88 unsigned BucketNo = FullHashValue & (
NumBuckets - 1);
91 unsigned ProbeAmt = 1;
92 int FirstTombstone = -1;
99 if (FirstTombstone != -1) {
100 HashTable[FirstTombstone] = FullHashValue;
101 return FirstTombstone;
104 HashTable[BucketNo] = FullHashValue;
110 if (FirstTombstone == -1)
111 FirstTombstone = BucketNo;
112 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
120 char *ItemStr = (
char *)BucketItem +
ItemSize;
128 BucketNo = (BucketNo + ProbeAmt) & (
NumBuckets - 1);
142#ifdef EXPENSIVE_CHECKS
146 FullHashValue = ~FullHashValue;
147 unsigned BucketNo = FullHashValue & (
NumBuckets - 1);
150 unsigned ProbeAmt = 1;
159 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
167 char *ItemStr = (
char *)BucketItem +
ItemSize;
175 BucketNo = (BucketNo + ProbeAmt) & (
NumBuckets - 1);
186 const char *VStr = (
char *)V +
ItemSize;
189 assert(V == V2 &&
"Didn't find key?");
224 unsigned NewBucketNo = BucketNo;
226 unsigned *NewHashArray =
getHashTable(NewTableArray, NewSize);
235 unsigned FullHash = HashTable[
I];
236 unsigned NewBucket = FullHash & (NewSize - 1);
237 if (NewTableArray[NewBucket]) {
238 unsigned ProbeSize = 1;
240 NewBucket = (NewBucket + ProbeSize++) & (NewSize - 1);
241 }
while (NewTableArray[NewBucket]);
245 NewTableArray[NewBucket] = Bucket;
246 NewHashArray[NewBucket] = FullHash;
248 NewBucketNo = NewBucket;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
static StringMapEntryBase ** createTable(unsigned NewNumBuckets)
static unsigned * getHashTable(StringMapEntryBase **TheTable, unsigned NumBuckets)
static unsigned getMinBucketToReserveForEntries(unsigned NumEntries)
Returns the number of buckets to allocate to ensure that the DenseMap can accommodate NumEntries with...
StringMapEntryBase - Shared base class of StringMapEntry instances.
size_t getKeyLength() const
static StringMapEntryBase * getTombstoneVal()
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
LLVM_ABI unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
LLVM_ABI void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
StringMapEntryBase ** TheTable
StringMapImpl(unsigned itemSize)
LLVM_ABI void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
static LLVM_ABI uint32_t hash(StringRef Key)
Returns the hash value that will be used for the given string.
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI uint64_t xxh3_64bits(ArrayRef< uint8_t > data)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
bool shouldReverseIterate()
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.