LLVM 23.0.0git
ArrayRef.h
Go to the documentation of this file.
1//===- ArrayRef.h - Array Reference Wrapper ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_ADT_ARRAYREF_H
10#define LLVM_ADT_ARRAYREF_H
11
12#include "llvm/ADT/Hashing.h"
13#include "llvm/ADT/STLExtras.h"
16#include "llvm/Support/xxhash.h"
17#include <algorithm>
18#include <array>
19#include <cassert>
20#include <cstddef>
21#include <initializer_list>
22#include <iterator>
23#include <type_traits>
24#include <vector>
25
26namespace llvm {
27template <typename T> class [[nodiscard]] MutableArrayRef;
28
29/// Represent a constant reference to an array (0 or more elements
30/// consecutively in memory), i.e. a start pointer and a length. It allows
31/// various APIs to take consecutive elements easily and conveniently.
32///
33/// This class does not own the underlying data, it is expected to be used in
34/// situations where the data resides in some other buffer, whose lifetime
35/// extends past that of the ArrayRef. For this reason, it is not in general
36/// safe to store an ArrayRef.
37///
38/// This is intended to be trivially copyable, so it should be passed by
39/// value.
40template <typename T> class LLVM_GSL_POINTER [[nodiscard]] ArrayRef {
41public:
42 using value_type = T;
44 using const_pointer = const value_type *;
46 using const_reference = const value_type &;
49 using reverse_iterator = std::reverse_iterator<iterator>;
50 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
51 using size_type = size_t;
53
54private:
55 /// The start of the array, in an external buffer.
56 const T *Data = nullptr;
57
58 /// The number of elements.
59 size_type Length = 0;
60
61public:
62 /// @name Constructors
63 /// @{
64
65 /// Construct an empty ArrayRef.
66 /*implicit*/ ArrayRef() = default;
67
68 /// Construct an ArrayRef from a single element.
69 /*implicit*/ ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)
70 : Data(&OneElt), Length(1) {}
71
72 /// Construct an ArrayRef from a pointer and length.
73 constexpr /*implicit*/ ArrayRef(const T *data LLVM_LIFETIME_BOUND,
74 size_t length)
75 : Data(data), Length(length) {}
76
77 /// Construct an ArrayRef from a range.
78 constexpr ArrayRef(const T *begin LLVM_LIFETIME_BOUND, const T *end)
79 : Data(begin), Length(end - begin) {
80 assert(begin <= end);
81 }
82
83 /// Construct an ArrayRef from a type that has a data() method that returns
84 /// a pointer convertible to const T *.
85 template <
86 typename C,
87 typename = std::enable_if_t<
88 std::conjunction_v<
89 std::is_convertible<decltype(std::declval<const C &>().data()) *,
90 const T *const *>,
91 std::is_integral<decltype(std::declval<const C &>().size())>>,
92 void>>
93 /*implicit*/ constexpr ArrayRef(const C &V)
94 : Data(V.data()), Length(V.size()) {}
95
96 /// Construct an ArrayRef from a C array.
97 template <size_t N>
98 /*implicit*/ constexpr ArrayRef(const T (&Arr LLVM_LIFETIME_BOUND)[N])
99 : Data(Arr), Length(N) {}
100
101 /// Construct an ArrayRef from a std::initializer_list.
102#if LLVM_GNUC_PREREQ(9, 0, 0)
103// Disable gcc's warning in this constructor as it generates an enormous amount
104// of messages. Anyone using ArrayRef should already be aware of the fact that
105// it does not do lifetime extension.
106#pragma GCC diagnostic push
107#pragma GCC diagnostic ignored "-Winit-list-lifetime"
108#endif
109 constexpr /*implicit*/ ArrayRef(
110 std::initializer_list<T> Vec LLVM_LIFETIME_BOUND)
111 : Data(Vec.begin() == Vec.end() ? (T *)nullptr : Vec.begin()),
112 Length(Vec.size()) {}
113#if LLVM_GNUC_PREREQ(9, 0, 0)
114#pragma GCC diagnostic pop
115#endif
116
117 /// Construct an ArrayRef<T> from iterator_range<U*>. This uses SFINAE
118 /// to ensure that this is only used for iterator ranges over plain pointer
119 /// iterators.
120 template <typename U, typename = std::enable_if_t<
121 std::is_convertible_v<U *const *, T *const *>>>
123 : Data(Range.begin()), Length(llvm::size(Range)) {}
124
125 /// @}
126 /// @name Simple Operations
127 /// @{
128
129 iterator begin() const { return Data; }
130 iterator end() const { return Data + Length; }
131
134
135 /// Check if the array is empty.
136 bool empty() const { return Length == 0; }
137
138 const T *data() const { return Data; }
139
140 /// Get the array size.
141 size_t size() const { return Length; }
142
143 /// Get the first element.
144 const T &front() const {
145 assert(!empty());
146 return Data[0];
147 }
148
149 /// Get the last element.
150 const T &back() const {
151 assert(!empty());
152 return Data[Length - 1];
153 }
154
155 /// consume_front() - Returns the first element and drops it from ArrayRef.
156 const T &consume_front() {
157 const T &Ret = front();
158 *this = drop_front();
159 return Ret;
160 }
161
162 /// consume_back() - Returns the last element and drops it from ArrayRef.
163 const T &consume_back() {
164 const T &Ret = back();
165 *this = drop_back();
166 return Ret;
167 }
168
169 // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
170 template <typename Allocator> MutableArrayRef<T> copy(Allocator &A) {
171 T *Buff = A.template Allocate<T>(Length);
172 llvm::uninitialized_copy(*this, Buff);
173 return MutableArrayRef<T>(Buff, Length);
174 }
175
176 /// Check for element-wise equality.
177 bool equals(ArrayRef RHS) const {
178 if (Length != RHS.Length)
179 return false;
180 return std::equal(begin(), end(), RHS.begin());
181 }
182
183 /// slice(n, m) - Chop off the first N elements of the array, and keep M
184 /// elements in the array.
185 ArrayRef<T> slice(size_t N, size_t M) const {
186 assert(N + M <= size() && "Invalid specifier");
187 return ArrayRef<T>(data() + N, M);
188 }
189
190 /// slice(n) - Chop off the first N elements of the array.
191 ArrayRef<T> slice(size_t N) const { return drop_front(N); }
192
193 /// Drop the first \p N elements of the array.
194 ArrayRef<T> drop_front(size_t N = 1) const {
195 assert(size() >= N && "Dropping more elements than exist");
196 return slice(N, size() - N);
197 }
198
199 /// Drop the last \p N elements of the array.
200 ArrayRef<T> drop_back(size_t N = 1) const {
201 assert(size() >= N && "Dropping more elements than exist");
202 return slice(0, size() - N);
203 }
204
205 /// Return a copy of *this with the first N elements satisfying the
206 /// given predicate removed.
207 template <class PredicateT> ArrayRef<T> drop_while(PredicateT Pred) const {
208 return ArrayRef<T>(find_if_not(*this, Pred), end());
209 }
210
211 /// Return a copy of *this with the first N elements not satisfying
212 /// the given predicate removed.
213 template <class PredicateT> ArrayRef<T> drop_until(PredicateT Pred) const {
214 return ArrayRef<T>(find_if(*this, Pred), end());
215 }
216
217 /// Return a copy of *this with only the first \p N elements.
218 ArrayRef<T> take_front(size_t N = 1) const {
219 if (N >= size())
220 return *this;
221 return drop_back(size() - N);
222 }
223
224 /// Return a copy of *this with only the last \p N elements.
225 ArrayRef<T> take_back(size_t N = 1) const {
226 if (N >= size())
227 return *this;
228 return drop_front(size() - N);
229 }
230
231 /// Return the first N elements of this Array that satisfy the given
232 /// predicate.
233 template <class PredicateT> ArrayRef<T> take_while(PredicateT Pred) const {
234 return ArrayRef<T>(begin(), find_if_not(*this, Pred));
235 }
236
237 /// Return the first N elements of this Array that don't satisfy the
238 /// given predicate.
239 template <class PredicateT> ArrayRef<T> take_until(PredicateT Pred) const {
240 return ArrayRef<T>(begin(), find_if(*this, Pred));
241 }
242
243 /// @}
244 /// @name Operator Overloads
245 /// @{
246 const T &operator[](size_t Index) const {
247 assert(Index < Length && "Invalid index!");
248 return Data[Index];
249 }
250
251 /// Disallow accidental assignment from a temporary.
252 ///
253 /// The declaration here is extra complicated so that "arrayRef = {}"
254 /// continues to select the move assignment operator.
255 template <typename U>
256 std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
257 operator=(U &&Temporary) = delete;
258
259 /// Disallow accidental assignment from a temporary.
260 ///
261 /// The declaration here is extra complicated so that "arrayRef = {}"
262 /// continues to select the move assignment operator.
263 template <typename U>
264 std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
265 operator=(std::initializer_list<U>) = delete;
266
267 /// @}
268 /// @name Expensive Operations
269 /// @{
270 std::vector<T> vec() const { return std::vector<T>(Data, Data + Length); }
271
272 /// @}
273 /// @name Conversion operators
274 /// @{
275 operator std::vector<T>() const {
276 return std::vector<T>(Data, Data + Length);
277 }
278
279 /// @}
280};
281
282/// Represent a mutable reference to an array (0 or more elements
283/// consecutively in memory), i.e. a start pointer and a length. It allows
284/// various APIs to take and modify consecutive elements easily and
285/// conveniently.
286///
287/// This class does not own the underlying data, it is expected to be used in
288/// situations where the data resides in some other buffer, whose lifetime
289/// extends past that of the MutableArrayRef. For this reason, it is not in
290/// general safe to store a MutableArrayRef.
291///
292/// This is intended to be trivially copyable, so it should be passed by
293/// value.
294template <typename T> class [[nodiscard]] MutableArrayRef : public ArrayRef<T> {
295public:
296 using value_type = T;
298 using const_pointer = const value_type *;
303 using reverse_iterator = std::reverse_iterator<iterator>;
304 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
305 using size_type = size_t;
307
308 /// Construct an empty MutableArrayRef.
309 /*implicit*/ MutableArrayRef() = default;
310
311 /// Construct a MutableArrayRef from a single element.
312 /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef<T>(OneElt) {}
313
314 /// Construct a MutableArrayRef from a pointer and length.
315 /*implicit*/ MutableArrayRef(T *data, size_t length)
316 : ArrayRef<T>(data, length) {}
317
318 /// Construct a MutableArrayRef from a range.
320
321 /// Construct a MutableArrayRef from a type that has data() and size(),
322 /// where data() returns a pointer convertible to T *const *.
323 template <typename C,
324 typename = std::enable_if_t<
325 std::conjunction_v<
326 std::is_convertible<decltype(std::declval<C &>().data()) *,
327 T *const *>,
328 std::is_integral<decltype(std::declval<C &>().size())>>,
329 void>>
330 /*implicit*/ constexpr MutableArrayRef(C &&V) : ArrayRef<T>(V) {}
331
332 /// Construct a MutableArrayRef from a C array.
333 template <size_t N>
334 /*implicit*/ constexpr MutableArrayRef(T (&Arr)[N]) : ArrayRef<T>(Arr) {}
335
336 T *data() const { return const_cast<T *>(ArrayRef<T>::data()); }
337
338 iterator begin() const { return data(); }
339 iterator end() const { return data() + this->size(); }
340
343
344 /// Get the first element.
345 T &front() const {
346 assert(!this->empty());
347 return data()[0];
348 }
349
350 /// Get the last element.
351 T &back() const {
352 assert(!this->empty());
353 return data()[this->size() - 1];
354 }
355
356 /// Returns the first element and drops it from ArrayRef.
358 T &Ret = front();
359 *this = drop_front();
360 return Ret;
361 }
362
363 /// Returns the last element and drops it from ArrayRef.
365 T &Ret = back();
366 *this = drop_back();
367 return Ret;
368 }
369
370 /// Chop off the first \p N elements of the array, and keep \p M elements
371 /// in the array.
372 MutableArrayRef<T> slice(size_t N, size_t M) const {
373 assert(N + M <= this->size() && "Invalid specifier");
374 return MutableArrayRef<T>(this->data() + N, M);
375 }
376
377 /// Chop off the first \p N elements of the array.
378 MutableArrayRef<T> slice(size_t N) const {
379 return slice(N, this->size() - N);
380 }
381
382 /// Drop the first \p N elements of the array.
383 MutableArrayRef<T> drop_front(size_t N = 1) const {
384 assert(this->size() >= N && "Dropping more elements than exist");
385 return slice(N, this->size() - N);
386 }
387
388 MutableArrayRef<T> drop_back(size_t N = 1) const {
389 assert(this->size() >= N && "Dropping more elements than exist");
390 return slice(0, this->size() - N);
391 }
392
393 /// Return a copy of *this with the first N elements satisfying the
394 /// given predicate removed.
395 template <class PredicateT>
397 return MutableArrayRef<T>(find_if_not(*this, Pred), end());
398 }
399
400 /// Return a copy of *this with the first N elements not satisfying
401 /// the given predicate removed.
402 template <class PredicateT>
404 return MutableArrayRef<T>(find_if(*this, Pred), end());
405 }
406
407 /// Return a copy of *this with only the first \p N elements.
408 MutableArrayRef<T> take_front(size_t N = 1) const {
409 if (N >= this->size())
410 return *this;
411 return drop_back(this->size() - N);
412 }
413
414 /// Return a copy of *this with only the last \p N elements.
415 MutableArrayRef<T> take_back(size_t N = 1) const {
416 if (N >= this->size())
417 return *this;
418 return drop_front(this->size() - N);
419 }
420
421 /// Return the first N elements of this Array that satisfy the given
422 /// predicate.
423 template <class PredicateT>
425 return MutableArrayRef<T>(begin(), find_if_not(*this, Pred));
426 }
427
428 /// Return the first N elements of this Array that don't satisfy the
429 /// given predicate.
430 template <class PredicateT>
432 return MutableArrayRef<T>(begin(), find_if(*this, Pred));
433 }
434
435 /// @}
436 /// @name Operator Overloads
437 /// @{
438 T &operator[](size_t Index) const {
439 assert(Index < this->size() && "Invalid index!");
440 return data()[Index];
441 }
442};
443
444/// @name ArrayRef Deduction guides
445/// @{
446/// Deduction guide to construct an ArrayRef from a single element.
447template <typename T> ArrayRef(const T &OneElt) -> ArrayRef<T>;
448
449/// Deduction guide to construct an ArrayRef from a pointer and length
450template <typename T> ArrayRef(const T *data, size_t length) -> ArrayRef<T>;
451
452/// Deduction guide to construct an ArrayRef from a range
453template <typename T> ArrayRef(const T *data, const T *end) -> ArrayRef<T>;
454
455/// Deduction guide to construct an ArrayRef from a SmallVector
456template <typename T> ArrayRef(const SmallVectorImpl<T> &Vec) -> ArrayRef<T>;
457
458/// Deduction guide to construct an ArrayRef from a SmallVector
459template <typename T, unsigned N>
461
462/// Deduction guide to construct an ArrayRef from a std::vector
463template <typename T> ArrayRef(const std::vector<T> &Vec) -> ArrayRef<T>;
464
465/// Deduction guide to construct an ArrayRef from a std::array
466template <typename T, std::size_t N>
467ArrayRef(const std::array<T, N> &Vec) -> ArrayRef<T>;
468
469/// Deduction guide to construct an ArrayRef from an ArrayRef (const)
470template <typename T> ArrayRef(const ArrayRef<T> &Vec) -> ArrayRef<T>;
471
472/// Deduction guide to construct an ArrayRef from an ArrayRef
473template <typename T> ArrayRef(ArrayRef<T> &Vec) -> ArrayRef<T>;
474
475/// Deduction guide to construct an ArrayRef from a C array.
476template <typename T, size_t N> ArrayRef(const T (&Arr)[N]) -> ArrayRef<T>;
477
478/// @}
479
480/// @name MutableArrayRef Deduction guides
481/// @{
482/// Deduction guide to construct a `MutableArrayRef` from a single element
483template <class T> MutableArrayRef(T &OneElt) -> MutableArrayRef<T>;
484
485/// Deduction guide to construct a `MutableArrayRef` from a pointer and
486/// length.
487template <class T>
489
490/// Deduction guide to construct a `MutableArrayRef` from a `SmallVector`.
491template <class T>
493
494template <class T, unsigned N>
496
497/// Deduction guide to construct a `MutableArrayRef` from a `std::vector`.
498template <class T> MutableArrayRef(std::vector<T> &Vec) -> MutableArrayRef<T>;
499
500/// Deduction guide to construct a `MutableArrayRef` from a `std::array`.
501template <class T, std::size_t N>
502MutableArrayRef(std::array<T, N> &Vec) -> MutableArrayRef<T>;
503
504/// Deduction guide to construct a `MutableArrayRef` from a C array.
505template <typename T, size_t N>
507
508/// @}
509/// @name ArrayRef Comparison Operators
510/// @{
511
512template <typename T> inline bool operator==(ArrayRef<T> LHS, ArrayRef<T> RHS) {
513 return LHS.equals(RHS);
514}
515
516template <typename T>
517[[nodiscard]] inline bool operator==(const SmallVectorImpl<T> &LHS,
519 return ArrayRef<T>(LHS).equals(RHS);
520}
521
522template <typename T> inline bool operator!=(ArrayRef<T> LHS, ArrayRef<T> RHS) {
523 return !(LHS == RHS);
524}
525
526template <typename T>
527[[nodiscard]] inline bool operator!=(const SmallVectorImpl<T> &LHS,
529 return !(LHS == RHS);
530}
531
532template <typename T> inline bool operator<(ArrayRef<T> LHS, ArrayRef<T> RHS) {
533 return std::lexicographical_compare(LHS.begin(), LHS.end(), RHS.begin(),
534 RHS.end());
535}
536
537template <typename T> inline bool operator>(ArrayRef<T> LHS, ArrayRef<T> RHS) {
538 return RHS < LHS;
539}
540
541template <typename T> inline bool operator<=(ArrayRef<T> LHS, ArrayRef<T> RHS) {
542 return !(LHS > RHS);
543}
544
545template <typename T> inline bool operator>=(ArrayRef<T> LHS, ArrayRef<T> RHS) {
546 return !(LHS < RHS);
547}
548
549/// @}
550
551template <typename T> hash_code hash_value(ArrayRef<T> S) {
552 return hash_combine_range(S);
553}
554
555/// Inline ArrayRef overloads of the xxhash entry points declared
556/// out-of-line in llvm/Support/xxhash.h. They live here so xxhash.h can stay
557/// free of ADT dependencies.
559 return xxh3_64bits(data.data(), data.size());
560}
562 return xxh3_128bits(data.data(), data.size());
563}
564
565// Provide DenseMapInfo for ArrayRefs.
566template <typename T> struct DenseMapInfo<ArrayRef<T>, void> {
567 static inline ArrayRef<T> getEmptyKey() {
568 return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)),
569 size_t(0));
570 }
571
572 static inline ArrayRef<T> getTombstoneKey() {
573 return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)),
574 size_t(0));
575 }
576
577 static unsigned getHashValue(ArrayRef<T> Val) {
578 assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
579 assert(Val.data() != getTombstoneKey().data() &&
580 "Cannot hash the tombstone key!");
581 return (unsigned)(hash_value(Val));
582 }
583
585 if (RHS.data() == getEmptyKey().data())
586 return LHS.data() == getEmptyKey().data();
587 if (RHS.data() == getTombstoneKey().data())
588 return LHS.data() == getTombstoneKey().data();
589 return LHS == RHS;
590 }
591};
592
593} // end namespace llvm
594
595#endif // LLVM_ADT_ARRAYREF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_LIFETIME_BOUND
Definition Compiler.h:435
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
Definition Compiler.h:429
#define T
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Basic Register Allocator
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
static Split data
Value * RHS
Value * LHS
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(std::initializer_list< U >)=delete
Disallow accidental assignment from a temporary.
size_t size_type
Definition ArrayRef.h:51
std::vector< T > vec() const
Definition ArrayRef.h:270
bool equals(ArrayRef RHS) const
Check for element-wise equality.
Definition ArrayRef.h:177
ArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
Definition ArrayRef.h:207
const T & back() const
Get the last element.
Definition ArrayRef.h:150
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition ArrayRef.h:218
constexpr ArrayRef(std::initializer_list< T > Vec LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a std::initializer_list.
Definition ArrayRef.h:109
MutableArrayRef< T > copy(Allocator &A)
Definition ArrayRef.h:170
const value_type * const_pointer
Definition ArrayRef.h:44
ArrayRef< llvm::cfg::Update< MachineBasicBlock * > > drop_front(size_t N=1) const
Definition ArrayRef.h:194
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition ArrayRef.h:191
ptrdiff_t difference_type
Definition ArrayRef.h:52
reverse_iterator rend() const
Definition ArrayRef.h:133
const_pointer const_iterator
Definition ArrayRef.h:48
const T & front() const
Get the first element.
Definition ArrayRef.h:144
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition ArrayRef.h:233
ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)
Construct an ArrayRef from a single element.
Definition ArrayRef.h:69
constexpr ArrayRef(const T *begin LLVM_LIFETIME_BOUND, const T *end)
Construct an ArrayRef from a range.
Definition ArrayRef.h:78
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ArrayRef.h:50
const value_type & const_reference
Definition ArrayRef.h:46
value_type * pointer
Definition ArrayRef.h:43
ArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
Definition ArrayRef.h:239
ArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
Definition ArrayRef.h:213
ArrayRef()=default
Construct an empty ArrayRef.
value_type & reference
Definition ArrayRef.h:45
const_pointer iterator
Definition ArrayRef.h:47
const T & consume_back()
consume_back() - Returns the last element and drops it from ArrayRef.
Definition ArrayRef.h:163
std::reverse_iterator< iterator > reverse_iterator
Definition ArrayRef.h:49
ArrayRef< llvm::cfg::Update< MachineBasicBlock * > > drop_back(size_t N=1) const
Definition ArrayRef.h:200
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition ArrayRef.h:225
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
constexpr ArrayRef(const T(&Arr LLVM_LIFETIME_BOUND)[N])
Construct an ArrayRef from a C array.
Definition ArrayRef.h:98
ArrayRef(const iterator_range< U * > &Range)
Construct an ArrayRef<T> from iterator_range<U*>.
Definition ArrayRef.h:122
constexpr ArrayRef(const T *data LLVM_LIFETIME_BOUND, size_t length)
Construct an ArrayRef from a pointer and length.
Definition ArrayRef.h:73
const T & operator[](size_t Index) const
Definition ArrayRef.h:246
const llvm::cfg::Update< MachineBasicBlock * > * data() const
Definition ArrayRef.h:138
constexpr ArrayRef(const C &V)
Construct an ArrayRef from a type that has a data() method that returns a pointer convertible to cons...
Definition ArrayRef.h:93
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
Definition ArrayRef.h:132
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.
Definition ArrayRef.h:185
const T & consume_front()
consume_front() - Returns the first element and drops it from ArrayRef.
Definition ArrayRef.h:156
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
MutableArrayRef< T > take_until(PredicateT Pred) const
Return the first N elements of this Array that don't satisfy the given predicate.
Definition ArrayRef.h:431
MutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition ArrayRef.h:312
MutableArrayRef< char > drop_front(size_t N=1) const
Definition ArrayRef.h:383
T & consume_front()
Returns the first element and drops it from ArrayRef.
Definition ArrayRef.h:357
const value_type * const_pointer
Definition ArrayRef.h:298
T & consume_back()
Returns the last element and drops it from ArrayRef.
Definition ArrayRef.h:364
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition ArrayRef.h:415
constexpr MutableArrayRef(C &&V)
Construct a MutableArrayRef from a type that has data() and size(), where data() returns a pointer co...
Definition ArrayRef.h:330
reverse_iterator rbegin() const
Definition ArrayRef.h:341
value_type & reference
Definition ArrayRef.h:299
MutableArrayRef(T *begin, T *end)
Construct a MutableArrayRef from a range.
Definition ArrayRef.h:319
MutableArrayRef< T > slice(size_t N) const
Chop off the first N elements of the array.
Definition ArrayRef.h:378
MutableArrayRef(T *data, size_t length)
Construct a MutableArrayRef from a pointer and length.
Definition ArrayRef.h:315
MutableArrayRef()=default
Construct an empty MutableArrayRef.
const_pointer const_iterator
Definition ArrayRef.h:302
T & front() const
Get the first element.
Definition ArrayRef.h:345
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition ArrayRef.h:304
value_type * pointer
Definition ArrayRef.h:297
T & operator[](size_t Index) const
Definition ArrayRef.h:438
T & back() const
Get the last element.
Definition ArrayRef.h:351
const value_type & const_reference
Definition ArrayRef.h:300
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
Definition ArrayRef.h:334
MutableArrayRef< char > drop_back(size_t N=1) const
Definition ArrayRef.h:388
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition ArrayRef.h:424
MutableArrayRef< T > slice(size_t N, size_t M) const
Chop off the first N elements of the array, and keep M elements in the array.
Definition ArrayRef.h:372
MutableArrayRef< T > drop_while(PredicateT Pred) const
Return a copy of *this with the first N elements satisfying the given predicate removed.
Definition ArrayRef.h:396
ptrdiff_t difference_type
Definition ArrayRef.h:306
reverse_iterator rend() const
Definition ArrayRef.h:342
MutableArrayRef< T > drop_until(PredicateT Pred) const
Return a copy of *this with the first N elements not satisfying the given predicate removed.
Definition ArrayRef.h:403
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition ArrayRef.h:408
std::reverse_iterator< iterator > reverse_iterator
Definition ArrayRef.h:303
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.
Definition Hashing.h:78
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
Definition APSInt.h:360
hash_code hash_value(const FixedPointSemantics &Val)
uint64_t xxh3_64bits(ArrayRef< uint8_t > data)
Inline ArrayRef overloads of the xxhash entry points declared out-of-line in llvm/Support/xxhash....
Definition ArrayRef.h:558
bool operator!=(uint64_t V1, const APInt &V2)
Definition APInt.h:2142
bool operator>=(int64_t V1, const APSInt &V2)
Definition APSInt.h:359
auto uninitialized_copy(R &&Src, IterTy Dst)
Definition STLExtras.h:2110
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
XXH128_hash_t xxh3_128bits(ArrayRef< uint8_t > data)
Definition ArrayRef.h:561
bool operator>(int64_t V1, const APSInt &V2)
Definition APSInt.h:361
auto find_if_not(R &&Range, UnaryPredicate P)
Definition STLExtras.h:1776
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.
Definition STLExtras.h:1771
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:305
bool operator<=(int64_t V1, const APSInt &V2)
Definition APSInt.h:358
#define N
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
Definition ArrayRef.h:584
static ArrayRef< T > getTombstoneKey()
Definition ArrayRef.h:572
static unsigned getHashValue(ArrayRef< T > Val)
Definition ArrayRef.h:577
An information struct used to provide DenseMap with the various necessary components for a given valu...
The return value from 128-bit hashes.
Definition xxhash.h:58