54 assert((InitSize & (InitSize-1)) == 0 &&
55 "Init Size must be a power of 2 or zero!");
57 unsigned NewNumBuckets = InitSize ? InitSize : 16;
84 unsigned FullHashValue =
djbHash(Name, 0);
85 unsigned BucketNo = FullHashValue & (HTSize-1);
88 unsigned ProbeAmt = 1;
89 int FirstTombstone = -1;
96 if (FirstTombstone != -1) {
97 HashTable[FirstTombstone] = FullHashValue;
98 return FirstTombstone;
101 HashTable[BucketNo] = FullHashValue;
107 if (FirstTombstone == -1) FirstTombstone = BucketNo;
108 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
116 char *ItemStr = (
char*)BucketItem+
ItemSize;
124 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
137 if (HTSize == 0)
return -1;
138 unsigned FullHashValue =
djbHash(Key, 0);
139 unsigned BucketNo = FullHashValue & (HTSize-1);
142 unsigned ProbeAmt = 1;
151 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
159 char *ItemStr = (
char*)BucketItem+
ItemSize;
167 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
178 const char *VStr = (
char*)V +
ItemSize;
181 assert(V == V2 &&
"Didn't find key?");
188 if (Bucket == -1)
return nullptr;
217 unsigned NewBucketNo = BucketNo;
223 unsigned *NewHashArray = (
unsigned *)(NewTableArray + NewSize + 1);
232 unsigned FullHash = HashTable[
I];
233 unsigned NewBucket = FullHash & (NewSize-1);
234 if (!NewTableArray[NewBucket]) {
235 NewTableArray[FullHash & (NewSize-1)] = Bucket;
236 NewHashArray[FullHash & (NewSize-1)] = FullHash;
238 NewBucketNo = NewBucket;
243 unsigned ProbeSize = 1;
245 NewBucket = (NewBucket + ProbeSize++) & (NewSize-1);
246 }
while (NewTableArray[NewBucket]);
249 NewTableArray[NewBucket] = Bucket;
250 NewHashArray[NewBucket] = FullHash;
252 NewBucketNo = NewBucket;
StringMapImpl(unsigned itemSize)
This class represents lattice values for constants.
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.
#define LLVM_UNLIKELY(EXPR)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.
#define LLVM_LIKELY(EXPR)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
StringRef - Represent a constant reference to a string, i.e.