9#ifndef LLVM_ADT_ARRAYREF_H
10#define LLVM_ADT_ARRAYREF_H
20#include <initializer_list>
57 const T *
Data =
nullptr;
99 constexpr ArrayRef(
const std::array<T, N> &Arr)
107#if LLVM_GNUC_PREREQ(9, 0, 0)
111#pragma GCC diagnostic push
112#pragma GCC diagnostic ignored "-Winit-list-lifetime"
114 constexpr ArrayRef(
const std::initializer_list<T> &Vec)
115 :
Data(Vec.begin() == Vec.end() ? (
T *)nullptr : Vec.begin()),
117#if LLVM_GNUC_PREREQ(9, 0, 0)
118#pragma GCC diagnostic pop
123 template <
typename U>
125 std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
132 template <
typename U,
typename DummyT>
135 std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
141 template <
typename U,
typename A>
143 std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
179 T *Buff =
A.template Allocate<T>(
Length);
180 std::uninitialized_copy(begin(), end(), Buff);
188 return std::equal(begin(), end(),
RHS.begin());
203 assert(
size() >=
N &&
"Dropping more elements than exist");
204 return slice(
N,
size() -
N);
209 assert(
size() >=
N &&
"Dropping more elements than exist");
210 return slice(0,
size() -
N);
229 return drop_back(
size() -
N);
236 return drop_front(
size() -
N);
263 template <
typename U>
264 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
271 template <
typename U>
272 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
278 std::vector<T>
vec()
const {
285 operator std::vector<T>()
const {
369 return data()[this->
size()-1];
375 assert(
N + M <= this->
size() &&
"Invalid specifier");
381 return slice(
N, this->
size() -
N);
386 assert(this->
size() >=
N &&
"Dropping more elements than exist");
387 return slice(
N, this->
size() -
N);
391 assert(this->
size() >=
N &&
"Dropping more elements than exist");
392 return slice(0, this->
size() -
N);
397 template <
class PredicateT>
404 template <
class PredicateT>
411 if (
N >= this->
size())
413 return drop_back(this->
size() -
N);
418 if (
N >= this->
size())
420 return drop_front(this->
size() -
N);
425 template <
class PredicateT>
432 template <
class PredicateT>
441 assert(Index < this->
size() &&
"Invalid index!");
442 return data()[
Index];
454 std::copy(
Data.begin(),
Data.end(), this->begin());
460 delete[] this->
data();
484 template <
typename T,
unsigned N>
491 template <
typename T, std::
size_t N>
508 template <
typename T>
515 template <
typename T>
522 template <
typename T>
529 template <
typename T>
536 template <
typename T,
unsigned N>
543 template <
typename T>
550 template <
typename T, std::
size_t N>
557 template <
typename T>
564 template <
typename T>
571 template <
typename T,
size_t N>
591 template <
class T,
unsigned N>
598 template <
class T, std::
size_t N>
602 template <
typename T,
size_t N>
608 template <
typename T>
615 template <
typename T>
622 template <
typename T>
629 template <
typename T,
unsigned N>
636 template <
typename T>
643 template <
typename T, std::
size_t N>
650 template <
typename T>
657 template <
typename T,
size_t N>
672 template <
typename T>
677 template <
typename T>
682 template <
typename T>
697 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(0)),
size_t(0));
702 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(1)),
size_t(0));
707 "Cannot hash the empty key!");
708 assert(Val.
data() != getTombstoneKey().data() &&
709 "Cannot hash the tombstone key!");
714 if (
RHS.data() == getEmptyKey().data())
715 return LHS.data() == getEmptyKey().data();
716 if (
RHS.data() == getTombstoneKey().data())
717 return LHS.data() == getTombstoneKey().data();
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DEPRECATED(MSG, FIX)
#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),...
constexpr ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
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.
constexpr ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
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.
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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.
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.
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*>.
const T & operator[](size_t Index) const
constexpr ArrayRef(const std::initializer_list< T > &Vec)
Construct an ArrayRef from a std::initializer_list.
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.
constexpr ArrayRef(const T *begin, const T *end)
Construct an ArrayRef from a range.
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)
ArrayRef< T > makeArrayRef(const T &OneElt)
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.
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
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...