|
LLVM 24.0.0git
|
Implements the folding set functionality. 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 the singly linked bucket list 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. | |
| unsigned | capacity () const |
| Returns the number of nodes permitted in the folding set before a rebucket operation is performed. | |
| 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 void | reserve (unsigned EltCount, const FoldingSetInfo &Info) |
Grow the number of buckets so that we can hold at least EltCount nodes before rebucketing. | |
| 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, const FoldingSetInfo &Info) |
| Insert the specified node into the folding set, knowing that it is not already in the folding set. | |
Protected Attributes | |
| void ** | Buckets |
| Array of bucket chains. | |
| unsigned | NumBuckets |
| Length of the Buckets array. Always a power of 2. | |
| unsigned | NumNodes |
| Number of nodes in the folding set. | |
Implements the folding set functionality.
The main structure is an array of buckets. Each bucket is indexed by the hash of the nodes it contains. The bucket itself points to the nodes contained in the bucket via a singly linked list. The last node in the list points back to the bucket to facilitate node removal.
Definition at line 299 of file FoldingSet.h.
|
explicitprotected |
Definition at line 178 of file FoldingSet.cpp.
References AllocateBuckets(), assert(), Buckets, NumBuckets, and NumNodes.
Referenced by FoldingSetBase(), and operator=().
|
protected |
Definition at line 186 of file FoldingSet.cpp.
References Buckets, FoldingSetBase(), NumBuckets, and NumNodes.
|
protected |
Definition at line 207 of file FoldingSet.cpp.
References Buckets.
|
inline |
Returns the number of nodes permitted in the folding set before a rebucket operation is performed.
Definition at line 344 of file FoldingSet.h.
References NumBuckets.
Referenced by InsertNode(), and reserve().
| void FoldingSetBase::clear | ( | ) |
Remove all nodes from the folding set.
Definition at line 209 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 340 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 260 of file FoldingSet.cpp.
References Buckets, llvm::FoldingSetNodeID::clear(), GetBucketFor(), GetNextPtr(), 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 353 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.
The insert position is actually a bucket pointer.
Definition at line 282 of file FoldingSet.cpp.
References assert(), Buckets, capacity(), GetBucketFor(), llvm::DebugEpochBase::incrementEpoch(), N, llvm::Next, NumBuckets, and NumNodes.
Referenced by GetOrInsertNode(), and llvm::FoldingSetImpl< T, Trait >< ListTy >::InsertNode().
|
protected |
Definition at line 194 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 312 of file FoldingSet.cpp.
References GetBucketPtr(), GetNextPtr(), llvm::DebugEpochBase::incrementEpoch(), N, and NumNodes.
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::RemoveNode().
|
protected |
Grow the number of buckets so that we can hold at least EltCount nodes before rebucketing.
May allocate more space than requested.
Definition at line 251 of file FoldingSet.cpp.
References llvm::bit_floor(), and capacity().
Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::reserve().
|
inline |
Returns the number of nodes in the folding set.
Definition at line 337 of file FoldingSet.h.
References NumNodes.
|
protected |
Array of bucket chains.
Definition at line 302 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=(), and ~FoldingSetBase().
|
protected |
Length of the Buckets array. Always a power of 2.
Definition at line 305 of file FoldingSet.h.
Referenced by capacity(), clear(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), llvm::FoldingSetImpl< T, Trait >< ListTy >::end(), FindNodeOrInsertPos(), FoldingSetBase(), FoldingSetBase(), InsertNode(), and operator=().
|
protected |
Number of nodes in the folding set.
Growth occurs when NumNodes is greater than twice the number of buckets.
Definition at line 309 of file FoldingSet.h.
Referenced by clear(), empty(), FoldingSetBase(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and size().