35 if (Size != RHS.Size)
return false;
36 return memcmp(Data, RHS.Data, Size*
sizeof(*Data)) == 0;
43 return Size < RHS.Size;
44 return memcmp(Data, RHS.Data, Size*
sizeof(*Data)) < 0;
57 Bits.
append(reinterpret_cast<unsigned *>(&Ptr),
58 reinterpret_cast<unsigned *>(&Ptr+1));
70 if (
sizeof(
long) ==
sizeof(
int))
72 else if (
sizeof(
long) ==
sizeof(
long long)) {
83 if ((uint64_t)(
unsigned)I != I)
88 unsigned Size = String.
size();
92 unsigned Units = Size / 4;
94 const unsigned *Base = (
const unsigned*) String.
data();
98 Bits.
append(Base, Base + Units);
99 Pos = (Units + 1) * 4;
105 for (Pos += 4; Pos <= Size; Pos += 4) {
106 unsigned V = ((
unsigned char)String[Pos - 4] << 24) |
107 ((
unsigned char)String[Pos - 3] << 16) |
108 ((
unsigned char)String[Pos - 2] << 8) |
109 (
unsigned char)String[Pos - 1];
114 for (Pos += 4; Pos <= Size; Pos += 4) {
115 unsigned V = ((
unsigned char)String[Pos - 1] << 24) |
116 ((
unsigned char)String[Pos - 2] << 16) |
117 ((
unsigned char)String[Pos - 3] << 8) |
118 (
unsigned char)String[Pos - 4];
128 switch (Pos - Size) {
129 case 1: V = (V << 8) | (
unsigned char)String[Size - 3];
130 case 2: V = (V << 8) | (
unsigned char)String[Size - 2];
131 case 3: V = (V << 8) | (
unsigned char)String[Size - 1];
break;
176 unsigned *New = Allocator.
Allocate<
unsigned>(Bits.
size());
177 std::uninitialized_copy(Bits.
begin(), Bits.
end(), New);
192 if (reinterpret_cast<intptr_t>(NextInBucketPtr) & 1)
202 assert((Ptr & 1) &&
"Not a bucket pointer");
203 return reinterpret_cast<void**
>(Ptr & ~
intptr_t(1));
208 static void **
GetBucketFor(
unsigned Hash,
void **Buckets,
unsigned NumBuckets) {
210 unsigned BucketNum = Hash & (NumBuckets-1);
211 return Buckets + BucketNum;
216 void **Buckets =
static_cast<void**
>(
calloc(NumBuckets+1,
sizeof(
void*)));
218 Buckets[NumBuckets] =
reinterpret_cast<void*
>(-1);
226 assert(5 < Log2InitSize && Log2InitSize < 32 &&
227 "Initial hash table size out of range");
248 void FoldingSetImpl::GrowHashTable() {
259 for (
unsigned i = 0; i != OldNumBuckets; ++i) {
260 void *Probe = OldBuckets[i];
261 if (!Probe)
continue;
262 while (Node *NodeInBucket =
GetNextPtr(Probe)) {
264 Probe = NodeInBucket->getNextInBucket();
265 NodeInBucket->SetNextInBucket(0);
286 void *Probe = *Bucket;
292 if (
NodeEquals(NodeInBucket, ID, IDHash, TempID))
296 Probe = NodeInBucket->getNextInBucket();
319 void **Bucket =
static_cast<void**
>(InsertPos);
321 void *Next = *Bucket;
327 Next =
reinterpret_cast<void*
>(
reinterpret_cast<intptr_t>(Bucket)|1);
340 if (Ptr == 0)
return false;
346 void *NodeNextPtr = Ptr;
352 Ptr = NodeInBucket->getNextInBucket();
357 NodeInBucket->SetNextInBucket(NodeNextPtr);
367 *Bucket = NodeNextPtr;
392 while (*Bucket != reinterpret_cast<void*>(-1) &&
412 }
while (*Bucket != reinterpret_cast<void*>(-1) &&
423 Ptr = (*Bucket == 0 ||
GetNextPtr(*Bucket) == 0) ? (
void*) Bucket : *Bucket;
Node * GetOrInsertNode(Node *N)
void AddPointer(const void *Ptr)
void push_back(const T &Elt)
static void ** AllocateBuckets(unsigned NumBuckets)
AllocateBuckets - Allocated initialized bucket memory.
size_t size() const
size - Get the string size.
void InsertNode(Node *N, void *InsertPos)
static void ** GetBucketPtr(void *NextInBucketPtr)
testing.
unsigned ComputeHash() const
#define llvm_unreachable(msg)
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const =0
void AddInteger(signed I)
ID
LLVM Calling Convention Representation.
static const bool IsLittleEndianHost
const char * data() const
bool operator==(const FoldingSetNodeID &RHS) const
int memcmp(const void *s1, const void *s2, size_t n);
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const =0
void AddNodeID(const FoldingSetNodeID &ID)
void * getNextInBucket() const
bool operator<(FoldingSetNodeIDRef) const
static FoldingSetImpl::Node * GetNextPtr(void *NextInBucketPtr)
Helper functions for FoldingSetImpl.
Node * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
static void ** GetBucketFor(unsigned Hash, void **Buckets, unsigned NumBuckets)
FoldingSetImpl(unsigned Log2InitSize=6)
void append(in_iter in_start, in_iter in_end)
bool operator<(const FoldingSetNodeID &RHS) const
void SetNextInBucket(void *N)
virtual ~FoldingSetImpl()
void * Allocate(size_t Size, size_t Alignment)
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
pointer data()
data - Return a pointer to the vector's buffer, even if empty().
FoldingSetIteratorImpl(void **Bucket)
unsigned ComputeHash() const
static const bool IsBigEndianHost
void AddString(StringRef String)
FoldingSetBucketIteratorImpl(void **Bucket)
FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
virtual bool NodeEquals(Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID) const =0
void clear()
clear - Remove all nodes from the folding set.
void *calloc(size_t count, size_t size);
bool operator==(FoldingSetNodeIDRef) const