9 #ifndef LLVM_ADT_ALLOCATORLIST_H 10 #define LLVM_ADT_ALLOCATORLIST_H 20 #include <type_traits> 36 Node(Node &&) =
delete;
37 Node(
const Node &) =
delete;
41 Node(
T &&V) : V(std::move(V)) {}
42 Node(
const T &V) : V(V) {}
43 template <
class... Ts> Node(Ts &&... Vs) : V(std::forward<Ts>(Vs)...) {}
51 AllocatorT &getAlloc() {
return *
this; }
52 const AllocatorT &getAlloc()
const {
return *
this; }
54 template <
class... ArgTs> Node *create(ArgTs &&...
Args) {
55 return new (getAlloc()) Node(std::forward<ArgTs>(
Args)...);
63 Node *operator()(
const Node &
N)
const {
return AL.create(N.V); }
71 void operator()(Node *
N)
const {
73 AL.getAlloc().Deallocate(N);
87 template <
class ValueT,
class IteratorBase>
91 std::bidirectional_iterator_tag, ValueT> {
92 template <
class OtherValueT,
class OtherIteratorBase>
93 friend class IteratorImpl;
98 std::bidirectional_iterator_tag,
ValueT>;
105 IteratorImpl() =
default;
106 IteratorImpl(
const IteratorImpl &) =
default;
107 IteratorImpl &
operator=(
const IteratorImpl &) =
default;
109 explicit IteratorImpl(
const IteratorBase &
I) : base_type(I) {}
111 template <
class OtherValueT,
class OtherIteratorBase>
112 IteratorImpl(
const IteratorImpl<OtherValueT, OtherIteratorBase> &
X,
113 typename std::enable_if<std::is_convertible<
114 OtherIteratorBase, IteratorBase>::value>::
type * =
nullptr)
115 : base_type(X.wrapped()) {}
117 ~IteratorImpl() =
default;
122 friend bool operator==(
const IteratorImpl &L,
const IteratorImpl &
R) {
123 return L.wrapped() == R.wrapped();
125 friend bool operator!=(
const IteratorImpl &L,
const IteratorImpl &R) {
131 using iterator = IteratorImpl<T, typename list_type::iterator>;
133 IteratorImpl<T, typename list_type::reverse_iterator>;
135 IteratorImpl<const T, typename list_type::const_iterator>;
137 IteratorImpl<const T, typename list_type::const_reverse_iterator>;
141 : AllocatorT(
std::move(
X.getAlloc())), List(
std::move(
X.List)) {}
144 List.
cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
149 List = std::move(
X.List);
150 getAlloc() = std::move(
X.getAlloc());
155 List.
cloneFrom(X.List, Cloner(*
this), Disposer(*
this));
188 return iterator(List.
insert(I.wrapped(), *create(std::forward<Ts>(Vs)...)));
198 template <
class Iterator>
200 for (; First != Last; ++First)
201 List.
insert(I.wrapped(), *create(*First));
210 List.
eraseAndDispose(First.wrapped(), Last.wrapped(), Disposer(*
this)));
231 assert(
empty() &&
"Cannot reset allocator if not empty");
240 #endif // LLVM_ADT_ALLOCATORLIST_H
void cloneFrom(const simple_ilist &L2, Cloner clone, Disposer dispose)
Clone another list.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
AllocatorList & operator=(AllocatorList &&X)
This class represents lattice values for constants.
A linked-list with a custom, local allocator.
void swap(simple_ilist &X)
Swap with another list in place using std::swap.
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.
Node(Kind K_, Cache RHSComponentCache_=Cache::No, Cache ArrayCache_=Cache::No, Cache FunctionCache_=Cache::No)
const_iterator end() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
iterator erase(iterator I)
const_iterator begin() const
void emplace_back(Ts &&... Vs)
APInt operator*(APInt a, uint64_t RHS)
IteratorImpl< Token, typename list_type::reverse_iterator > reverse_iterator
const_reverse_iterator rend() const
AllocatorList & operator=(const AllocatorList &X)
const_reverse_iterator rbegin() const
IteratorImpl< Token, typename list_type::iterator > iterator
CRTP base class for adapting an iterator to a different type.
iterator eraseAndDispose(iterator I, Disposer dispose)
Remove a node by iterator and dispose of it.
LLVM_NODISCARD size_type size() const
Calculate the size of the list in linear time.
ptrdiff_t difference_type
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)
LLVM_NODISCARD bool empty() const
Check if the list is empty in constant time.
void clearAndDispose(Disposer dispose)
Clear the list and dispose of the nodes.
AllocatorList(const AllocatorList &X)
bool operator!=(uint64_t V1, const APInt &V2)
void swap(AllocatorList &RHS)
IteratorImpl< const Token, typename list_type::const_reverse_iterator > const_reverse_iterator
iterator insert(iterator I, reference Node)
Insert a node by reference; never copies.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
iterator emplace(iterator I, Ts &&... Vs)
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
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
reverse_iterator rbegin()
void push_back(const T &V)