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