10 #ifndef LLVM_ADT_ALLOCATORLIST_H
11 #define LLVM_ADT_ALLOCATORLIST_H
21 #include <type_traits>
37 Node(Node &&) =
delete;
38 Node(
const Node &) =
delete;
42 Node(
T &&V) : V(std::move(V)) {}
43 Node(
const T &V) : V(V) {}
44 template <
class... Ts> Node(Ts &&... Vs) : V(std::forward<Ts>(Vs)...) {}
52 AllocatorT &getAlloc() {
return *
this; }
53 const AllocatorT &getAlloc()
const {
return *
this; }
55 template <
class... ArgTs> Node *create(ArgTs &&...
Args) {
56 return new (getAlloc()) Node(std::forward<ArgTs>(
Args)...);
64 Node *operator()(
const Node &
N)
const {
return AL.create(N.V); }
72 void operator()(Node *
N)
const {
74 AL.getAlloc().Deallocate(N);
88 template <
class ValueT,
class IteratorBase>
92 std::bidirectional_iterator_tag, ValueT> {
93 template <
class OtherValueT,
class OtherIteratorBase>
94 friend class IteratorImpl;
99 std::bidirectional_iterator_tag,
ValueT>;
106 IteratorImpl() =
default;
107 IteratorImpl(
const IteratorImpl &) =
default;
108 IteratorImpl &
operator=(
const IteratorImpl &) =
default;
110 explicit IteratorImpl(
const IteratorBase &
I) : base_type(I) {}
112 template <
class OtherValueT,
class OtherIteratorBase>
113 IteratorImpl(
const IteratorImpl<OtherValueT, OtherIteratorBase> &
X,
114 typename std::enable_if<std::is_convertible<
115 OtherIteratorBase,
IteratorBase>::value>::type * =
nullptr)
116 : base_type(X.wrapped()) {}
118 ~IteratorImpl() =
default;
123 friend bool operator==(
const IteratorImpl &
L,
const IteratorImpl &R) {
124 return L.wrapped() == R.wrapped();
126 friend bool operator!=(
const IteratorImpl &L,
const IteratorImpl &R) {
132 using iterator = IteratorImpl<T, typename list_type::iterator>;
134 IteratorImpl<T, typename list_type::reverse_iterator>;
136 IteratorImpl<const T, typename list_type::const_iterator>;
138 IteratorImpl<const T, typename list_type::const_reverse_iterator>;
142 : AllocatorT(std::move(
X.getAlloc())),
List(std::move(
X.
List)) {}
145 List.cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
150 List = std::move(
X.List);
151 getAlloc() = std::move(
X.getAlloc());
156 List.cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
189 return iterator(
List.insert(I.wrapped(), *create(std::forward<Ts>(Vs)...)));
193 return iterator(
List.insert(I.wrapped(), *create(std::move(V))));
199 template <
class Iterator>
201 for (; First != Last; ++First)
202 List.insert(I.wrapped(), *create(*First));
206 return iterator(
List.eraseAndDispose(I.wrapped(), Disposer(*
this)));
211 List.eraseAndDispose(First.wrapped(), Last.wrapped(), Disposer(*
this)));
232 assert(
empty() &&
"Cannot reset allocator if not empty");
241 #endif // LLVM_ADT_ALLOCATORLIST_H
AllocatorList & operator=(AllocatorList &&X)
iterator emplace(iterator I, Ts &&...Vs)
A linked-list with a custom, local allocator.
const Token * const_pointer
void emplace_front(Ts &&...Vs)
void push_front(const T &V)
void insert(iterator I, Iterator First, Iterator Last)
void resetAlloc()
Reset the underlying allocator.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
iterator erase(iterator I)
APInt operator*(APInt a, uint64_t RHS)
IteratorImpl< Token, typename list_type::reverse_iterator > reverse_iterator
AllocatorList & operator=(const AllocatorList &X)
const_reverse_iterator rbegin() const
const_iterator end() const
IteratorImpl< Token, typename list_type::iterator > iterator
CRTP base class for adapting an iterator to a different type.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
ptrdiff_t difference_type
const_iterator begin() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
void emplace_back(Ts &&...Vs)
typename list_type::size_type size_type
AllocatorList(AllocatorList &&X)
iterator erase(iterator First, iterator Last)
const Token & const_reference
iterator insert(iterator I, T &&V)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
iterator insert(iterator I, const T &V)
AllocatorList(const AllocatorList &X)
bool operator!=(uint64_t V1, const APInt &V2)
const_reverse_iterator rend() const
const IteratorBase & wrapped() const
void swap(AllocatorList &RHS)
IteratorImpl< const Token, typename list_type::const_reverse_iterator > const_reverse_iterator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
IteratorImpl< const Token, typename list_type::const_iterator > const_iterator
reverse_iterator rbegin()
bool operator==(uint64_t V1, const APInt &V2)
typename list_type::difference_type difference_type
void push_back(const T &V)