LLVM 24.0.0git
llvm::UniquingSet< T, Info > Class Template Reference

A uniquing set that compares nodes against a typed key rather than a serialized FoldingSetNodeID. More...

#include "llvm/ADT/FoldingSet.h"

Inheritance diagram for llvm::UniquingSet< T, Info >:
[legend]

Public Types

using KeyTy = typename Info::KeyTy
using iterator = FoldingSetIterator<T>
using const_iterator = FoldingSetIterator<const T>

Public Member Functions

 UniquingSet (unsigned Log2InitSize=6)
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
Tlookup (const KeyTy &Key, FoldingSetInsertToken &Token)
 Look up Key.
void insert (T *N, FoldingSetInsertToken Token)
 Insert N, which must key identically to the lookup that produced Token.
bool erase (T *N)
 Remove N, returning whether it was present.
Public Member Functions inherited from llvm::FoldingSetBase
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 ()

Additional Inherited Members

Protected Member Functions inherited from llvm::FoldingSetBase
LLVM_ABI FoldingSetBase (unsigned Log2InitSize)
LLVM_ABI FoldingSetBase (FoldingSetBase &&Arg)
LLVM_ABI FoldingSetBaseoperator= (FoldingSetBase &&RHS)
LLVM_ABI ~FoldingSetBase ()
LLVM_ABI bool erase (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.
template<typename MatchFn>
Nodeprobe (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 (Node *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 inherited from llvm::FoldingSetBase
static FoldingSetInsertToken makeInsertToken (uint32_t Hash)
 Wrap Hash, which must not be NotAHash, as the token insert takes.
Protected Attributes inherited from llvm::FoldingSetBase
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

template<typename T, typename Info = UniquingSetInfo<T>>
class llvm::UniquingSet< T, Info >

A uniquing set that compares nodes against a typed key rather than a serialized FoldingSetNodeID.

T must derive from FoldingSetNode and provide a getKey() whose result is comparable with == and for which DenseMapInfo<KeyTy>::getHashValue exists. Info overrides that:

using KeyTy = ...;
static KeyTy getKey(const T &N);
static unsigned getHashValue(const KeyTy &K);
#define T
typename Info::KeyTy KeyTy
Definition FoldingSet.h:725
#define N

Derive Info from UniquingSetInfo<T> to override only the hash. The default Info needs T complete wherever UniquingSet<T> is instantiated; FoldingSet does not. A key may alias storage owned by the node; it is only used within a single lookup().

Prefer FoldingSet when a key cannot be read cheaply out of a node: a FoldingSetNodeID cannot disagree with itself, whereas getKey and the code that builds a key to look up must be kept in step by hand.

Definition at line 723 of file FoldingSet.h.

Member Typedef Documentation

◆ const_iterator

template<typename T, typename Info = UniquingSetInfo<T>>
using llvm::UniquingSet< T, Info >::const_iterator = FoldingSetIterator<const T>

Definition at line 736 of file FoldingSet.h.

◆ iterator

template<typename T, typename Info = UniquingSetInfo<T>>
using llvm::UniquingSet< T, Info >::iterator = FoldingSetIterator<T>

Definition at line 730 of file FoldingSet.h.

◆ KeyTy

template<typename T, typename Info = UniquingSetInfo<T>>
using llvm::UniquingSet< T, Info >::KeyTy = typename Info::KeyTy

Definition at line 725 of file FoldingSet.h.

Constructor & Destructor Documentation

◆ UniquingSet()

template<typename T, typename Info = UniquingSetInfo<T>>
llvm::UniquingSet< T, Info >::UniquingSet ( unsigned Log2InitSize = 6)
inlineexplicit

Definition at line 727 of file FoldingSet.h.

References llvm::FoldingSetBase::FoldingSetBase().

Member Function Documentation

◆ begin() [1/2]

template<typename T, typename Info = UniquingSetInfo<T>>
iterator llvm::UniquingSet< T, Info >::begin ( )
inline

◆ begin() [2/2]

template<typename T, typename Info = UniquingSetInfo<T>>
const_iterator llvm::UniquingSet< T, Info >::begin ( ) const
inline

◆ end() [1/2]

template<typename T, typename Info = UniquingSetInfo<T>>
iterator llvm::UniquingSet< T, Info >::end ( )
inline

◆ end() [2/2]

template<typename T, typename Info = UniquingSetInfo<T>>
const_iterator llvm::UniquingSet< T, Info >::end ( ) const
inline

◆ erase()

template<typename T, typename Info = UniquingSetInfo<T>>
bool llvm::UniquingSet< T, Info >::erase ( T * N)
inline

Remove N, returning whether it was present.

Definition at line 762 of file FoldingSet.h.

References llvm::FoldingSetBase::erase(), N, and T.

◆ insert()

template<typename T, typename Info = UniquingSetInfo<T>>
void llvm::UniquingSet< T, Info >::insert ( T * N,
FoldingSetInsertToken Token )
inline

Insert N, which must key identically to the lookup that produced Token.

Definition at line 754 of file FoldingSet.h.

References assert(), llvm::FoldingSetBase::insert(), llvm::FoldingSetBase::makeInsertToken(), N, and T.

Referenced by llvm::BinOpInit::get(), llvm::ListInit::get(), llvm::TernOpInit::get(), and llvm::UnOpInit::get().

◆ lookup()

template<typename T, typename Info = UniquingSetInfo<T>>
T * llvm::UniquingSet< T, Info >::lookup ( const KeyTy & Key,
FoldingSetInsertToken & Token )
inline

Look up Key.

On a hit Token is cleared; on a miss it receives a token for insert().

Definition at line 746 of file FoldingSet.h.

References llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, N, llvm::FoldingSetBase::probe(), and T.

Referenced by llvm::BinOpInit::get(), llvm::ListInit::get(), llvm::TernOpInit::get(), and llvm::UnOpInit::get().


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