9#ifndef LLVM_ADT_ARRAYREF_H
10#define LLVM_ADT_ARRAYREF_H
20#include <initializer_list>
57 const T *Data =
nullptr;
74 : Data(&OneElt),
Length(1) {}
79 : Data(data),
Length(length) {}
83 : Data(begin),
Length(end - begin) {
103 : Data(Arr.data()),
Length(
N) {}
111#if LLVM_GNUC_PREREQ(9, 0, 0)
115#pragma GCC diagnostic push
116#pragma GCC diagnostic ignored "-Winit-list-lifetime"
120 : Data(Vec.begin() == Vec.end() ? (
T *)nullptr : Vec.begin()),
122#if LLVM_GNUC_PREREQ(9, 0, 0)
123#pragma GCC diagnostic pop
128 template <
typename U>
130 std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
137 template <
typename U,
typename DummyT>
140 std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
146 template <
typename U,
typename A>
148 std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
165 const T *
data()
const {
return Data; }
184 T *Buff =
A.template Allocate<T>(
Length);
185 std::uninitialized_copy(begin(), end(), Buff);
193 return std::equal(begin(), end(),
RHS.begin());
208 assert(
size() >=
N &&
"Dropping more elements than exist");
209 return slice(
N,
size() -
N);
214 assert(
size() >=
N &&
"Dropping more elements than exist");
215 return slice(0,
size() -
N);
234 return drop_back(
size() -
N);
241 return drop_front(
size() -
N);
268 template <
typename U>
269 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
276 template <
typename U>
277 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
283 std::vector<T>
vec()
const {
284 return std::vector<T>(Data, Data+
Length);
290 operator std::vector<T>()
const {
291 return std::vector<T>(Data, Data+
Length);
374 return data()[this->
size()-1];
380 assert(
N + M <= this->
size() &&
"Invalid specifier");
386 return slice(
N, this->
size() -
N);
391 assert(this->
size() >=
N &&
"Dropping more elements than exist");
392 return slice(
N, this->
size() -
N);
396 assert(this->
size() >=
N &&
"Dropping more elements than exist");
397 return slice(0, this->
size() -
N);
402 template <
class PredicateT>
409 template <
class PredicateT>
416 if (
N >= this->
size())
418 return drop_back(this->
size() -
N);
423 if (
N >= this->
size())
425 return drop_front(this->
size() -
N);
430 template <
class PredicateT>
437 template <
class PredicateT>
446 assert(Index < this->
size() &&
"Invalid index!");
447 return data()[
Index];
459 std::copy(Data.begin(), Data.end(), this->begin());
465 delete[] this->
data();
489 template <
typename T,
unsigned N>
496 template <
typename T, std::
size_t N>
524 template <
class T,
unsigned N>
531 template <
class T, std::
size_t N>
535 template <
typename T,
size_t N>
547 template <
typename T>
552 template <
typename T>
557 template <
typename T>
572 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(0)),
size_t(0));
577 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(1)),
size_t(0));
582 "Cannot hash the empty key!");
583 assert(Val.
data() != getTombstoneKey().data() &&
584 "Cannot hash the tombstone key!");
589 if (
RHS.data() == getEmptyKey().data())
590 return LHS.data() == getEmptyKey().data();
591 if (
RHS.data() == getTombstoneKey().data())
592 return LHS.data() == getTombstoneKey().data();
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_LIFETIME_BOUND
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(std::initializer_list< U >)=delete
Disallow accidental assignment from a temporary.
std::vector< T > vec() const
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
ArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
const T & back() const
back - Get the last element.
ArrayRef(const std::vector< U *, A > &Vec, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from std::vector<T*>.
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
constexpr ArrayRef(std::initializer_list< T > Vec LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a std::initializer_list.
MutableArrayRef< T > copy(Allocator &A)
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
reverse_iterator rend() const
const T & front() const
front - Get the first element.
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a single element.
constexpr ArrayRef(const T *begin LLVM_LIFETIME_BOUND, const T *end)
Construct an ArrayRef from a range.
std::reverse_iterator< const_iterator > const_reverse_iterator
ArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
ArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
size_t size() const
size - Get the array size.
ArrayRef()=default
Construct an empty ArrayRef.
ArrayRef(std::nullopt_t)
Construct an empty ArrayRef from std::nullopt.
ArrayRef(const ArrayRef< U * > &A, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from ArrayRef<T*>.
std::reverse_iterator< iterator > reverse_iterator
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
constexpr ArrayRef(const std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
bool empty() const
empty - Check if the array is empty.
constexpr ArrayRef(const T(&Arr LLVM_LIFETIME_BOUND)[N])
Construct an ArrayRef from a C array.
ArrayRef(const SmallVectorTemplateCommon< U *, DummyT > &Vec, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from a SmallVector<T*>.
constexpr ArrayRef(const T *data LLVM_LIFETIME_BOUND, size_t length)
Construct an ArrayRef from a pointer and length.
const T & operator[](size_t Index) const
ArrayRef(const std::vector< T, A > &Vec)
Construct an ArrayRef from a std::vector.
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(U &&Temporary)=delete
Disallow accidental assignment from a temporary.
reverse_iterator rbegin() const
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
Construct an ArrayRef from a SmallVector.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
MutableArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
MutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
MutableArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
reverse_iterator rbegin() const
MutableArrayRef(T *begin, T *end)
Construct a MutableArrayRef from a range.
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
MutableArrayRef(T *data, size_t length)
Construct a MutableArrayRef from a pointer and length.
MutableArrayRef()=default
Construct an empty MutableArrayRef.
constexpr MutableArrayRef(std::array< T, N > &Arr)
Construct a MutableArrayRef from a std::array.
T & front() const
front - Get the first element.
std::reverse_iterator< const_iterator > const_reverse_iterator
T & operator[](size_t Index) const
T & back() const
back - Get the last element.
MutableArrayRef(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct a MutableArrayRef from a SmallVector.
MutableArrayRef< T > drop_back(size_t N=1) const
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
MutableArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
MutableArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
reverse_iterator rend() const
MutableArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
MutableArrayRef(std::nullopt_t)
Construct an empty MutableArrayRef from std::nullopt.
std::reverse_iterator< iterator > reverse_iterator
This is a MutableArrayRef that owns its array.
OwningArrayRef & operator=(OwningArrayRef &&Other)
OwningArrayRef(OwningArrayRef &&Other)
OwningArrayRef(ArrayRef< T > Data)
OwningArrayRef(size_t Size)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An opaque object representing a hash code.
This is an optimization pass for GlobalISel generic memory operations.
hash_code hash_value(const FixedPointSemantics &Val)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
bool operator!=(uint64_t V1, const APInt &V2)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
auto find_if_not(R &&Range, UnaryPredicate P)
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
static ArrayRef< T > getTombstoneKey()
static unsigned getHashValue(ArrayRef< T > Val)
static ArrayRef< T > getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...