42 unsigned NumBuckets) {
43 return reinterpret_cast<unsigned *
>(TheTable + NumBuckets + 1);
68 assert((InitSize & (InitSize - 1)) == 0 &&
69 "Init Size must be a power of 2 or zero!");
71 unsigned NewNumBuckets = InitSize ? InitSize : 16;
88#ifdef EXPENSIVE_CHECKS
95 FullHashValue = ~FullHashValue;
96 unsigned BucketNo = FullHashValue & (
NumBuckets - 1);
99 unsigned ProbeAmt = 1;
100 int FirstTombstone = -1;
107 if (FirstTombstone != -1) {
108 HashTable[FirstTombstone] = FullHashValue;
109 return FirstTombstone;
112 HashTable[BucketNo] = FullHashValue;
118 if (FirstTombstone == -1)
119 FirstTombstone = BucketNo;
120 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
128 char *ItemStr = (
char *)BucketItem +
ItemSize;
136 BucketNo = (BucketNo + ProbeAmt) & (
NumBuckets - 1);
150#ifdef EXPENSIVE_CHECKS
154 FullHashValue = ~FullHashValue;
155 unsigned BucketNo = FullHashValue & (
NumBuckets - 1);
158 unsigned ProbeAmt = 1;
167 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
175 char *ItemStr = (
char *)BucketItem +
ItemSize;
183 BucketNo = (BucketNo + ProbeAmt) & (
NumBuckets - 1);
194 const char *VStr = (
char *)V +
ItemSize;
197 assert(V == V2 &&
"Didn't find key?");
232 unsigned NewBucketNo = BucketNo;
234 unsigned *NewHashArray =
getHashTable(NewTableArray, NewSize);
243 unsigned FullHash = HashTable[
I];
244 unsigned NewBucket = FullHash & (NewSize - 1);
245 if (NewTableArray[NewBucket]) {
246 unsigned ProbeSize = 1;
248 NewBucket = (NewBucket + ProbeSize++) & (NewSize - 1);
249 }
while (NewTableArray[NewBucket]);
253 NewTableArray[NewBucket] = Bucket;
254 NewHashArray[NewBucket] = FullHash;
256 NewBucketNo = NewBucket;
This file defines the StringMap class.
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
StringMapEntryBase ** TheTable
StringMapImpl(unsigned itemSize)
void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
static 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.
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.