28 if (LHS.size() != RHS.size())
29 return LHS.size() < RHS.size();
30 return memcmp(LHS.data(), RHS.data(), LHS.size() *
sizeof(
unsigned)) < 0;
40 Bits.reserve(Bits.size() + NumInserts);
46 unsigned Units =
Size / 4;
48 const unsigned *
Base = (
const unsigned *)
String.data();
51 if (!((intptr_t)
Base & 3)) {
53 Pos = (Units + 1) * 4;
59 "Unexpected host endianness");
61 for (Pos += 4; Pos <=
Size; Pos += 4) {
62 unsigned V = ((
unsigned char)
String[Pos - 4] << 24) |
63 ((
unsigned char)
String[Pos - 3] << 16) |
65 (
unsigned char)
String[Pos - 1];
69 for (Pos += 4; Pos <=
Size; Pos += 4) {
70 unsigned V = ((
unsigned char)
String[Pos - 1] << 24) |
71 ((
unsigned char)
String[Pos - 2] << 16) |
73 (
unsigned char)
String[Pos - 4];
85 V = (V << 8) | (
unsigned char)
String[
Size - 3];
88 V = (V << 8) | (
unsigned char)
String[
Size - 2];
91 V = (V << 8) | (
unsigned char)
String[
Size - 1];
101 Bits.append(ID.Bits.begin(), ID.Bits.end());
106 unsigned *New = Allocator.Allocate<
unsigned>(Bits.size());
115 assert(5 < Log2InitSize && Log2InitSize < 32 &&
116 "Initial hash table size out of range");
126 Arg.incrementEpoch();
134 RHS.incrementEpoch();
136 Buckets = std::exchange(RHS.Buckets,
nullptr);
137 NumBuckets = std::exchange(RHS.NumBuckets, 0);
138 NumNodes = std::exchange(RHS.NumNodes, 0);
154 unsigned I = Hash & Mask;
163void FoldingSetBase::grow(
unsigned MinNumBuckets) {
165 unsigned NewBucketCount = std::max(64u,
llvm::bit_ceil(MinNumBuckets));
171 Tmp.placeNode(
N,
N->getFoldingSetHash());
173 *
this = std::move(Tmp);
180 grow(
N + (
N + 2) / 3);
184 assert(
N &&
"Cannot insert a null node");
185 assert(Token &&
"Invalid token!");
191 N->setFoldingSetHash(Hash);
200 unsigned I = Hash & Mask;
211 for (
unsigned J = (
I + 1) & Mask;
Buckets[J]; J = (J + 1) & Mask) {
212 unsigned Ideal =
Buckets[J]->getFoldingSetHash();
213 if (((
I - Ideal) & Mask) < ((J - Ideal) & Mask)) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
#define LLVM_UNLIKELY(EXPR)
This file defines a hash set that can be used to remove duplication of nodes in a graph.
LLVM_ABI bool erase(FoldingSetNode *N)
Remove a node from the folding set, returning true if one was removed or false if the node was not in...
FoldingSetNode ** Buckets
Array of node pointers; a null entry marks an empty slot.
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 void insert(FoldingSetNode *N, FoldingSetInsertToken Token)
Insert the specified node into the folding set, knowing that it is not already in the folding set.
LLVM_ABI void reserve(unsigned N)
Grow the number of buckets so that we can hold at least N nodes before rebucketing.
LLVM_ABI void clear()
Remove all nodes from the folding set.
LLVM_ABI FoldingSetBase(unsigned Log2InitSize)
Insertion token: a failed lookup fills it in, the matching insert consumes it.
This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node...
static constexpr unsigned NotAHash
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...
FoldingSetNodeID()=default
LLVM_ABI void AddNodeID(const FoldingSetNodeID &ID)
LLVM_ABI void AddString(StringRef String)
This class is used to maintain node state in a folding set.
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.
bool operator<(int64_t V1, const APSInt &V2)
auto uninitialized_copy(R &&Src, IterTy Dst)
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
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 T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Implement std::hash so that hash_code can be used in STL containers.