10 #ifndef LLVM_ADT_ARRAYREF_H
11 #define LLVM_ADT_ARRAYREF_H
60 : Data(&OneElt), Length(1) {}
64 : Data(data), Length(length) {}
68 : Data(begin), Length(end - begin) {}
75 : Data(Vec.data()), Length(Vec.size()) {
81 : Data(Vec.data()), Length(Vec.size()) {}
85 constexpr
ArrayRef(
const std::array<T, N> &Arr)
86 : Data(Arr.data()), Length(
N) {}
90 constexpr
ArrayRef(
const T (&Arr)[
N]) : Data(Arr), Length(N) {}
102 typename std::enable_if<
103 std::is_convertible<U *const *, T const *>::value>::type * =
nullptr)
104 : Data(A.data()), Length(A.size()) {}
109 template<
typename U,
typename DummyT>
112 typename std::enable_if<
113 std::is_convertible<U *const *, T const *>::value>::type * =
nullptr)
114 : Data(Vec.data()), Length(Vec.size()) {
119 template<
typename U,
typename A>
121 typename std::enable_if<
122 std::is_convertible<U *const *, T const *>::value>::type* = 0)
123 : Data(Vec.data()), Length(Vec.size()) {}
136 bool empty()
const {
return Length == 0; }
138 const T *
data()
const {
return Data; }
141 size_t size()
const {
return Length; }
152 return Data[Length-1];
157 T *Buff = A.template Allocate<T>(Length);
158 std::uninitialized_copy(
begin(),
end(), Buff);
164 if (Length != RHS.Length)
172 assert(N+M <= size() &&
"Invalid specifier");
181 assert(size() >=
N &&
"Dropping more elements than exist");
182 return slice(
N, size() -
N);
187 assert(size() >=
N &&
"Dropping more elements than exist");
188 return slice(0, size() -
N);
207 return drop_back(size() -
N);
214 return drop_front(size() -
N);
233 assert(Index < Length &&
"Invalid index!");
241 template <
typename U>
242 typename std::enable_if<std::is_same<U, T>::value,
ArrayRef<T>>::type &
243 operator=(U &&Temporary) =
delete;
249 template <
typename U>
250 typename std::enable_if<std::is_same<U, T>::value,
ArrayRef<T>>::type &
251 operator=(std::initializer_list<U>) =
delete;
256 std::vector<T>
vec()
const {
257 return std::vector<T>(Data, Data+Length);
263 operator std::vector<T>()
const {
264 return std::vector<T>(Data, Data+Length);
339 return data()[this->size()-1];
345 assert(N + M <= this->size() &&
"Invalid specifier");
351 return slice(N, this->size() - N);
356 assert(this->size() >=
N &&
"Dropping more elements than exist");
357 return slice(
N, this->size() -
N);
361 assert(this->size() >=
N &&
"Dropping more elements than exist");
362 return slice(0, this->size() -
N);
367 template <
class PredicateT>
374 template <
class PredicateT>
381 if (
N >= this->size())
383 return drop_back(this->size() -
N);
388 if (
N >= this->size())
390 return drop_front(this->size() -
N);
395 template <
class PredicateT>
402 template <
class PredicateT>
411 assert(Index < this->size() &&
"Invalid index!");
412 return data()[Index];
427 delete[] this->
data();
457 template <
typename T>
463 template <
typename T,
unsigned N>
485 template<
typename T,
size_t N>
501 return !(LHS == RHS);
517 #endif // LLVM_ADT_ARRAYREF_H
const_iterator end(StringRef path)
Get end iterator over path.
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
MutableArrayRef< T > drop_back(size_t N=1) const
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
const T & operator[](size_t Index) const
reverse_iterator rbegin() const
ArrayRef(const ArrayRef< U * > &A, typename std::enable_if< std::is_convertible< U *const *, T const * >::value >::type *=nullptr)
Construct an ArrayRef<const T*> from ArrayRef<T*>.
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having to ...
const T & front() const
front - Get the first element.
constexpr MutableArrayRef(T(&Arr)[N])
Construct an MutableArrayRef from a C array.
const_iterator begin(StringRef path)
Get begin iterator over path.
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
ArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't 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(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
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< U *, DummyT > &Vec, typename std::enable_if< std::is_convertible< U *const *, T const * >::value >::type *=nullptr)
Construct an ArrayRef<const T*> from a SmallVector<T*>.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
ArrayRef(const std::vector< T, A > &Vec)
Construct an ArrayRef from a std::vector.
auto find_if_not(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
ArrayRef(const std::initializer_list< T > &Vec)
Construct an ArrayRef from a std::initializer_list.
ArrayRef< T > copy(Allocator &A)
std::reverse_iterator< iterator > reverse_iterator
reverse_iterator rbegin() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
size_t size() const
size - Get the array size.
OwningArrayRef & operator=(OwningArrayRef &&Other)
reverse_iterator rend() const
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
MutableArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed...
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
Construct an ArrayRef from a SmallVector.
MutableArrayRef(T *begin, T *end)
Construct an MutableArrayRef from a range.
MutableArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate. ...
reverse_iterator rend() const
ArrayRef()
Construct an empty ArrayRef.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
A Counter mapping region associates a source range with a specific counter.
Greedy Register Allocator
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
std::enable_if< std::is_same< U, T >::value, ArrayRef< T > >::type & operator=(U &&Temporary)=delete
Disallow accidental assignment from a temporary.
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
bool empty() const
empty - Check if the array is empty.
MutableArrayRef()
Construct an empty MutableArrayRef.
OwningArrayRef(OwningArrayRef &&Other)
MutableArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
This is a MutableArrayRef that owns its array.
const T & back() const
back - Get the last element.
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MutableArrayRef(T *data, size_t length)
Construct an MutableArrayRef from a pointer and length.
constexpr ArrayRef(const std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
ArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed...
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
MutableArrayRef(T &OneElt)
Construct an MutableArrayRef from a single element.
An opaque object representing a hash code.
ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
bool operator!=(uint64_t V1, const APInt &V2)
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD...
MutableArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
constexpr ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
ArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
OwningArrayRef(ArrayRef< T > Data)
T & front() const
front - Get the first element.
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
OwningArrayRef(size_t Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
constexpr MutableArrayRef(std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
ArrayRef(const T *begin, const T *end)
Construct an ArrayRef from a range.
T & operator[](size_t Index) const
bool operator==(uint64_t V1, const APInt &V2)
MutableArrayRef(NoneType)
Construct an empty MutableArrayRef from None.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct an MutableArrayRef from a SmallVector.
T & back() const
back - Get the last element.
ArrayRef(const std::vector< U *, A > &Vec, typename std::enable_if< std::is_convertible< U *const *, T const * >::value >::type *=0)
Construct an ArrayRef<const T*> from std::vector<T*>.
std::vector< T > vec() const