14 #ifndef LLVM_ADT_IMMUTABLELIST_H 15 #define LLVM_ADT_IMMUTABLELIST_H 34 template <
typename ElemT>
36 : Head(
std::forward<ElemT>(head)), Tail(tail) {}
70 static_assert(std::is_trivially_destructible<T>::value,
71 "T must be trivially destructible!");
97 const typename std::remove_reference<value_type>::type*
operator->()
const {
134 assert(!isEmpty() &&
"Cannot get the head of an empty list.");
141 return X ? X->
getTail() :
nullptr;
149 template <
typename T>
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>
183 ListTy::Profile(ID, Head, TailImpl);
184 ListTy* L = Cache.FindNodeOrInsertPos(ID, InsertPos);
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>
216 return concat(std::forward<ElemT>(
Data), getEmptyList());
236 return (
unsigned((uintptr_t)PtrVal) >> 4) ^
237 (
unsigned((uintptr_t)PtrVal) >> 9);
246 template <
typename T>
251 #endif // LLVM_ADT_IMMUTABLELIST_H detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&... Ranges)
Concatenated range across two or more ranges.
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
const_iterator end(StringRef path)
Get end iterator over path.
void Profile(FoldingSetNodeID &ID)
bool operator==(const ImmutableList &L) const
ImmutableList< T > create(ElemT &&Data)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
LLVM_NODISCARD ImmutableList< T > add(ElemT &&Data, ImmutableList< T > L)
iterator end() const
end - Returns an iterator denoting the end of the list.
This class represents lattice values for constants.
static ImmutableList< T > getEmptyKey()
ImmutableListImpl & operator=(const ImmutableListImpl &)=delete
const T & getHead() const
const ImmutableListImpl * getTail() const
static bool isEqual(ImmutableList< T > X1, ImmutableList< T > X2)
bool operator!=(const iterator &I) const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
LLVM_NODISCARD ImmutableList< T > emplace(ImmutableList< T > Tail, CtorArgs &&...Args)
ImmutableList getList() const
const std::remove_reference< value_type >::type * operator->() const
ImmutableList< T > getEmptyList() const
static ImmutableList< T > getTombstoneKey()
ImmutableList(const ImmutableListImpl< T > *x=nullptr)
static bool isEqual(const Function &Caller, const Function &Callee)
bool isEmpty() const
isEmpty - Returns true if the list is empty.
void Profile(FoldingSetNodeID &ID) const
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
static void Profile(FoldingSetNodeID &ID, const T &H, const ImmutableListImpl *L)
ImmutableList - This class represents an immutable (functional) list.
Allocate memory in an ever growing pool, as if by bump-pointer.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
ImmutableListFactory(BumpPtrAllocator &Alloc)
const T & getHead() const
getHead - Returns the head of the list.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
const value_type & operator*() const
bool operator==(const iterator &I) const
bool isEqual(const ImmutableList &L) const
isEqual - Returns true if two lists are equal.
const ImmutableListImpl< T > * getInternalPointer() const
iterator begin() const
begin - Returns an iterator referring to the head of the list, or an iterator denoting the end of the...
iterator(ImmutableList l)
LLVM_NODISCARD ImmutableList< T > concat(ElemT &&Head, ImmutableList< T > Tail)
static unsigned getHashValue(ImmutableList< T > X)
Node - This class is used to maintain the singly linked bucket list in a folding set.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ImmutableList getTail() const
getTail - Returns the tail of the list, which is another (possibly empty) ImmutableList.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool contains(const T &V) const