|
LLVM 24.0.0git
|
Non-templated base class for FoldingSet and ContextualFoldingSet, holding the memory management and probing that does not depend on the node type. More...
#include "llvm/ADT/FoldingSet.h"
Public Member Functions | |
| LLVM_ABI void | clear () |
| Remove all nodes from the folding set. | |
| unsigned | size () const |
| Returns the number of nodes in the folding set. | |
| bool | empty () const |
| Returns true if there are no 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. | |
| Public Member Functions inherited from llvm::DebugEpochBase | |
| void | incrementEpoch () |
Protected Member Functions | |
| LLVM_ABI | FoldingSetBase (unsigned Log2InitSize) |
| LLVM_ABI | FoldingSetBase (FoldingSetBase &&Arg) |
| LLVM_ABI FoldingSetBase & | operator= (FoldingSetBase &&RHS) |
| LLVM_ABI | ~FoldingSetBase () |
| 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 the folding set. | |
| template<typename MatchFn> | |
| FoldingSetNode * | probe (uint32_t Hash, FoldingSetInsertToken &Token, MatchFn IsMatch) |
Walk the probe chain for Hash, offering each node whose cached hash matches to IsMatch. | |
| 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. | |
Static Protected Member Functions | |
| static FoldingSetInsertToken | makeInsertToken (uint32_t Hash) |
Wrap Hash, which must not be NotAHash, as the token insert takes. | |
Protected Attributes | |
| FoldingSetNode ** | Buckets = nullptr |
| Array of node pointers; a null entry marks an empty slot. | |
| unsigned | NumBuckets = 0 |
| Length of the Buckets array. Always a power of 2. | |
| unsigned | NumNodes = 0 |
| Number of nodes in the folding set. | |
Non-templated base class for FoldingSet and ContextualFoldingSet, holding the memory management and probing that does not depend on the node type.
Definition at line 371 of file FoldingSet.h.
|
explicitprotected |
Definition at line 114 of file FoldingSet.cpp.
References assert(), Buckets, NumBuckets, and llvm::safe_calloc().
Referenced by FoldingSetBase(), operator=(), and llvm::UniquingSet< T, Info >::UniquingSet().
|
protected |
Definition at line 122 of file FoldingSet.cpp.
References Buckets, FoldingSetBase(), NumBuckets, and NumNodes.
|
protected |
Definition at line 142 of file FoldingSet.cpp.
References Buckets.
| void FoldingSetBase::clear | ( | ) |
Remove all nodes from the folding set.
Definition at line 144 of file FoldingSet.cpp.
References Buckets, llvm::DebugEpochBase::incrementEpoch(), NumBuckets, and NumNodes.
|
inlinenodiscard |
Returns true if there are no nodes in the folding set.
Definition at line 395 of file FoldingSet.h.
References NumNodes.
|
protected |
Remove a node from the folding set, returning true if one was removed or false if the node was not in the folding set.
Definition at line 194 of file FoldingSet.cpp.
References Buckets, I, llvm::DebugEpochBase::incrementEpoch(), LLVM_UNLIKELY, N, llvm::FoldingSetNodeIDRef::NotAHash, NumBuckets, and NumNodes.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::erase(), and llvm::UniquingSet< T, Info >::erase().
|
protected |
Insert the specified node into the folding set, knowing that it is not already in the folding set.
Token must come from lookup for an ID that N profiles identically to.
Definition at line 183 of file FoldingSet.cpp.
References assert(), llvm::DebugEpochBase::incrementEpoch(), LLVM_UNLIKELY, N, NumBuckets, and NumNodes.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::getOrInsert(), llvm::UniquingSet< T, Info >::getOrInsert(), llvm::FoldingSetImpl< T, Trait >< ListTy >::insert(), and llvm::UniquingSet< T, Info >::insert().
|
inlinestaticprotected |
Wrap Hash, which must not be NotAHash, as the token insert takes.
Definition at line 444 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::insert(), and llvm::UniquingSet< T, Info >::insert().
|
protected |
Definition at line 129 of file FoldingSet.cpp.
References Buckets, FoldingSetBase(), llvm::DebugEpochBase::incrementEpoch(), NumBuckets, and NumNodes.
|
inlineprotected |
Walk the probe chain for Hash, offering each node whose cached hash matches to IsMatch.
IsMatch is a template parameter so that it, and the profile it may build, inline into the loop.
Definition at line 422 of file FoldingSet.h.
References assert(), Buckets, I, N, llvm::FoldingSetNodeIDRef::NotAHash, and NumBuckets.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::lookup(), and llvm::UniquingSet< T, Info >::lookup().
| void FoldingSetBase::reserve | ( | unsigned | N | ) |
Grow the number of buckets so that we can hold at least N nodes before rebucketing.
May allocate more space than requested.
Definition at line 176 of file FoldingSet.cpp.
References N, and NumBuckets.
|
inline |
Returns the number of nodes in the folding set.
Definition at line 392 of file FoldingSet.h.
References NumNodes.
|
protected |
Array of node pointers; a null entry marks an empty slot.
Definition at line 374 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::UniquingSet< T, Info >::begin(), llvm::UniquingSet< T, Info >::begin(), clear(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::UniquingSet< T, Info >::end(), llvm::UniquingSet< T, Info >::end(), erase(), FoldingSetBase(), FoldingSetBase(), operator=(), probe(), and ~FoldingSetBase().
|
protected |
Length of the Buckets array. Always a power of 2.
Definition at line 377 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::UniquingSet< T, Info >::begin(), llvm::UniquingSet< T, Info >::begin(), clear(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::UniquingSet< T, Info >::end(), llvm::UniquingSet< T, Info >::end(), erase(), FoldingSetBase(), FoldingSetBase(), insert(), operator=(), probe(), and reserve().
|
protected |
Number of nodes in the folding set.
Definition at line 380 of file FoldingSet.h.
Referenced by clear(), empty(), erase(), FoldingSetBase(), insert(), operator=(), and size().