28 if (Size != RHS.Size)
return false;
29 return memcmp(Data, RHS.Data, Size*
sizeof(*Data)) == 0;
36 return Size < RHS.Size;
37 return memcmp(Data, RHS.Data, Size*
sizeof(*Data)) < 0;
49 Bits.reserve(Bits.size() + NumInserts);
54 unsigned Units =
Size / 4;
56 const unsigned *
Base = (
const unsigned*)
String.data();
59 if (!((intptr_t)
Base & 3)) {
61 Pos = (Units + 1) * 4;
67 "Unexpected host endianness");
69 for (Pos += 4; Pos <=
Size; Pos += 4) {
70 unsigned V = ((
unsigned char)
String[Pos - 4] << 24) |
71 ((
unsigned char)
String[Pos - 3] << 16) |
73 (
unsigned char)
String[Pos - 1];
77 for (Pos += 4; Pos <=
Size; Pos += 4) {
78 unsigned V = ((
unsigned char)
String[Pos - 1] << 24) |
79 ((
unsigned char)
String[Pos - 2] << 16) |
81 (
unsigned char)
String[Pos - 4];
92 case 1: V = (V << 8) | (
unsigned char)
String[
Size - 3]; [[fallthrough]];
93 case 2: V = (V << 8) | (
unsigned char)
String[
Size - 2]; [[fallthrough]];
94 case 3: V = (V << 8) | (
unsigned char)
String[
Size - 1];
break;
103 Bits.append(
ID.Bits.begin(),
ID.Bits.end());
133 unsigned *New = Allocator.Allocate<
unsigned>(Bits.size());
149 if (
reinterpret_cast<intptr_t
>(NextInBucketPtr) & 1)
158 intptr_t
Ptr =
reinterpret_cast<intptr_t
>(NextInBucketPtr);
159 assert((
Ptr & 1) &&
"Not a bucket pointer");
160 return reinterpret_cast<void**
>(
Ptr & ~intptr_t(1));
165static void **
GetBucketFor(
unsigned Hash,
void **Buckets,
unsigned NumBuckets) {
167 unsigned BucketNum = Hash & (NumBuckets-1);
168 return Buckets + BucketNum;
173 void **Buckets =
static_cast<void**
>(
safe_calloc(NumBuckets + 1,
176 Buckets[NumBuckets] =
reinterpret_cast<void*
>(-1);
184 assert(5 < Log2InitSize && Log2InitSize < 32 &&
185 "Initial hash table size out of range");
193 Arg.Buckets =
nullptr;
203 RHS.Buckets =
nullptr;
224void FoldingSetBase::GrowBucketCount(
unsigned NewBucketCount,
225 const FoldingSetInfo &Info) {
227 "Can't shrink a folding set with GrowBucketCount");
240 for (
unsigned i = 0; i != OldNumBuckets; ++i) {
241 void *Probe = OldBuckets[i];
242 if (!Probe)
continue;
245 Probe = NodeInBucket->getNextInBucket();
246 NodeInBucket->SetNextInBucket(
nullptr);
250 GetBucketFor(Info.ComputeNodeHash(
this, NodeInBucket, TempID),
262void FoldingSetBase::GrowHashTable(
const FoldingSetInfo &
Info) {
280 unsigned IDHash =
ID.ComputeHash();
282 void *Probe = *Bucket;
288 if (Info.NodeEquals(
this, NodeInBucket,
ID, IDHash, TempID))
292 Probe = NodeInBucket->getNextInBucket();
317 void **Bucket =
static_cast<void**
>(InsertPos);
319 void *
Next = *Bucket;
325 Next =
reinterpret_cast<void*
>(
reinterpret_cast<intptr_t
>(Bucket)|1);
328 N->SetNextInBucket(
Next);
337 void *
Ptr =
N->getNextInBucket();
338 if (!
Ptr)
return false;
341 N->SetNextInBucket(
nullptr);
344 void *NodeNextPtr =
Ptr;
350 Ptr = NodeInBucket->getNextInBucket();
355 NodeInBucket->SetNextInBucket(NodeNextPtr);
365 *Bucket = NodeNextPtr;
379 Info.GetNodeProfile(
this,
N,
ID);
392 while (*Bucket !=
reinterpret_cast<void*
>(-1) &&
401 void *Probe =
NodePtr->getNextInBucket();
412 }
while (*Bucket !=
reinterpret_cast<void*
>(-1) &&
423 Ptr = (!*Bucket || !
GetNextPtr(*Bucket)) ? (
void*) Bucket : *Bucket;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
Analysis containing CSE Info
static void ** GetBucketPtr(void *NextInBucketPtr)
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 - Allocated 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.
Merge contiguous icmps into a memcmp
Node - This class is used to maintain the singly linked bucket list in a folding set.
LLVM_ABI FoldingSetBase(unsigned Log2InitSize=6)
void ** Buckets
Buckets - Array of bucket chains.
LLVM_ABI void reserve(unsigned EltCount, const FoldingSetInfo &Info)
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket...
LLVM_ABI bool RemoveNode(Node *N)
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the no...
LLVM_ABI FoldingSetBase & operator=(FoldingSetBase &&RHS)
LLVM_ABI ~FoldingSetBase()
unsigned NumBuckets
NumBuckets - Length of the Buckets array. Always a power of 2.
unsigned NumNodes
NumNodes - Number of nodes in the folding set.
unsigned capacity()
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is pe...
LLVM_ABI Node * GetOrInsertNode(Node *N, const FoldingSetInfo &Info)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node,...
LLVM_ABI void InsertNode(Node *N, void *InsertPos, const FoldingSetInfo &Info)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
LLVM_ABI void clear()
clear - Remove all nodes from the folding set.
LLVM_ABI Node * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
FindNodeOrInsertPos - Look up the node specified by ID.
LLVM_ABI FoldingSetBucketIteratorImpl(void **Bucket)
LLVM_ABI FoldingSetIteratorImpl(void **Bucket)
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID,...
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
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
LLVM_ABI FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
Intern - Copy this node's data to a memory region allocated from the given allocator and return a Fol...
void clear()
clear - Clear the accumulated profile, allowing this FoldingSetNodeID object to be used to compute a ...
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)
Add* - Add various data types to Bit data.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
FunctionAddr VTableAddr Next
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.