53 assert((InitSize & (InitSize-1)) == 0 &&
54 "Init Size must be a power of 2 or zero!");
80 unsigned BucketNo = FullHashValue & (HTSize-1);
83 unsigned ProbeAmt = 1;
84 int FirstTombstone = -1;
91 if (FirstTombstone != -1) {
92 HashTable[FirstTombstone] = FullHashValue;
93 return FirstTombstone;
96 HashTable[BucketNo] = FullHashValue;
102 if (FirstTombstone == -1) FirstTombstone = BucketNo;
103 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
111 char *ItemStr = (
char*)BucketItem+
ItemSize;
119 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
132 if (HTSize == 0)
return -1;
134 unsigned BucketNo = FullHashValue & (HTSize-1);
137 unsigned ProbeAmt = 1;
146 }
else if (
LLVM_LIKELY(HashTable[BucketNo] == FullHashValue)) {
154 char *ItemStr = (
char*)BucketItem+
ItemSize;
162 BucketNo = (BucketNo+ProbeAmt) & (HTSize-1);
173 const char *VStr = (
char*)V +
ItemSize;
176 assert(V == V2 &&
"Didn't find key?");
183 if (Bucket == -1)
return nullptr;
212 unsigned NewBucketNo = BucketNo;
218 unsigned *NewHashArray = (
unsigned *)(NewTableArray + NewSize + 1);
227 unsigned FullHash = HashTable[
I];
228 unsigned NewBucket = FullHash & (NewSize-1);
229 if (!NewTableArray[NewBucket]) {
230 NewTableArray[FullHash & (NewSize-1)] = Bucket;
231 NewHashArray[FullHash & (NewSize-1)] = FullHash;
233 NewBucketNo = NewBucket;
238 unsigned ProbeSize = 1;
240 NewBucket = (NewBucket + ProbeSize++) & (NewSize-1);
241 }
while (NewTableArray[NewBucket]);
244 NewTableArray[NewBucket] = Bucket;
245 NewHashArray[NewBucket] = FullHash;
247 NewBucketNo = NewBucket;
StringMapImpl(unsigned itemSize)
static unsigned HashString(StringRef Str, unsigned Result=0)
HashString - Hash function for strings.
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
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...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
StringMapEntryBase ** TheTable
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)
NextPowerOf2 - Returns the next power of two (in 64-bits) that is strictly greater than A...
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it...
static StringMapEntryBase * getTombstoneVal()
unsigned getKeyLength() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringRef - Represent a constant reference to a string, i.e.