LLVM 24.0.0git
llvm::FoldingSetBase Class Reference

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"

Inheritance diagram for llvm::FoldingSetBase:
[legend]

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 FoldingSetBaseoperator= (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>
FoldingSetNodeprobe (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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ FoldingSetBase() [1/2]

FoldingSetBase::FoldingSetBase ( unsigned Log2InitSize)
explicitprotected

◆ FoldingSetBase() [2/2]

FoldingSetBase::FoldingSetBase ( FoldingSetBase && Arg)
protected

Definition at line 122 of file FoldingSet.cpp.

References Buckets, FoldingSetBase(), NumBuckets, and NumNodes.

◆ ~FoldingSetBase()

FoldingSetBase::~FoldingSetBase ( )
protected

Definition at line 142 of file FoldingSet.cpp.

References Buckets.

Member Function Documentation

◆ clear()

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.

◆ empty()

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

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

Definition at line 395 of file FoldingSet.h.

References NumNodes.

◆ erase()

bool FoldingSetBase::erase ( FoldingSetNode * N)
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().

◆ insert()

void FoldingSetBase::insert ( FoldingSetNode * N,
FoldingSetInsertToken Token )
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().

◆ makeInsertToken()

FoldingSetInsertToken llvm::FoldingSetBase::makeInsertToken ( uint32_t Hash)
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().

◆ operator=()

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

◆ probe()

template<typename MatchFn>
FoldingSetNode * llvm::FoldingSetBase::probe ( uint32_t Hash,
FoldingSetInsertToken & Token,
MatchFn IsMatch )
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().

◆ reserve()

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.

◆ size()

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

Returns the number of nodes in the folding set.

Definition at line 392 of file FoldingSet.h.

References NumNodes.

Member Data Documentation

◆ Buckets

◆ NumBuckets

◆ NumNodes

unsigned llvm::FoldingSetBase::NumNodes = 0
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().


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