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]

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 FoldingSetBaseoperator= (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 NodeGetOrInsertNode (Node *N, const FoldingSetInfo &Info)
 If there is an existing node exactly equal to the node N, return it.
LLVM_ABI Nodelookup (const FoldingSetNodeID &ID, FoldingSetInsertToken &Token, const FoldingSetInfo &Info)
 Look up the node specified by ID.
LLVM_ABI NodeFindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
LLVM_ABI void insert (Node *N, FoldingSetInsertToken Token)
 Insert the specified node into the folding set, knowing that it is not already in the folding set.
LLVM_ABI void InsertNode (Node *N, void *InsertPos)

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.

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

Constructor & Destructor Documentation

◆ FoldingSetBase() [1/2]

FoldingSetBase::FoldingSetBase ( unsigned Log2InitSize)
explicitprotected

Definition at line 145 of file FoldingSet.cpp.

References assert(), Buckets, NumBuckets, and llvm::safe_calloc().

Referenced by FoldingSetBase(), and operator=().

◆ FoldingSetBase() [2/2]

FoldingSetBase::FoldingSetBase ( FoldingSetBase && Arg)
protected

Definition at line 152 of file FoldingSet.cpp.

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

◆ ~FoldingSetBase()

FoldingSetBase::~FoldingSetBase ( )
protected

Definition at line 172 of file FoldingSet.cpp.

References Buckets.

Member Function Documentation

◆ clear()

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.

◆ empty()

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

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

Definition at line 358 of file FoldingSet.h.

References NumNodes.

◆ FindNodeOrInsertPos()

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

◆ GetOrInsertNode()

FoldingSetBase::Node * FoldingSetBase::GetOrInsertNode ( Node * N,
const FoldingSetInfo & Info )
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 293 of file FoldingSet.cpp.

References insert(), lookup(), and N.

Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::getOrInsert().

◆ insert()

void FoldingSetBase::insert ( Node * 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 247 of file FoldingSet.cpp.

References assert(), llvm::DebugEpochBase::incrementEpoch(), LLVM_UNLIKELY, N, NumBuckets, and NumNodes.

Referenced by GetOrInsertNode(), llvm::FoldingSetImpl< T, Trait >< ListTy >::insert(), and InsertNode().

◆ InsertNode()

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

Definition at line 258 of file FoldingSet.cpp.

References decodeHash(), insert(), and N.

Referenced by llvm::FoldingSetImpl< T, Trait >< ListTy >::InsertNode().

◆ lookup()

FoldingSetBase::Node * FoldingSetBase::lookup ( const FoldingSetNodeID & ID,
FoldingSetInsertToken & Token,
const FoldingSetInfo & Info )
protected

Look up the node specified by ID.

If it exists, return it and clear Token; otherwise return null and set Token for a subsequent insert.

Definition at line 222 of file FoldingSet.cpp.

References Buckets, I, N, and NumBuckets.

Referenced by FindNodeOrInsertPos(), GetOrInsertNode(), and llvm::FoldingSetImpl< T, Trait >< ListTy >::lookup().

◆ operator=()

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

◆ RemoveNode()

bool FoldingSetBase::RemoveNode ( Node * 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 262 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().

◆ 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 207 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 355 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 327 of file FoldingSet.h.

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


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