LLVM 20.0.0git
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::FoldingSetBase Class Reference

FoldingSetBase - Implements the folding set functionality. More...

#include "llvm/ADT/FoldingSet.h"

Inheritance diagram for llvm::FoldingSetBase:
Inheritance graph
[legend]

Classes

struct  FoldingSetInfo
 Functions provided by the derived class to compute folding properties. More...
 
class  Node
 Node - This class is used to maintain the singly linked bucket list in a folding set. More...
 

Public Member Functions

void clear ()
 clear - Remove all nodes from the folding set.
 
unsigned size () const
 size - Returns the number of nodes in the folding set.
 
bool empty () const
 empty - Returns true if there are no nodes in the folding set.
 
unsigned capacity ()
 capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed.
 

Protected Member Functions

 FoldingSetBase (unsigned Log2InitSize=6)
 
 FoldingSetBase (FoldingSetBase &&Arg)
 
FoldingSetBaseoperator= (FoldingSetBase &&RHS)
 
 ~FoldingSetBase ()
 
void reserve (unsigned EltCount, const FoldingSetInfo &Info)
 reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket operation.
 
bool RemoveNode (Node *N)
 RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the node was not in the folding set.
 
NodeGetOrInsertNode (Node *N, const FoldingSetInfo &Info)
 GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it.
 
NodeFindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
 FindNodeOrInsertPos - Look up the node specified by ID.
 
void InsertNode (Node *N, void *InsertPos, const FoldingSetInfo &Info)
 InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set.
 

Protected Attributes

void ** Buckets
 Buckets - Array of bucket chains.
 
unsigned NumBuckets
 NumBuckets - Length of the Buckets array. Always a power of 2.
 
unsigned NumNodes
 NumNodes - Number of nodes in the folding set.
 

Detailed Description

FoldingSetBase - 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 117 of file FoldingSet.h.

Constructor & Destructor Documentation

◆ FoldingSetBase() [1/2]

FoldingSetBase::FoldingSetBase ( unsigned  Log2InitSize = 6)
explicitprotected

Definition at line 183 of file FoldingSet.cpp.

References AllocateBuckets(), assert(), Buckets, NumBuckets, and NumNodes.

◆ FoldingSetBase() [2/2]

FoldingSetBase::FoldingSetBase ( FoldingSetBase &&  Arg)
protected

Definition at line 191 of file FoldingSet.cpp.

◆ ~FoldingSetBase()

FoldingSetBase::~FoldingSetBase ( )
protected

Definition at line 209 of file FoldingSet.cpp.

References Buckets.

Member Function Documentation

◆ capacity()

unsigned llvm::FoldingSetBase::capacity ( )
inline

capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed.

Definition at line 162 of file FoldingSet.h.

References NumBuckets.

Referenced by InsertNode(), and reserve().

◆ clear()

void FoldingSetBase::clear ( )

clear - Remove all nodes from the folding set.

Definition at line 213 of file FoldingSet.cpp.

References Buckets, NumBuckets, and NumNodes.

◆ empty()

bool llvm::FoldingSetBase::empty ( ) const
inline

empty - Returns true if there are no nodes in the folding set.

Definition at line 158 of file FoldingSet.h.

References NumNodes.

◆ FindNodeOrInsertPos()

FoldingSetBase::Node * FoldingSetBase::FindNodeOrInsertPos ( const FoldingSetNodeID ID,
void *&  InsertPos,
const FoldingSetInfo Info 
)
protected

FindNodeOrInsertPos - 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 278 of file FoldingSet.cpp.

References Buckets, llvm::FoldingSetNodeID::clear(), GetBucketFor(), GetNextPtr(), Info, and NumBuckets.

Referenced by llvm::FoldingSetImpl< Derived, T >::FindNodeOrInsertPos(), and GetOrInsertNode().

◆ GetOrInsertNode()

FoldingSetBase::Node * FoldingSetBase::GetOrInsertNode ( FoldingSetBase::Node N,
const FoldingSetInfo Info 
)
protected

GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it.

Otherwise, insert 'N' and return it instead.

Otherwise, insert 'N' and it instead.

Definition at line 376 of file FoldingSet.cpp.

References FindNodeOrInsertPos(), Info, InsertNode(), and N.

Referenced by llvm::FoldingSetImpl< Derived, T >::GetOrInsertNode().

◆ InsertNode()

void FoldingSetBase::InsertNode ( Node N,
void *  InsertPos,
const FoldingSetInfo Info 
)
protected

InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set.

InsertNode - Insert the specified node into the folding set, knowing that it is not already in the map.

InsertPos must be obtained from FindNodeOrInsertPos.

The insert position is actually a bucket pointer.

Definition at line 303 of file FoldingSet.cpp.

References assert(), Buckets, capacity(), GetBucketFor(), Info, N, NumBuckets, and NumNodes.

Referenced by GetOrInsertNode(), and llvm::FoldingSetImpl< Derived, T >::InsertNode().

◆ operator=()

FoldingSetBase & FoldingSetBase::operator= ( FoldingSetBase &&  RHS)
protected

Definition at line 198 of file FoldingSet.cpp.

References Buckets, NumBuckets, NumNodes, and RHS.

◆ RemoveNode()

bool FoldingSetBase::RemoveNode ( Node N)
protected

RemoveNode - 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 334 of file FoldingSet.cpp.

References GetBucketPtr(), GetNextPtr(), N, NumNodes, and Ptr.

Referenced by llvm::FoldingSetImpl< Derived, T >::RemoveNode().

◆ reserve()

void FoldingSetBase::reserve ( unsigned  EltCount,
const FoldingSetInfo Info 
)
protected

reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket operation.

reserve is permitted to allocate more space than requested by EltCount.

Definition at line 266 of file FoldingSet.cpp.

References llvm::bit_floor(), capacity(), and Info.

Referenced by llvm::FoldingSetImpl< Derived, T >::reserve().

◆ size()

unsigned llvm::FoldingSetBase::size ( ) const
inline

size - Returns the number of nodes in the folding set.

Definition at line 155 of file FoldingSet.h.

References NumNodes.

Member Data Documentation

◆ Buckets

void** llvm::FoldingSetBase::Buckets
protected

◆ NumBuckets

unsigned llvm::FoldingSetBase::NumBuckets
protected

◆ NumNodes

unsigned llvm::FoldingSetBase::NumNodes
protected

NumNodes - Number of nodes in the folding set.

Growth occurs when NumNodes is greater than twice the number of buckets.

Definition at line 127 of file FoldingSet.h.

Referenced by clear(), empty(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and size().


The documentation for this class was generated from the following files: