53 assert((InitSize & (InitSize-1)) == 0 &&
54 "Init Size must be a power of 2 or zero!");
56 unsigned NewNumBuckets = InitSize ? InitSize : 16;
83 unsigned FullHashValue =
djbHash(Name, 0);
84 unsigned BucketNo = FullHashValue & (HTSize-1);
87 unsigned ProbeAmt = 1;
88 int FirstTombstone = -1;
95 if (FirstTombstone != -1) {
96 HashTable[FirstTombstone] = FullHashValue;
97 return FirstTombstone;
100 HashTable[BucketNo] = FullHashValue;
106 if (FirstTombstone == -1) FirstTombstone = BucketNo;
107 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
115 char *ItemStr = (
char*)BucketItem+
ItemSize;
123 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
136 if (HTSize == 0)
return -1;
137 unsigned FullHashValue =
djbHash(Key, 0);
138 unsigned BucketNo = FullHashValue & (HTSize-1);
141 unsigned ProbeAmt = 1;
150 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
158 char *ItemStr = (
char*)BucketItem+
ItemSize;
166 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
177 const char *VStr = (
char*)V +
ItemSize;
180 assert(V == V2 &&
"Didn't find key?");
187 if (Bucket == -1)
return nullptr;
216 unsigned NewBucketNo = BucketNo;
222 unsigned *NewHashArray = (
unsigned *)(NewTableArray + NewSize + 1);
231 unsigned FullHash = HashTable[
I];
232 unsigned NewBucket = FullHash & (NewSize-1);
233 if (!NewTableArray[NewBucket]) {
234 NewTableArray[FullHash & (NewSize-1)] = Bucket;
235 NewHashArray[FullHash & (NewSize-1)] = FullHash;
237 NewBucketNo = NewBucket;
242 unsigned ProbeSize = 1;
244 NewBucket = (NewBucket + ProbeSize++) & (NewSize-1);
245 }
while (NewTableArray[NewBucket]);
248 NewTableArray[NewBucket] = Bucket;
249 NewHashArray[NewBucket] = FullHash;
251 NewBucketNo = NewBucket;
StringMapImpl(unsigned itemSize)
This class represents lattice values for constants.
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
static unsigned getMinBucketToReserveForEntries(unsigned NumEntries)
Returns the number of buckets to allocate to ensure that the DenseMap can accommodate NumEntries with...
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
StringMapEntryBase ** TheTable
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty...
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
uint32_t djbHash(StringRef Buffer, uint32_t H=5381)
The Bernstein hash function used by the DWARF accelerator tables.
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it...
static StringMapEntryBase * getTombstoneVal()
size_t getKeyLength() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringMapEntryBase - Shared base class of StringMapEntry instances.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
StringRef - Represent a constant reference to a string, i.e.