29 return Size < RHS.Size;
30 return memcmp(Data, RHS.Data, Size *
sizeof(*Data)) < 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());
114 unsigned *New = Allocator.Allocate<
unsigned>(Bits.size());
123 assert(5 < Log2InitSize && Log2InitSize < 32 &&
124 "Initial hash table size out of range");
133 Arg.incrementEpoch();
141 RHS.incrementEpoch();
143 Buckets = std::exchange(RHS.Buckets,
nullptr);
144 NumBuckets = std::exchange(RHS.NumBuckets, 0);
145 NumNodes = std::exchange(RHS.NumNodes, 0);
161 unsigned I = Hash & Mask;
170void FoldingSetBase::grow(
unsigned MinNumBuckets) {
172 unsigned NewBucketCount = std::max(64u,
llvm::bit_ceil(MinNumBuckets));
178 Tmp.placeNode(
static_cast<Node *
>(
N),
179 static_cast<Node *
>(
N)->getFoldingSetHash());
181 *
this = std::move(Tmp);
188 grow(
N + (
N + 2) / 3);
192 assert(
N &&
"Cannot insert a null node");
193 assert(Token &&
"Invalid token!");
199 N->setFoldingSetHash(Hash);
208 unsigned I = Hash & Mask;
219 for (
unsigned J = (
I + 1) & Mask;
Buckets[J]; J = (J + 1) & Mask) {
220 unsigned Ideal =
static_cast<Node *
>(
Buckets[J])->getFoldingSetHash();
221 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.
This class is used to maintain node state in a folding set.
void ** Buckets
Array of node pointers; a null entry marks an empty slot.
LLVM_ABI FoldingSetBase & operator=(FoldingSetBase &&RHS)
LLVM_ABI ~FoldingSetBase()
LLVM_ABI bool erase(Node *N)
Remove a node from the folding set, returning true if one was removed or false if the node was not in...
unsigned NumBuckets
Length of the Buckets array. Always a power of 2.
unsigned NumNodes
Number of nodes 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 insert(Node *N, FoldingSetInsertToken Token)
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 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...
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
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 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.
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.