30 return memcmp(Data, RHS.Data, Size *
sizeof(*Data)) == 0;
35 return Size < RHS.Size;
36 return memcmp(Data, RHS.Data, Size *
sizeof(*Data)) < 0;
46 Bits.reserve(Bits.size() + NumInserts);
52 unsigned Units =
Size / 4;
54 const unsigned *
Base = (
const unsigned *)
String.data();
57 if (!((intptr_t)
Base & 3)) {
59 Pos = (Units + 1) * 4;
65 "Unexpected host endianness");
67 for (Pos += 4; Pos <=
Size; Pos += 4) {
68 unsigned V = ((
unsigned char)
String[Pos - 4] << 24) |
69 ((
unsigned char)
String[Pos - 3] << 16) |
71 (
unsigned char)
String[Pos - 1];
75 for (Pos += 4; Pos <=
Size; Pos += 4) {
76 unsigned V = ((
unsigned char)
String[Pos - 1] << 24) |
77 ((
unsigned char)
String[Pos - 2] << 16) |
79 (
unsigned char)
String[Pos - 4];
91 V = (V << 8) | (
unsigned char)
String[
Size - 3];
94 V = (V << 8) | (
unsigned char)
String[
Size - 2];
97 V = (V << 8) | (
unsigned char)
String[
Size - 1];
107 Bits.append(ID.Bits.begin(), ID.Bits.end());
128 unsigned *New = Allocator.Allocate<
unsigned>(Bits.size());
144 if (
reinterpret_cast<intptr_t
>(NextInBucketPtr) & 1)
153 intptr_t Ptr =
reinterpret_cast<intptr_t
>(NextInBucketPtr);
154 assert((Ptr & 1) &&
"Not a bucket pointer");
155 return reinterpret_cast<void **
>(Ptr & ~intptr_t(1));
160static void **
GetBucketFor(
unsigned Hash,
void **Buckets,
unsigned NumBuckets) {
162 unsigned BucketNum = Hash & (NumBuckets - 1);
163 return Buckets + BucketNum;
169 static_cast<void **
>(
safe_calloc(NumBuckets + 1,
sizeof(
void *)));
171 Buckets[NumBuckets] =
reinterpret_cast<void *
>(-1);
179 assert(5 < Log2InitSize && Log2InitSize < 32 &&
180 "Initial hash table size out of range");
188 Arg.incrementEpoch();
189 Arg.Buckets =
nullptr;
196 RHS.incrementEpoch();
201 RHS.Buckets =
nullptr;
221void FoldingSetBase::GrowBucketCount(
unsigned NewBucketCount,
222 const FoldingSetInfo &Info) {
224 "Can't shrink a folding set with GrowBucketCount");
235 Probe = NodeInBucket->getNextInBucket();
236 NodeInBucket->SetNextInBucket(
nullptr);
241 GetBucketFor(Info.ComputeNodeHash(
this, NodeInBucket, TempID),
242 Tmp.Buckets, Tmp.NumBuckets),
248 *
this = std::move(Tmp);
262 unsigned IDHash = ID.ComputeHash();
264 void *Probe = *Bucket;
270 if (Info.NodeEquals(
this, NodeInBucket, ID, IDHash, TempID))
274 Probe = NodeInBucket->getNextInBucket();
297 void **Bucket =
static_cast<void **
>(InsertPos);
299 void *
Next = *Bucket;
305 Next =
reinterpret_cast<void *
>(
reinterpret_cast<intptr_t
>(Bucket) | 1);
308 N->SetNextInBucket(
Next);
315 void *Ptr =
N->getNextInBucket();
321 N->SetNextInBucket(
nullptr);
324 void *NodeNextPtr = Ptr;
330 Ptr = NodeInBucket->getNextInBucket();
335 NodeInBucket->SetNextInBucket(NodeNextPtr);
345 *Bucket = NodeNextPtr;
355 Info.GetNodeProfile(
this,
N, ID);
370 while (*Bucket !=
reinterpret_cast<void *
>(-1) &&
380 void *Probe =
NodePtr->getNextInBucket();
391 }
while (*Bucket !=
reinterpret_cast<void *
>(-1) &&
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static void ** GetBucketPtr(void *NextInBucketPtr)
GetBucketPtr - Provides a casting of a bucket pointer for isNode testing.
static void ** GetBucketFor(unsigned Hash, void **Buckets, unsigned NumBuckets)
GetBucketFor - Hash the specified node ID and return the hash bucket for the specified ID.
static void ** AllocateBuckets(unsigned NumBuckets)
AllocateBuckets - Allocate initialized bucket memory.
static FoldingSetBase::Node * GetNextPtr(void *NextInBucketPtr)
Helper functions for FoldingSetBase.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
bool isHandleInSync() const
This class is used to maintain the singly linked bucket list in a folding set.
Implements the folding set functionality.
void ** Buckets
Array of bucket chains.
LLVM_ABI void reserve(unsigned EltCount, const FoldingSetInfo &Info)
Grow the number of buckets so that we can hold at least EltCount nodes before rebucketing.
unsigned capacity() const
Returns the number of nodes permitted in the folding set before a rebucket operation is performed.
LLVM_ABI bool RemoveNode(Node *N)
Remove a node from the folding set, returning true if one was removed or false if the node was not in...
LLVM_ABI FoldingSetBase & operator=(FoldingSetBase &&RHS)
LLVM_ABI ~FoldingSetBase()
unsigned NumBuckets
Length of the Buckets array. Always a power of 2.
unsigned NumNodes
Number of nodes in the folding set.
LLVM_ABI Node * GetOrInsertNode(Node *N, const FoldingSetInfo &Info)
If there is an existing node exactly equal to the node N, return it.
LLVM_ABI void InsertNode(Node *N, void *InsertPos, const FoldingSetInfo &Info)
Insert the specified node into the folding set, knowing that it is not already in the folding set.
LLVM_ABI void clear()
Remove all nodes from the folding set.
LLVM_ABI Node * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
Look up the node specified by ID.
LLVM_ABI FoldingSetBase(unsigned Log2InitSize)
LLVM_ABI FoldingSetIteratorImpl(const DebugEpochBase *Epoch, void **Bucket)
This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node...
LLVM_ABI bool operator==(FoldingSetNodeIDRef) const
LLVM_ABI bool operator<(FoldingSetNodeIDRef) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
FoldingSetNodeIDRef()=default
This class is used to gather all the unique data bits of a node.
LLVM_ABI FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
Copy this node's data to a memory region allocated from the given allocator and return a FoldingSetNo...
void clear()
Clear the accumulated profile, allowing this FoldingSetNodeID object to be used to compute a new prof...
FoldingSetNodeID()=default
LLVM_ABI bool operator==(const FoldingSetNodeID &RHS) const
operator== - Used to compare two nodes to each other.
LLVM_ABI bool operator<(const FoldingSetNodeID &RHS) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
LLVM_ABI void AddNodeID(const FoldingSetNodeID &ID)
LLVM_ABI void AddString(StringRef String)
Represent a constant reference to a string, i.e.
constexpr bool IsLittleEndianHost
constexpr bool IsBigEndianHost
This is an optimization pass for GlobalISel generic memory operations.
FoldingSetBase::Node FoldingSetNode
auto uninitialized_copy(R &&Src, IterTy Dst)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_calloc(size_t Count, size_t Sz)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
Functions provided by the derived class to compute folding properties.