16#ifndef LLVM_ADT_FOLDINGSET_H
17#define LLVM_ADT_FOLDINGSET_H
108class FoldingSetNodeID;
142 void *NextInFoldingSetBucket =
nullptr;
265template <
typename T,
typename Enable =
void>
270template<
typename T,
typename Ctx>
294 const unsigned *Data =
nullptr;
311 reinterpret_cast<const uint8_t *
>(Data),
sizeof(
unsigned) * Size)));
322 const unsigned *
getData()
const {
return Data; }
347 static_assert(
sizeof(uintptr_t) <=
sizeof(
unsigned long long),
348 "unexpected pointer size");
355 if (
sizeof(
long) ==
sizeof(
int))
357 else if (
sizeof(
long) ==
sizeof(
long long)) {
373 template <
typename T>
378 inline void clear() { Bits.clear(); }
432template<
typename T,
typename Ctx>
442template<
typename T,
typename Ctx>
501 return static_cast<T *
>(
510 ID, InsertPos, Derived::getFoldingSetInfo()));
525 assert(Inserted ==
N &&
"Node already inserted!");
547 T *TN =
static_cast<T *
>(
N);
556 T *TN =
static_cast<T *
>(
N);
564 T *TN =
static_cast<T *
>(
N);
570 GetNodeProfile, NodeEquals, ComputeNodeHash};
590template <
class T,
class Ctx>
611 T *TN =
static_cast<T *
>(
N);
618 T *TN =
static_cast<T *
>(
N);
625 T *TN =
static_cast<T *
>(
N);
632 GetNodeProfile, NodeEquals, ComputeNodeHash};
649template <
class T,
class VectorT = SmallVector<T*, 8>>
668 void clear() { Set.clear(); Vector.clear(); }
674 return Set.FindNodeOrInsertPos(
ID, InsertPos);
681 T *Result = Set.GetOrInsertNode(
N);
682 if (Result ==
N) Vector.push_back(
N);
690 Set.InsertNode(
N, InsertPos);
702 unsigned size()
const {
return Set.size(); }
705 bool empty()
const {
return Set.empty(); }
763 uintptr_t x =
reinterpret_cast<uintptr_t
>(Probe) & ~0x1;
764 Ptr =
reinterpret_cast<void*
>(x);
805 template <
typename... Ts>
807 : data(
std::forward<Ts>(Args)...) {}
814 operator T&() {
return data; }
815 operator const T&()
const {
return data; }
842template <
typename T1,
typename T2>
844 static inline void Profile(
const std::pair<T1, T2> &
P,
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file contains library features backported from future STL versions.
This file defines the SmallVector class.
static unsigned getSize(unsigned Kind)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Allocate memory in an ever growing pool, as if by bump-pointer.
ContextualFoldingSet - This template class is a further refinement of FoldingSet which provides a con...
ContextualFoldingSet(Ctx Context, unsigned Log2InitSize=6)
FastFoldingSetNode - This is a subclass of FoldingSetNode which stores a FoldingSetNodeID value rathe...
FastFoldingSetNode(const FoldingSetNodeID &ID)
void Profile(FoldingSetNodeID &ID) const
Node - This class is used to maintain the singly linked bucket list in a folding set.
void * getNextInBucket() const
void SetNextInBucket(void *N)
FoldingSetBase - Implements the folding set functionality.
void ** Buckets
Buckets - Array of bucket chains.
unsigned size() const
size - Returns the number of nodes in the folding set.
LLVM_ABI void reserve(unsigned EltCount, const FoldingSetInfo &Info)
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket...
LLVM_ABI bool RemoveNode(Node *N)
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the no...
LLVM_ABI FoldingSetBase & operator=(FoldingSetBase &&RHS)
LLVM_ABI ~FoldingSetBase()
unsigned NumBuckets
NumBuckets - Length of the Buckets array. Always a power of 2.
unsigned NumNodes
NumNodes - Number of nodes in the folding set.
unsigned capacity()
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is pe...
LLVM_ABI Node * GetOrInsertNode(Node *N, const FoldingSetInfo &Info)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node,...
bool empty() const
empty - Returns true if there are no nodes in the folding set.
LLVM_ABI void InsertNode(Node *N, void *InsertPos, const FoldingSetInfo &Info)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
LLVM_ABI void clear()
clear - Remove all nodes from the folding set.
LLVM_ABI Node * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
FindNodeOrInsertPos - Look up the node specified by ID.
FoldingSetBucketIteratorImpl - This is the common bucket iterator support shared by all folding sets,...
FoldingSetBucketIteratorImpl(void **Bucket, bool)
bool operator!=(const FoldingSetBucketIteratorImpl &RHS) const
bool operator==(const FoldingSetBucketIteratorImpl &RHS) const
FoldingSetBucketIterator(void **Bucket, bool)
FoldingSetBucketIterator(void **Bucket)
FoldingSetBucketIterator operator++(int)
FoldingSetBucketIterator & operator++()
FoldingSetImpl - An implementation detail that lets us share code between FoldingSet and ContextualFo...
void reserve(unsigned EltCount)
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket...
FoldingSetIterator< T > iterator
const_iterator end() const
bucket_iterator bucket_begin(unsigned hash)
bool RemoveNode(T *N)
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the no...
~FoldingSetImpl()=default
FoldingSetImpl(FoldingSetImpl &&Arg)=default
FoldingSetBucketIterator< T > bucket_iterator
void InsertNode(T *N)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
const_iterator begin() const
FoldingSetIterator< const T > const_iterator
FoldingSetImpl & operator=(FoldingSetImpl &&RHS)=default
T * GetOrInsertNode(T *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node,...
FoldingSetImpl(unsigned Log2InitSize)
bucket_iterator bucket_end(unsigned hash)
FoldingSetIteratorImpl - This is the common iterator support shared by all folding sets,...
bool operator==(const FoldingSetIteratorImpl &RHS) const
bool operator!=(const FoldingSetIteratorImpl &RHS) const
FoldingSetIterator(void **Bucket)
FoldingSetIterator operator++(int)
FoldingSetIterator & operator++()
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID,...
unsigned computeStableHash() const
FoldingSetNodeIDRef(const unsigned *D, size_t S)
LLVM_ABI bool operator<(FoldingSetNodeIDRef) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
bool operator!=(FoldingSetNodeIDRef RHS) const
unsigned ComputeHash() const
FoldingSetNodeIDRef()=default
const unsigned * getData() const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
LLVM_ABI FoldingSetNodeIDRef Intern(BumpPtrAllocator &Allocator) const
Intern - Copy this node's data to a memory region allocated from the given allocator and return a Fol...
void AddInteger(signed I)
void AddInteger(unsigned long I)
FoldingSetNodeID(FoldingSetNodeIDRef Ref)
unsigned computeStableHash() const
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
bool operator!=(const FoldingSetNodeIDRef RHS) const
void clear()
clear - Clear the accumulated profile, allowing this FoldingSetNodeID object to be used to compute a ...
void AddInteger(unsigned I)
FoldingSetNodeID()=default
bool operator!=(const FoldingSetNodeID &RHS) const
void AddInteger(unsigned long long I)
void AddInteger(long long I)
unsigned ComputeHash() const
LLVM_ABI bool operator<(const FoldingSetNodeID &RHS) const
Used to compare the "ordering" of two nodes as defined by the profiled bits and their ordering define...
LLVM_ABI void AddNodeID(const FoldingSetNodeID &ID)
LLVM_ABI void AddString(StringRef String)
Add* - Add various data types to Bit data.
FoldingSetNodeWrapper - This template class is used to "wrap" arbitrary types in an enclosing object ...
FoldingSetNodeWrapper(Ts &&... Args)
const T & getValue() const
void Profile(FoldingSetNodeID &ID)
FoldingSetVector - This template class combines a FoldingSet and a vector to provide the interface of...
T * GetOrInsertNode(T *N)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node,...
const_iterator end() const
void InsertNode(T *N)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
unsigned size() const
size - Returns the number of nodes in the folding set.
void clear()
clear - Remove all nodes from the folding set.
bool empty() const
empty - Returns true if there are no nodes in the folding set.
FoldingSetVector(unsigned Log2InitSize=6)
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
const_iterator begin() const
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
FoldingSet(FoldingSet &&Arg)=default
FoldingSet(unsigned Log2InitSize=6)
FoldingSet & operator=(FoldingSet &&RHS)=default
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI uint64_t xxh3_64bits(ArrayRef< uint8_t > data)
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
@ Ref
The access may reference the value stored in memory.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Implement std::hash so that hash_code can be used in STL containers.
ContextualFoldingSetTrait - Like FoldingSetTrait, but for ContextualFoldingSets.
DefaultContextualFoldingSetTrait - Like DefaultFoldingSetTrait, but for ContextualFoldingSets.
static bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID, Ctx Context)
static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context)
static unsigned ComputeHash(T &X, FoldingSetNodeID &TempID, Ctx Context)
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
static void Profile(const T &X, FoldingSetNodeID &ID)
static unsigned ComputeHash(T &X, FoldingSetNodeID &TempID)
static bool Equals(T &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
static void Profile(T &X, FoldingSetNodeID &ID)
Functions provided by the derived class to compute folding properties.
unsigned(* ComputeNodeHash)(const FoldingSetBase *Self, Node *N, FoldingSetNodeID &TempID)
ComputeNodeHash - Instantiations of the FoldingSet template implement this function to compute a hash...
bool(* NodeEquals)(const FoldingSetBase *Self, Node *N, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
NodeEquals - Instantiations of the FoldingSet template implement this function to compare the given n...
void(* GetNodeProfile)(const FoldingSetBase *Self, Node *N, FoldingSetNodeID &ID)
GetNodeProfile - Instantiations of the FoldingSet template implement this function to gather data bit...
static void Profile(const T &X, FoldingSetNodeID &ID)
static void Profile(T *X, FoldingSetNodeID &ID)
static void Profile(const std::pair< T1, T2 > &P, FoldingSetNodeID &ID)
FoldingSetTrait - This trait class is used to define behavior of how to "profile" (in the FoldingSet ...
An iterator type that allows iterating over the pointees via some other iterator.