14#ifndef LLVM_ADT_IMMUTABLELIST_H
15#define LLVM_ADT_IMMUTABLELIST_H
32 const ImmutableListImpl* Tail;
34 template <
typename ElemT>
35 ImmutableListImpl(ElemT &&head,
const ImmutableListImpl *tail =
nullptr)
36 : Head(std::forward<ElemT>(head)),
Tail(tail) {}
40 ImmutableListImpl &
operator=(
const ImmutableListImpl &) =
delete;
43 const ImmutableListImpl*
getTail()
const {
return Tail; }
46 const ImmutableListImpl* L){
69 static_assert(std::is_trivially_destructible<T>::value,
70 "T must be trivially destructible!");
96 const std::remove_reference_t<value_type> *
operator->()
const {
132 assert(!
isEmpty() &&
"Cannot get the head of an empty list.");
139 return X ? X->
getTail() :
nullptr;
155 bool ownsAllocator()
const {
156 return (Allocator & 0x1) == 0;
168 : Allocator(reinterpret_cast<uintptr_t>(&
Alloc) | 0x1) {}
171 if (ownsAllocator())
delete &getAllocator();
174 template <
typename ElemT>
180 const ListTy* TailImpl =
Tail.getInternalPointer();
182 ListTy* L = Cache.FindNodeOrInsertPos(
ID, InsertPos);
187 L = (ListTy*)
A.Allocate<ListTy>();
188 new (L) ListTy(std::forward<ElemT>(Head), TailImpl);
191 Cache.InsertNode(L, InsertPos);
197 template <
typename ElemT>
202 template <
typename... CtorArgs>
204 CtorArgs &&...Args) {
205 return concat(
T(std::forward<CtorArgs>(Args)...),
Tail);
212 template <
typename ElemT>
232 uintptr_t PtrVal =
reinterpret_cast<uintptr_t
>(
X.getInternalPointer());
233 return (
unsigned((uintptr_t)PtrVal) >> 4) ^
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines a hash set that can be used to remove duplication of nodes in a graph.
This class is used to gather all the unique data bits of a node.
This template class is used to instantiate a specialized implementation of the folding set to the nod...
ImmutableListFactory(BumpPtrAllocator &Alloc)
ImmutableList< T > create(ElemT &&Data)
ImmutableList< T > add(ElemT &&Data, ImmutableList< T > L)
ImmutableList< T > getEmptyList() const
ImmutableList< T > concat(ElemT &&Head, ImmutableList< T > Tail)
ImmutableList< T > emplace(ImmutableList< T > Tail, CtorArgs &&...Args)
static void Profile(FoldingSetNodeID &ID, const T &H, const ImmutableListImpl *L)
ImmutableListImpl & operator=(const ImmutableListImpl &)=delete
const T & getHead() const
ImmutableListImpl(const ImmutableListImpl &)=delete
const ImmutableListImpl * getTail() const
void Profile(FoldingSetNodeID &ID)
bool operator==(const iterator &I) const
const std::remove_reference_t< value_type > * operator->() const
const value_type & operator*() const
iterator(ImmutableList l)
ImmutableList getList() const
bool operator!=(const iterator &I) const
This class represents an immutable (functional) list.
ImmutableListFactory< T > Factory
bool isEmpty() const
Returns true if the list is empty.
iterator end() const
Returns an iterator denoting the end of the list.
const T & getHead() const
Returns the head of the list.
ImmutableList getTail() const
Returns the tail of the list, which is another (possibly empty) ImmutableList.
const ImmutableListImpl< T > * getInternalPointer() const
void Profile(FoldingSetNodeID &ID) const
bool contains(const T &V) const
bool operator==(const ImmutableList &L) const
ImmutableList(const ImmutableListImpl< T > *x=nullptr)
iterator begin() const
Returns an iterator referring to the head of the list, or an iterator denoting the end of the list if...
bool isEqual(const ImmutableList &L) const
Returns true if two lists are equal.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
This is an optimization pass for GlobalISel generic memory operations.
FoldingSetBase::Node FoldingSetNode
FunctionAddr VTableAddr uintptr_t uintptr_t Data
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
static unsigned getHashValue(ImmutableList< T > X)
static bool isEqual(ImmutableList< T > X1, ImmutableList< T > X2)
static ImmutableList< T > getTombstoneKey()
static ImmutableList< T > getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...