|
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"
Classes | |
| struct | FoldingSetInfo |
| Functions provided by the derived class to compute folding properties. More... | |
| class | Node |
| This class is used to maintain node state in a folding set. More... | |
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 | RemoveNode (Node *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. | |
| 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 Node * | FindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info) |
| Look up the node specified by ID. | |
| LLVM_ABI void | InsertNode (Node *N, void *InsertPos) |
| Insert the specified node into the folding set, knowing that it is not already in the folding set. | |
Protected Attributes | |
| void ** | 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 294 of file FoldingSet.h.
|
explicitprotected |
Definition at line 145 of file FoldingSet.cpp.
References assert(), Buckets, NumBuckets, and llvm::safe_calloc().
Referenced by FoldingSetBase(), and operator=().
|
protected |
Definition at line 152 of file FoldingSet.cpp.
References Buckets, FoldingSetBase(), NumBuckets, and NumNodes.
|
protected |
Definition at line 172 of file FoldingSet.cpp.
References Buckets.
| void FoldingSetBase::clear | ( | ) |
Remove all nodes from the folding set.
Definition at line 174 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 334 of file FoldingSet.h.
References NumNodes.
|
protected |
Look up the node specified by ID.
If it exists, return it. If not, return the insertion token that will make insertion faster.
Definition at line 222 of file FoldingSet.cpp.
References Buckets, encodeHash(), I, N, and NumBuckets.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::FindNodeOrInsertPos(), and GetOrInsertNode().
|
protected |
If there is an existing node exactly equal to the node N, return it.
Otherwise, insert N and return it instead.
Definition at line 280 of file FoldingSet.cpp.
References FindNodeOrInsertPos(), InsertNode(), and N.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::GetOrInsertNode().
|
protected |
Insert the specified node into the folding set, knowing that it is not already in the folding set.
InsertPos must be obtained from FindNodeOrInsertPos for an ID that N profiles identically to.
Definition at line 238 of file FoldingSet.cpp.
References assert(), decodeHash(), llvm::DebugEpochBase::incrementEpoch(), LLVM_UNLIKELY, N, NumBuckets, and NumNodes.
Referenced by GetOrInsertNode(), and llvm::FoldingSetImpl< T, Trait >< ListTy >::InsertNode().
|
protected |
Definition at line 159 of file FoldingSet.cpp.
References Buckets, FoldingSetBase(), llvm::DebugEpochBase::incrementEpoch(), NumBuckets, and NumNodes.
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 249 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 >::RemoveNode().
| 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 207 of file FoldingSet.cpp.
References N, and NumBuckets.
|
inline |
Returns the number of nodes in the folding set.
Definition at line 331 of file FoldingSet.h.
References NumNodes.
|
protected |
Array of node pointers; a null entry marks an empty slot.
Definition at line 297 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), clear(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), FindNodeOrInsertPos(), FoldingSetBase(), FoldingSetBase(), operator=(), RemoveNode(), and ~FoldingSetBase().
|
protected |
Length of the Buckets array. Always a power of 2.
Definition at line 300 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), llvm::FoldingSetImpl< T, Trait >< ListTy >::begin(), clear(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), FindNodeOrInsertPos(), FoldingSetBase(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and reserve().
|
protected |
Number of nodes in the folding set.
Definition at line 303 of file FoldingSet.h.
Referenced by clear(), empty(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and size().