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){
70 static_assert(std::is_trivially_destructible<T>::value,
71 "T must be trivially destructible!");
97 const std::remove_reference_t<value_type> *
operator->()
const {
134 assert(!
isEmpty() &&
"Cannot get the head of an empty list.");
141 return X ? X->
getTail() :
nullptr;
157 bool ownsAllocator()
const {
158 return (Allocator & 0x1) == 0;
170 : Allocator(reinterpret_cast<uintptr_t>(&
Alloc) | 0x1) {}
173 if (ownsAllocator())
delete &getAllocator();
176 template <
typename ElemT>
182 const ListTy* TailImpl =
Tail.getInternalPointer();
184 ListTy* L = Cache.FindNodeOrInsertPos(
ID, InsertPos);
189 L = (ListTy*)
A.Allocate<ListTy>();
190 new (L) ListTy(std::forward<ElemT>(Head), TailImpl);
193 Cache.InsertNode(L, InsertPos);
199 template <
typename ElemT>
204 template <
typename... CtorArgs>
206 CtorArgs &&...Args) {
207 return concat(
T(std::forward<CtorArgs>(Args)...),
Tail);
214 template <
typename ElemT>
234 uintptr_t PtrVal =
reinterpret_cast<uintptr_t
>(
X.getInternalPointer());
235 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.
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
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
ImmutableList - This class represents an immutable (functional) list.
ImmutableListFactory< T > Factory
bool isEmpty() const
isEmpty - Returns true if the list is empty.
iterator end() const
end - Returns an iterator denoting the end of the list.
const T & getHead() const
getHead - Returns the head of the list.
ImmutableList getTail() const
getTail - 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
begin - Returns an iterator referring to the head of the list, or an iterator denoting the end of the...
bool isEqual(const ImmutableList &L) const
isEqual - 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
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
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...