16 #ifndef LLVM_ADT_FOLDINGSET_H
17 #define LLVM_ADT_FOLDINGSET_H
103 class FoldingSetNodeID;
114 virtual void anchor();
142 void *NextInFoldingSetBucket;
145 Node() : NextInFoldingSetBucket(nullptr) {}
179 assert(Inserted == N &&
"Node already inserted!");
191 void reserve(
unsigned EltCount);
203 void GrowHashTable();
208 void GrowBucketCount(
unsigned NewBucketCount);
264 template<
typename T,
typename Ctx>
267 X.Profile(ID, Context);
288 const unsigned *Data =
nullptr;
307 const unsigned *
getData()
const {
return Data; }
325 : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
340 template <
typename T>
391 template<
typename T,
typename Ctx>
401 template<
typename T,
typename Ctx>
424 T *TN =
static_cast<T *
>(
N);
432 T *TN =
static_cast<T *
>(
N);
439 T *TN =
static_cast<T *
>(
N);
449 (void)FoldingSetImpl::operator=(std::move(RHS));
495 template <
class T,
class Ctx>
509 T *TN =
static_cast<T *
>(
N);
515 T *TN =
static_cast<T *
>(
N);
522 T *TN =
static_cast<T *
>(
N);
571 template <
class T,
class VectorT = SmallVector<T*, 8>>
578 : Set(Log2InitSize) {
590 void clear() { Set.clear(); Vector.clear(); }
596 return Set.FindNodeOrInsertPos(ID, InsertPos);
603 T *Result = Set.GetOrInsertNode(N);
604 if (Result == N) Vector.push_back(N);
612 Set.InsertNode(N, InsertPos);
624 unsigned size()
const {
return Set.size(); }
627 bool empty()
const {
return Set.empty(); }
650 template <
class T>
class FoldingSetIterator :
public FoldingSetIteratorImpl {
687 uintptr_t x =
reinterpret_cast<uintptr_t
>(Probe) & ~0x1;
688 Ptr =
reinterpret_cast<void*
>(x);
701 class FoldingSetBucketIterator :
public FoldingSetBucketIteratorImpl {
724 template <
typename T>
729 template <
typename... Ts>
731 : data(std::forward<Ts>(
Args)...) {}
738 operator T&() {
return data; }
739 operator const T&()
const {
return data; }
766 template <
typename T1,
typename T2>
768 static inline void Profile(
const std::pair<T1, T2> &
P,
777 #endif // LLVM_ADT_FOLDINGSET_H
Node * GetOrInsertNode(Node *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node...
FoldingSetVector - This template class combines a FoldingSet and a vector to provide the interface of...
FoldingSetIterator< T > iterator
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
FoldingSetNodeIDRef(const unsigned *D, size_t S)
FoldingSetBucketIterator< T > bucket_iterator
FoldingSetNodeIDRef()=default
ContextualFoldingSet(Ctx Context, unsigned Log2InitSize=6)
FastFoldingSetNode - This is a subclass of FoldingSetNode which stores a FoldingSetNodeID value rathe...
FoldingSetIterator< const T > const_iterator
bucket_iterator bucket_begin(unsigned hash)
FastFoldingSetNode(const FoldingSetNodeID &ID)
void ** Buckets
Buckets - Array of bucket chains.
void InsertNode(Node *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
FoldingSetImpl & operator=(FoldingSetImpl &&RHS)
static void Profile(const T &X, FoldingSetNodeID &ID)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
FoldingSet(unsigned Log2InitSize=6)
void InsertNode(Node *N)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
pointee_iterator< typename VectorT::const_iterator > const_iterator
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, used to lookup the node in th...
static void Profile(T *X, FoldingSetNodeID &ID)
ContextualFoldingSetTrait - Like FoldingSetTrait, but for ContextualFoldingSets.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
static unsigned ComputeHash(T &X, FoldingSetNodeID &TempID)
virtual void GetNodeProfile(Node *N, FoldingSetNodeID &ID) const =0
GetNodeProfile - Instantiations of the FoldingSet template implement this function to gather data bit...
T * GetOrInsertNode(Node *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node...
void AddInteger(signed I)
FoldingSetIteratorImpl - This is the common iterator support shared by all folding sets...
const_iterator end() const
bool operator==(const FoldingSetNodeID &RHS) const
operator== - Used to compare two nodes to each other.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
const_iterator end() const
const_iterator begin() const
FoldingSetNodeID()=default
void Profile(FoldingSetNodeID &ID)
void clear()
clear - Remove all nodes from the folding set.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
virtual unsigned ComputeNodeHash(Node *N, FoldingSetNodeID &TempID) const =0
ComputeNodeHash - Instantiations of the FoldingSet template implement this function to compute a hash...
FoldingSetTrait - This trait class is used to define behavior of how to "profile" (in the FoldingSet ...
void AddNodeID(const FoldingSetNodeID &ID)
const T & getValue() const
Allocate memory in an ever growing pool, as if by bump-pointer.
void * getNextInBucket() const
void Profile(FoldingSetNodeID &ID) const
static unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, Ctx Context)
bool operator<(FoldingSetNodeIDRef) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
FoldingSetBucketIterator operator++(int)
FoldingSetNodeWrapper(Ts &&...Args)
bool empty() const
empty - Returns true if there are no nodes in the folding set.
Greedy Register Allocator
Node * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
FoldingSetImpl - Implements the folding set functionality.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
FoldingSetIterator operator++(int)
unsigned size() const
size - Returns the number of nodes in the folding set.
unsigned NumNodes
NumNodes - Number of nodes in the folding set.
FoldingSetBucketIterator & operator++()
bucket_iterator bucket_end(unsigned hash)
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
FoldingSetImpl(unsigned Log2InitSize=6)
FoldingSetIterator< T > iterator
FoldingSetVector(unsigned Log2InitSize=6)
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
bool RemoveNode(Node *N)
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the no...
static bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
bool operator!=(const FoldingSetNodeID &RHS) const
bool empty() const
empty - Returns true if there are no nodes in the folding set.
FoldingSetNodeWrapper - This template class is used to "wrap" arbitrary types in an enclosing object ...
bool operator<(const FoldingSetNodeID &RHS) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
void InsertNode(T *N)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
unsigned size() const
size - Returns the number of nodes in the folding set.
FoldingSetNodeID(FoldingSetNodeIDRef Ref)
void SetNextInBucket(void *N)
void clear()
clear - Clear the accumulated profile, allowing this FoldingSetNodeID object to be used to compute a ...
FoldingSetBucketIterator(void **Bucket)
bool operator!=(const FoldingSetNodeIDRef RHS) const
FoldingSetBucketIterator(void **Bucket, bool)
FoldingSet & operator=(FoldingSet &&RHS)
An iterator type that allows iterating over the pointees via some other iterator. ...
FoldingSetImpl::Node FoldingSetNode
ContextualFoldingSet - This template class is a further refinement of FoldingSet which provides a con...
T * GetOrInsertNode(Node *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node...
FoldingSetIterator & operator++()
unsigned capacity()
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is pe...
Node - This class is used to maintain the singly linked bucket list in a folding set.
unsigned NumBuckets
NumBuckets - Length of the Buckets array.
static void Profile(T &X, FoldingSetNodeID &ID)
const unsigned * getData() const
T * GetOrInsertNode(T *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node...
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node id data rather than using plain FoldingSetNodeIDs, since the 32-element SmallVector is often much larger than necessary, and the possibility of heap allocation means it requires a non-trivial destructor call.
FoldingSetIteratorImpl(void **Bucket)
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to lookup the node in the F...
const_iterator end() const
bucket_iterator bucket_end(unsigned hash)
void AddString(StringRef String)
bool operator==(const FoldingSetIteratorImpl &RHS) const
pointee_iterator< typename VectorT::iterator > iterator
DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but for ContextualFoldingSets.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const_iterator begin() const
FoldingSetBucketIteratorImpl(void **Bucket)
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
FoldingSetIterator(void **Bucket)
bool operator!=(FoldingSetNodeIDRef RHS) const
void reserve(unsigned EltCount)
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket...
FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
Intern - Copy this node's data to a memory region allocated from the given allocator and return a Fol...
bucket_iterator bucket_begin(unsigned hash)
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 n...
static void Profile(const std::pair< T1, T2 > &P, FoldingSetNodeID &ID)
const_iterator begin() const
StringRef - Represent a constant reference to a string, i.e.
bool operator==(const FoldingSetBucketIteratorImpl &RHS) const
void clear()
clear - Remove all nodes from the folding set.
FoldingSet(FoldingSet &&Arg)
FoldingSetBucketIteratorImpl(void **Bucket, bool)
bool operator!=(const FoldingSetIteratorImpl &RHS) const
FoldingSetBucketIteratorImpl - This is the common bucket iterator support shared by all folding sets...
FoldingSetBucketIterator< T > bucket_iterator
bool operator!=(const FoldingSetBucketIteratorImpl &RHS) const
bool operator==(FoldingSetNodeIDRef) const
FoldingSetIterator< const T > const_iterator
static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context)
static bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID, Ctx Context)