10 #ifndef LLVM_ADT_ALLOCATORLIST_H
11 #define LLVM_ADT_ALLOCATORLIST_H
16 #include <type_traits>
31 Node(Node &&) =
delete;
32 Node(
const Node &) =
delete;
36 Node(
T &&V) : V(std::move(V)) {}
37 Node(
const T &V) : V(V) {}
38 template <
class... Ts> Node(Ts &&... Vs) : V(std::forward<Ts>(Vs)...) {}
45 AllocatorT &getAlloc() {
return *
this; }
46 const AllocatorT &getAlloc()
const {
return *
this; }
48 template <
class... ArgTs> Node *create(ArgTs &&...
Args) {
49 return new (getAlloc()) Node(std::forward<ArgTs>(
Args)...);
55 Node *operator()(
const Node &
N)
const {
return AL.create(N.V); }
61 void operator()(Node *
N)
const {
63 AL.getAlloc().Deallocate(N);
77 template <
class ValueT,
class IteratorBase>
81 std::bidirectional_iterator_tag, ValueT> {
82 template <
class OtherValueT,
class OtherIteratorBase>
83 friend class IteratorImpl;
96 IteratorImpl() =
default;
97 IteratorImpl(
const IteratorImpl &) =
default;
98 IteratorImpl &
operator=(
const IteratorImpl &) =
default;
99 ~IteratorImpl() =
default;
101 explicit IteratorImpl(
const IteratorBase &
I) : base_type(I) {}
103 template <
class OtherValueT,
class OtherIteratorBase>
104 IteratorImpl(
const IteratorImpl<OtherValueT, OtherIteratorBase> &
X,
105 typename std::enable_if<std::is_convertible<
106 OtherIteratorBase,
IteratorBase>::value>::type * =
nullptr)
107 : base_type(X.wrapped()) {}
112 friend bool operator==(
const IteratorImpl &
L,
const IteratorImpl &R) {
113 return L.wrapped() == R.wrapped();
115 friend bool operator!=(
const IteratorImpl &L,
const IteratorImpl &R) {
121 typedef IteratorImpl<T, typename list_type::iterator>
iterator;
122 typedef IteratorImpl<T, typename list_type::reverse_iterator>
124 typedef IteratorImpl<const T, typename list_type::const_iterator>
126 typedef IteratorImpl<const T, typename list_type::const_reverse_iterator>
131 : AllocatorT(std::move(
X.getAlloc())),
List(std::move(
X.
List)) {}
133 List.cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
137 List = std::move(
X.List);
138 getAlloc() = std::move(
X.getAlloc());
142 List.cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
174 return iterator(
List.insert(I.wrapped(), *create(std::forward<Ts>(Vs)...)));
178 return iterator(
List.insert(I.wrapped(), *create(std::move(V))));
184 template <
class Iterator>
186 for (; First != Last; ++First)
187 List.insert(I.wrapped(), *create(*First));
191 return iterator(
List.eraseAndDispose(I.wrapped(), Disposer(*
this)));
196 List.eraseAndDispose(First.wrapped(), Last.wrapped(), Disposer(*
this)));
217 assert(
empty() &&
"Cannot reset allocator if not empty");
226 #endif // LLVM_ADT_ALLOCATORLIST_H
AllocatorList & operator=(AllocatorList &&X)
iterator emplace(iterator I, Ts &&...Vs)
A linked-list with a custom, local allocator.
void emplace_front(Ts &&...Vs)
void push_front(const T &V)
list_type::size_type size_type
ptrdiff_t difference_type
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)
IteratorImpl< const T, typename list_type::const_iterator > const_iterator
IteratorImpl< const T, typename list_type::const_reverse_iterator > const_reverse_iterator
AllocatorList & operator=(const AllocatorList &X)
const T & const_reference
const_reverse_iterator rbegin() const
const_iterator end() const
CRTP base class for adapting an iterator to a different type.
const_iterator begin() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
void emplace_back(Ts &&...Vs)
list_type::difference_type difference_type
BlockMass operator*(BlockMass L, BranchProbability R)
IteratorImpl< T, typename list_type::reverse_iterator > reverse_iterator
AllocatorList(AllocatorList &&X)
iterator erase(iterator First, iterator Last)
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< T, typename list_type::iterator > iterator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
reverse_iterator rbegin()
bool operator==(uint64_t V1, const APInt &V2)
void push_back(const T &V)