14 #ifndef LLVM_ADT_IMMUTABLELIST_H
15 #define LLVM_ADT_IMMUTABLELIST_H
19 #include "llvm/Support/DataTypes.h"
32 : Head(head), Tail(tail) {}
124 assert (!
isEmpty() &&
"Cannot get the head of an empty list.");
131 return X ? X->getTail() : 0;
139 template <
typename T>
140 class ImmutableListFactory {
141 typedef ImmutableListImpl<T> ListTy;
142 typedef FoldingSet<ListTy> CacheTy;
147 bool ownsAllocator()
const {
148 return Allocator & 0x1 ?
false :
true;
160 : Allocator(reinterpret_cast<uintptr_t>(&Alloc) | 0x1) {}
163 if (ownsAllocator())
delete &getAllocator();
179 new (L)
ListTy(Head, TailImpl);
205 template<
typename T>
struct DenseMapInfo;
215 return (
unsigned((uintptr_t)PtrVal) >> 4) ^
216 (
unsigned((uintptr_t)PtrVal) >> 9);
223 template <
typename T>
struct isPodLike;
224 template <
typename T>
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
void Profile(FoldingSetNodeID &ID)
ImmutableListFactory< T > Factory
static ImmutableList< T > getEmptyKey()
ImmutableList getList() const
ImmutableList< T > concat(const T &Head, ImmutableList< T > Tail)
const ImmutableListImpl< T > * getInternalPointer() const
void InsertNode(Node *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
static bool isEqual(ImmutableList< T > X1, ImmutableList< T > X2)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool operator==(const iterator &I) const
ImmutableList< T > add(const T &D, ImmutableList< T > L)
static ImmutableList< T > getTombstoneKey()
bool operator==(const ImmutableList &L) const
const T & getHead() const
ImmutableList getTail()
getTail - Returns the tail of the list, which is another (possibly empty) ImmutableList.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template paramaters.
static void Profile(FoldingSetNodeID &ID, const T &H, const ImmutableListImpl *L)
ImmutableList(const ImmutableListImpl< T > *x=0)
ImmutableList - This class represents an immutable (functional) list.
Allocate memory in an ever growing pool, as if by bump-pointer.
ImmutableList< T > getEmptyList() const
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
const ImmutableListImpl * getTail() const
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
ImmutableListFactory(BumpPtrAllocator &Alloc)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
const value_type & operator*() const
bool isEmpty() const
isEmpty - Returns true if the list is empty.
ImmutableList< T > create(const T &X)
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
iterator end() const
end - Returns an iterator denoting the end of the list.
void Profile(FoldingSetNodeID &ID) const
Node - This class is used to maintain the singly linked bucket list in a folding set.
iterator begin() const
begin - Returns an iterator referring to the head of the list, or an iterator denoting the end of the...
bool contains(const T &V) const
iterator(ImmutableList l)
static unsigned getHashValue(ImmutableList< T > X)
bool isEqual(const ImmutableList &L) const
isEqual - Returns true if two lists are equal.
bool operator!=(const iterator &I) const
const T & getHead()
getHead - Returns the head of the list.