LLVM  3.7.0
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::FoldingSetImpl Class Referenceabstract

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

#include <FoldingSet.h>

Inheritance diagram for llvm::FoldingSetImpl:
[legend]
Collaboration diagram for llvm::FoldingSetImpl:
[legend]

Classes

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. More...
 
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. More...
 
NodeGetOrInsertNode (Node *N)
 GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it. More...
 
NodeFindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos)
 FindNodeOrInsertPos - Look up the node specified by ID. More...
 
void InsertNode (Node *N, void *InsertPos)
 InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set. More...
 
void InsertNode (Node *N)
 InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set. More...
 
unsigned size () const
 size - Returns the number of nodes in the folding set. More...
 
bool empty () const
 empty - Returns true if there are no nodes in the folding set. More...
 

Protected Member Functions

 ~FoldingSetImpl ()
 
 FoldingSetImpl (unsigned Log2InitSize=6)
 
virtual void GetNodeProfile (Node *N, FoldingSetNodeID &ID) const =0
 GetNodeProfile - Instantiations of the FoldingSet template implement this function to gather data bits for the given node. More...
 
virtual bool NodeEquals (Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID) const =0
 NodeEquals - Instantiations of the FoldingSet template implement this function to compare the given node with the given ID. More...
 
virtual unsigned ComputeNodeHash (Node *N, FoldingSetNodeID &TempID) const =0
 ComputeNodeHash - Instantiations of the FoldingSet template implement this function to compute a hash value for the given node. More...
 

Protected Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

FoldingSetImpl::~FoldingSetImpl ( )
protected

Definition at line 235 of file FoldingSet.cpp.

References Buckets.

FoldingSetImpl::FoldingSetImpl ( unsigned  Log2InitSize = 6)
explicitprotected

Definition at line 228 of file FoldingSet.cpp.

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

Member Function Documentation

void FoldingSetImpl::clear ( )

clear - Remove all nodes from the folding set.

Definition at line 238 of file FoldingSet.cpp.

References Buckets, NumBuckets, and NumNodes.

virtual unsigned llvm::FoldingSetImpl::ComputeNodeHash ( Node N,
FoldingSetNodeID TempID 
) const
protectedpure virtual

ComputeNodeHash - Instantiations of the FoldingSet template implement this function to compute a hash value for the given node.

Referenced by InsertNode().

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

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

Definition at line 182 of file FoldingSet.h.

References NumNodes.

FoldingSetImpl::Node * FoldingSetImpl::FindNodeOrInsertPos ( const FoldingSetNodeID ID,
void *&  InsertPos 
)

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

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

Referenced by llvm::FoldingSet< llvm::DIEAbbrev >::FindNodeOrInsertPos(), llvm::ContextualFoldingSet< T, Ctx >::FindNodeOrInsertPos(), and GetOrInsertNode().

virtual void llvm::FoldingSetImpl::GetNodeProfile ( Node N,
FoldingSetNodeID ID 
) const
protectedpure virtual

GetNodeProfile - Instantiations of the FoldingSet template implement this function to gather data bits for the given node.

Referenced by GetOrInsertNode().

FoldingSetImpl::Node * FoldingSetImpl::GetOrInsertNode ( FoldingSetImpl::Node N)

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

References FindNodeOrInsertPos(), GetNodeProfile(), InsertNode(), llvm::IP, and N.

Referenced by llvm::FoldingSet< llvm::DIEAbbrev >::GetOrInsertNode(), llvm::ContextualFoldingSet< T, Ctx >::GetOrInsertNode(), and InsertNode().

void FoldingSetImpl::InsertNode ( Node N,
void *  InsertPos 
)

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

References Buckets, ComputeNodeHash(), GetBucketFor(), llvm::FoldingSetImpl::Node::getNextInBucket(), N, NumBuckets, NumNodes, and llvm::FoldingSetImpl::Node::SetNextInBucket().

Referenced by llvm::ImmutableListFactory< T >::concat(), llvm::BitsInit::get(), llvm::ListInit::get(), llvm::DagInit::get(), and GetOrInsertNode().

void llvm::FoldingSetImpl::InsertNode ( Node N)
inline

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

Definition at line 172 of file FoldingSet.h.

References GetOrInsertNode().

virtual bool llvm::FoldingSetImpl::NodeEquals ( Node N,
const FoldingSetNodeID ID,
unsigned  IDHash,
FoldingSetNodeID TempID 
) const
protectedpure virtual

NodeEquals - Instantiations of the FoldingSet template implement this function to compare the given node with the given ID.

Referenced by FindNodeOrInsertPos().

bool FoldingSetImpl::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.

Definition at line 339 of file FoldingSet.cpp.

References GetBucketPtr(), llvm::FoldingSetImpl::Node::getNextInBucket(), GetNextPtr(), NumNodes, and llvm::FoldingSetImpl::Node::SetNextInBucket().

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

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

Definition at line 179 of file FoldingSet.h.

References NumNodes.

Member Data Documentation

void** llvm::FoldingSetImpl::Buckets
protected
unsigned llvm::FoldingSetImpl::NumBuckets
protected
unsigned llvm::FoldingSetImpl::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 123 of file FoldingSet.h.

Referenced by clear(), empty(), FoldingSetImpl(), InsertNode(), RemoveNode(), and size().


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