14#ifndef LLVM_ADT_IMMUTABLELIST_H
15#define LLVM_ADT_IMMUTABLELIST_H
34 const ImmutableListImpl* Tail;
36 template <
typename ElemT>
37 ImmutableListImpl(ElemT &&head,
const ImmutableListImpl *tail =
nullptr)
38 : Head(std::forward<ElemT>(head)),
Tail(tail) {}
42 ImmutableListImpl &
operator=(
const ImmutableListImpl &) =
delete;
45 const ImmutableListImpl*
getTail()
const {
return Tail; }
48 const ImmutableListImpl* L){
71 static_assert(std::is_trivially_destructible<T>::value,
72 "T must be trivially destructible!");
109 const std::remove_reference_t<value_type> *
operator->()
const {
110 return &L->getHead();
145 assert(!
isEmpty() &&
"Cannot get the head of an empty list.");
152 return X ? X->
getTail() :
nullptr;
168 bool ownsAllocator()
const {
169 return (Allocator & 0x1) == 0;
181 : Allocator(reinterpret_cast<uintptr_t>(&
Alloc) | 0x1) {}
184 if (ownsAllocator())
delete &getAllocator();
187 template <
typename ElemT>
193 const ListTy* TailImpl =
Tail.getInternalPointer();
195 ListTy* L = Cache.FindNodeOrInsertPos(
ID, InsertPos);
200 L = (ListTy*)
A.Allocate<ListTy>();
201 new (L) ListTy(std::forward<ElemT>(Head), TailImpl);
204 Cache.InsertNode(L, InsertPos);
210 template <
typename ElemT>
215 template <
typename... CtorArgs>
217 CtorArgs &&...Args) {
218 return concat(
T(std::forward<CtorArgs>(Args)...),
Tail);
225 template <
typename ElemT>
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)
std::ptrdiff_t difference_type
bool operator==(const iterator &I) const
std::remove_reference_t< T > value_type
const std::remove_reference_t< value_type > * operator->() const
const value_type & reference
const value_type & operator*() const
iterator(ImmutableList l)
const value_type * pointer
ImmutableList getList() const
bool operator!=(const iterator &I) const
std::forward_iterator_tag iterator_category
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)
An information struct used to provide DenseMap with the various necessary components for a given valu...