10 #ifndef LLVM_ADT_ARRAYREF_H
11 #define LLVM_ADT_ARRAYREF_H
22 #include <initializer_list>
25 #include <type_traits>
51 const T *
Data =
nullptr;
68 :
Data(&OneElt), Length(1) {}
72 :
Data(data), Length(length) {}
76 :
Data(begin), Length(end - begin) {}
83 :
Data(Vec.data()), Length(Vec.size()) {
89 :
Data(Vec.data()), Length(Vec.size()) {}
93 constexpr
ArrayRef(
const std::array<T, N> &Arr)
94 :
Data(Arr.data()), Length(
N) {}
103 Length(Vec.size()) {}
107 template <
typename U>
110 typename std::enable_if<
111 std::is_convertible<U *const *, T const *>::value>::type * =
nullptr)
112 :
Data(A.data()), Length(A.size()) {}
117 template<
typename U,
typename DummyT>
120 typename std::enable_if<
121 std::is_convertible<U *const *, T const *>::value>::type * =
nullptr)
122 :
Data(Vec.data()), Length(Vec.size()) {
127 template<
typename U,
typename A>
129 typename std::enable_if<
130 std::is_convertible<U *const *, T const *>::value>::type* = 0)
131 :
Data(Vec.data()), Length(Vec.size()) {}
144 bool empty()
const {
return Length == 0; }
149 size_t size()
const {
return Length; }
160 return Data[Length-1];
165 T *Buff = A.template Allocate<T>(Length);
166 std::uninitialized_copy(
begin(),
end(), Buff);
172 if (Length != RHS.Length)
180 assert(N+M <= size() &&
"Invalid specifier");
189 assert(size() >=
N &&
"Dropping more elements than exist");
190 return slice(
N, size() -
N);
195 assert(size() >=
N &&
"Dropping more elements than exist");
196 return slice(0, size() -
N);
215 return drop_back(size() -
N);
222 return drop_front(size() -
N);
241 assert(Index < Length &&
"Invalid index!");
249 template <
typename U>
250 typename std::enable_if<std::is_same<U, T>::value,
ArrayRef<T>>::type &
251 operator=(U &&Temporary) =
delete;
257 template <
typename U>
258 typename std::enable_if<std::is_same<U, T>::value,
ArrayRef<T>>::type &
259 operator=(std::initializer_list<U>) =
delete;
264 std::vector<T>
vec()
const {
265 return std::vector<T>(
Data, Data+Length);
271 operator std::vector<T>()
const {
272 return std::vector<T>(
Data, Data+Length);
346 return data()[this->size()-1];
352 assert(N + M <= this->size() &&
"Invalid specifier");
358 return slice(N, this->size() - N);
363 assert(this->size() >=
N &&
"Dropping more elements than exist");
364 return slice(
N, this->size() -
N);
368 assert(this->size() >=
N &&
"Dropping more elements than exist");
369 return slice(0, this->size() -
N);
374 template <
class PredicateT>
381 template <
class PredicateT>
388 if (
N >= this->size())
390 return drop_back(this->size() -
N);
395 if (
N >= this->size())
397 return drop_front(this->size() -
N);
402 template <
class PredicateT>
409 template <
class PredicateT>
418 assert(Index < this->size() &&
"Invalid index!");
419 return data()[Index];
437 delete[] this->
data();
468 template <
typename T>
474 template <
typename T,
unsigned N>
496 template<
typename T,
size_t N>
524 return !(LHS == RHS);
541 #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_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
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.
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
std::reverse_iterator< iterator > reverse_iterator
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)
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< T > drop_back(size_t N=1) const
Drop the last 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.
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 ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const storage::llvm::irsymtab::Symbol * const_iterator
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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
const storage::llvm::irsymtab::Symbol * iterator
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...
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