9#ifndef LLVM_ADT_ARRAYREF_H
10#define LLVM_ADT_ARRAYREF_H
20#include <initializer_list>
57 const T *Data =
nullptr;
71 : Data(&OneElt), Length(1) {}
76 : Data(
data), Length(length) {}
88 typename = std::enable_if_t<
91 decltype(std::declval<const C &>().data()) *,
93 std::is_integral<
decltype(std::declval<const C &>().
size())>>,
96 : Data(V.
data()), Length(V.
size()) {}
101 : Data(Arr), Length(
N) {}
104#if LLVM_GNUC_PREREQ(9, 0, 0)
108#pragma GCC diagnostic push
109#pragma GCC diagnostic ignored "-Winit-list-lifetime"
114 Length(Vec.
size()) {}
115#if LLVM_GNUC_PREREQ(9, 0, 0)
116#pragma GCC diagnostic pop
122 template <
typename U,
typename = std::enable_if_t<
123 std::is_convertible_v<U *const *, T *const *>>>
138 bool empty()
const {
return Length == 0; }
140 const T *
data()
const {
return Data; }
143 size_t size()
const {
return Length; }
154 return Data[Length-1];
166 const T &Ret =
back();
173 T *Buff =
A.template Allocate<T>(Length);
180 if (Length !=
RHS.Length)
197 assert(
size() >=
N &&
"Dropping more elements than exist");
203 assert(
size() >=
N &&
"Dropping more elements than exist");
249 assert(Index < Length &&
"Invalid index!");
257 template <
typename U>
258 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
265 template <
typename U>
266 std::enable_if_t<std::is_same<U, T>::value,
ArrayRef<T>> &
272 std::vector<T>
vec()
const {
273 return std::vector<T>(Data, Data+Length);
279 operator std::vector<T>()
const {
280 return std::vector<T>(Data, Data+Length);
328 template <
typename C,
329 typename = std::enable_if_t<
332 decltype(std::declval<C &>().data()) *,
T *
const *>,
333 std::is_integral<decltype(std::declval<C &>().size())>>,
378 assert(
N + M <= this->
size() &&
"Invalid specifier");
389 assert(this->
size() >=
N &&
"Dropping more elements than exist");
394 assert(this->
size() >=
N &&
"Dropping more elements than exist");
400 template <
class PredicateT>
407 template <
class PredicateT>
414 if (
N >= this->
size())
421 if (
N >= this->
size())
428 template <
class PredicateT>
435 template <
class PredicateT>
444 assert(Index < this->
size() &&
"Invalid index!");
445 return data()[Index];
457 std::copy(Data.begin(), Data.end(), this->begin());
463 delete[] this->
data();
487 template <
typename T,
unsigned N>
494 template <
typename T, std::
size_t N>
522 template <
class T,
unsigned N>
529 template <
class T, std::
size_t N>
533 template <
typename T,
size_t N>
545 template <
typename T>
551 template <
typename T>
556 template <
typename T>
562 template <
typename T>
564 return std::lexicographical_compare(
LHS.begin(),
LHS.end(),
RHS.begin(),
568 template <
typename T>
573 template <
typename T>
578 template <
typename T>
593 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(0)),
size_t(0));
598 reinterpret_cast<const T *
>(~
static_cast<uintptr_t
>(1)),
size_t(0));
603 "Cannot hash the empty key!");
605 "Cannot hash the tombstone key!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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< 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)
const value_type * const_pointer
ArrayRef< llvm::cfg::Update< MachineBasicBlock * > > drop_front(size_t N=1) const
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
ptrdiff_t difference_type
reverse_iterator rend() const
const_pointer const_iterator
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
const value_type & const_reference
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.
ArrayRef()=default
Construct an empty ArrayRef.
const T & consume_back()
consume_back() - Returns the last element and drops it from ArrayRef.
std::reverse_iterator< iterator > reverse_iterator
ArrayRef< llvm::cfg::Update< MachineBasicBlock * > > drop_back(size_t N=1) const
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 iterator_range< U * > &Range)
Construct an ArrayRef<T> from iterator_range<U*>.
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
const llvm::cfg::Update< MachineBasicBlock * > * data() const
constexpr ArrayRef(const C &V)
Construct an ArrayRef from a type that has a data() method that returns a pointer convertible to cons...
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.
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
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< char > drop_front(size_t N=1) const
T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
const value_type * const_pointer
T & consume_back()
consume_back() - Returns the last element and drops it from ArrayRef.
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.
const_pointer const_iterator
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.
const value_type & const_reference
constexpr MutableArrayRef(const C &V)
Construct a MutableArrayRef from a type that has a data() method that returns a pointer convertible t...
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
MutableArrayRef< char > 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.
ptrdiff_t difference_type
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.
std::reverse_iterator< iterator > reverse_iterator
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 a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An opaque object representing a hash code.
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
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>=(int64_t V1, const APSInt &V2)
auto uninitialized_copy(R &&Src, IterTy Dst)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
bool operator>(int64_t V1, const APSInt &V2)
auto find_if_not(R &&Range, UnaryPredicate P)
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
ArrayRef(const T &OneElt) -> ArrayRef< 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.
bool operator<=(int64_t V1, const APSInt &V2)
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...