LLVM  15.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/None.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/Support/Compiler.h"
17 #include <algorithm>
18 #include <array>
19 #include <cassert>
20 #include <cstddef>
21 #include <initializer_list>
22 #include <iterator>
23 #include <memory>
24 #include <type_traits>
25 #include <vector>
26 
27 namespace llvm {
28  template<typename T> class LLVM_NODISCARD MutableArrayRef;
29 
30  /// ArrayRef - Represent a constant reference to an array (0 or more elements
31  /// consecutively in memory), i.e. a start pointer and a length. It allows
32  /// various APIs to take consecutive elements easily and conveniently.
33  ///
34  /// This class does not own the underlying data, it is expected to be used in
35  /// situations where the data resides in some other buffer, whose lifetime
36  /// extends past that of the ArrayRef. For this reason, it is not in general
37  /// safe to store an ArrayRef.
38  ///
39  /// This is intended to be trivially copyable, so it should be passed by
40  /// value.
41  template<typename T>
43  public:
44  using value_type = T;
45  using pointer = value_type *;
46  using const_pointer = const value_type *;
47  using reference = value_type &;
48  using const_reference = const value_type &;
51  using reverse_iterator = std::reverse_iterator<iterator>;
52  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
53  using size_type = size_t;
55 
56  private:
57  /// The start of the array, in an external buffer.
58  const T *Data = nullptr;
59 
60  /// The number of elements.
61  size_type Length = 0;
62 
63  public:
64  /// @name Constructors
65  /// @{
66 
67  /// Construct an empty ArrayRef.
68  /*implicit*/ ArrayRef() = default;
69 
70  /// Construct an empty ArrayRef from None.
71  /*implicit*/ ArrayRef(NoneType) {}
72 
73  /// Construct an ArrayRef from a single element.
74  /*implicit*/ ArrayRef(const T &OneElt)
75  : Data(&OneElt), Length(1) {}
76 
77  /// Construct an ArrayRef from a pointer and length.
78  /*implicit*/ ArrayRef(const T *data, size_t length)
79  : Data(data), Length(length) {}
80 
81  /// Construct an ArrayRef from a range.
82  ArrayRef(const T *begin, const T *end)
83  : Data(begin), Length(end - begin) {}
84 
85  /// Construct an ArrayRef from a SmallVector. This is templated in order to
86  /// avoid instantiating SmallVectorTemplateCommon<T> whenever we
87  /// copy-construct an ArrayRef.
88  template<typename U>
89  /*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
90  : Data(Vec.data()), Length(Vec.size()) {
91  }
92 
93  /// Construct an ArrayRef from a std::vector.
94  template<typename A>
95  /*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
96  : Data(Vec.data()), Length(Vec.size()) {}
97 
98  /// Construct an ArrayRef from a std::array
99  template <size_t N>
100  /*implicit*/ constexpr ArrayRef(const std::array<T, N> &Arr)
101  : Data(Arr.data()), Length(N) {}
102 
103  /// Construct an ArrayRef from a C array.
104  template <size_t N>
105  /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
106 
107  /// Construct an ArrayRef from a std::initializer_list.
108 #if LLVM_GNUC_PREREQ(9, 0, 0)
109 // Disable gcc's warning in this constructor as it generates an enormous amount
110 // of messages. Anyone using ArrayRef should already be aware of the fact that
111 // it does not do lifetime extension.
112 #pragma GCC diagnostic push
113 #pragma GCC diagnostic ignored "-Winit-list-lifetime"
114 #endif
115  /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
116  : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
117  Length(Vec.size()) {}
118 #if LLVM_GNUC_PREREQ(9, 0, 0)
119 #pragma GCC diagnostic pop
120 #endif
121 
122  /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
123  /// ensure that only ArrayRefs of pointers can be converted.
124  template <typename U>
126  std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
127  * = nullptr)
128  : Data(A.data()), Length(A.size()) {}
129 
130  /// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
131  /// templated in order to avoid instantiating SmallVectorTemplateCommon<T>
132  /// whenever we copy-construct an ArrayRef.
133  template <typename U, typename DummyT>
134  /*implicit*/ ArrayRef(
136  std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
137  nullptr)
138  : Data(Vec.data()), Length(Vec.size()) {}
139 
140  /// Construct an ArrayRef<const T*> from std::vector<T*>. This uses SFINAE
141  /// to ensure that only vectors of pointers can be converted.
142  template <typename U, typename A>
143  ArrayRef(const std::vector<U *, A> &Vec,
144  std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
145  * = nullptr)
146  : Data(Vec.data()), Length(Vec.size()) {}
147 
148  /// @}
149  /// @name Simple Operations
150  /// @{
151 
152  iterator begin() const { return Data; }
153  iterator end() const { return Data + Length; }
154 
157 
158  /// empty - Check if the array is empty.
159  bool empty() const { return Length == 0; }
160 
161  const T *data() const { return Data; }
162 
163  /// size - Get the array size.
164  size_t size() const { return Length; }
165 
166  /// front - Get the first element.
167  const T &front() const {
168  assert(!empty());
169  return Data[0];
170  }
171 
172  /// back - Get the last element.
173  const T &back() const {
174  assert(!empty());
175  return Data[Length-1];
176  }
177 
178  // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
179  template <typename Allocator> MutableArrayRef<T> copy(Allocator &A) {
180  T *Buff = A.template Allocate<T>(Length);
181  std::uninitialized_copy(begin(), end(), Buff);
182  return MutableArrayRef<T>(Buff, Length);
183  }
184 
185  /// equals - Check for element-wise equality.
186  bool equals(ArrayRef RHS) const {
187  if (Length != RHS.Length)
188  return false;
189  return std::equal(begin(), end(), RHS.begin());
190  }
191 
192  /// slice(n, m) - Chop off the first N elements of the array, and keep M
193  /// elements in the array.
194  ArrayRef<T> slice(size_t N, size_t M) const {
195  assert(N+M <= size() && "Invalid specifier");
196  return ArrayRef<T>(data()+N, M);
197  }
198 
199  /// slice(n) - Chop off the first N elements of the array.
200  ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
201 
202  /// Drop the first \p N elements of the array.
203  ArrayRef<T> drop_front(size_t N = 1) const {
204  assert(size() >= N && "Dropping more elements than exist");
205  return slice(N, size() - N);
206  }
207 
208  /// Drop the last \p N elements of the array.
209  ArrayRef<T> drop_back(size_t N = 1) const {
210  assert(size() >= N && "Dropping more elements than exist");
211  return slice(0, size() - N);
212  }
213 
214  /// Return a copy of *this with the first N elements satisfying the
215  /// given predicate removed.
216  template <class PredicateT> ArrayRef<T> drop_while(PredicateT Pred) const {
217  return ArrayRef<T>(find_if_not(*this, Pred), end());
218  }
219 
220  /// Return a copy of *this with the first N elements not satisfying
221  /// the given predicate removed.
222  template <class PredicateT> ArrayRef<T> drop_until(PredicateT Pred) const {
223  return ArrayRef<T>(find_if(*this, Pred), end());
224  }
225 
226  /// Return a copy of *this with only the first \p N elements.
227  ArrayRef<T> take_front(size_t N = 1) const {
228  if (N >= size())
229  return *this;
230  return drop_back(size() - N);
231  }
232 
233  /// Return a copy of *this with only the last \p N elements.
234  ArrayRef<T> take_back(size_t N = 1) const {
235  if (N >= size())
236  return *this;
237  return drop_front(size() - N);
238  }
239 
240  /// Return the first N elements of this Array that satisfy the given
241  /// predicate.
242  template <class PredicateT> ArrayRef<T> take_while(PredicateT Pred) const {
243  return ArrayRef<T>(begin(), find_if_not(*this, Pred));
244  }
245 
246  /// Return the first N elements of this Array that don't satisfy the
247  /// given predicate.
248  template <class PredicateT> ArrayRef<T> take_until(PredicateT Pred) const {
249  return ArrayRef<T>(begin(), find_if(*this, Pred));
250  }
251 
252  /// @}
253  /// @name Operator Overloads
254  /// @{
255  const T &operator[](size_t Index) const {
256  assert(Index < Length && "Invalid index!");
257  return Data[Index];
258  }
259 
260  /// Disallow accidental assignment from a temporary.
261  ///
262  /// The declaration here is extra complicated so that "arrayRef = {}"
263  /// continues to select the move assignment operator.
264  template <typename U>
265  std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
266  operator=(U &&Temporary) = delete;
267 
268  /// Disallow accidental assignment from a temporary.
269  ///
270  /// The declaration here is extra complicated so that "arrayRef = {}"
271  /// continues to select the move assignment operator.
272  template <typename U>
273  std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
274  operator=(std::initializer_list<U>) = delete;
275 
276  /// @}
277  /// @name Expensive Operations
278  /// @{
279  std::vector<T> vec() const {
280  return std::vector<T>(Data, Data+Length);
281  }
282 
283  /// @}
284  /// @name Conversion operators
285  /// @{
286  operator std::vector<T>() const {
287  return std::vector<T>(Data, Data+Length);
288  }
289 
290  /// @}
291  };
292 
293  /// MutableArrayRef - Represent a mutable reference to an array (0 or more
294  /// elements consecutively in memory), i.e. a start pointer and a length. It
295  /// allows various APIs to take and modify consecutive elements easily and
296  /// conveniently.
297  ///
298  /// This class does not own the underlying data, it is expected to be used in
299  /// situations where the data resides in some other buffer, whose lifetime
300  /// extends past that of the MutableArrayRef. For this reason, it is not in
301  /// general safe to store a MutableArrayRef.
302  ///
303  /// This is intended to be trivially copyable, so it should be passed by
304  /// value.
305  template<typename T>
307  public:
308  using value_type = T;
309  using pointer = value_type *;
310  using const_pointer = const value_type *;
312  using const_reference = const value_type &;
313  using iterator = pointer;
315  using reverse_iterator = std::reverse_iterator<iterator>;
316  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
317  using size_type = size_t;
319 
320  /// Construct an empty MutableArrayRef.
321  /*implicit*/ MutableArrayRef() = default;
322 
323  /// Construct an empty MutableArrayRef from None.
324  /*implicit*/ MutableArrayRef(NoneType) : ArrayRef<T>() {}
325 
326  /// Construct a MutableArrayRef from a single element.
327  /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef<T>(OneElt) {}
328 
329  /// Construct a MutableArrayRef from a pointer and length.
330  /*implicit*/ MutableArrayRef(T *data, size_t length)
331  : ArrayRef<T>(data, length) {}
332 
333  /// Construct a MutableArrayRef from a range.
335 
336  /// Construct a MutableArrayRef from a SmallVector.
338  : ArrayRef<T>(Vec) {}
339 
340  /// Construct a MutableArrayRef from a std::vector.
341  /*implicit*/ MutableArrayRef(std::vector<T> &Vec)
342  : ArrayRef<T>(Vec) {}
343 
344  /// Construct a MutableArrayRef from a std::array
345  template <size_t N>
346  /*implicit*/ constexpr MutableArrayRef(std::array<T, N> &Arr)
347  : ArrayRef<T>(Arr) {}
348 
349  /// Construct a MutableArrayRef from a C array.
350  template <size_t N>
351  /*implicit*/ constexpr MutableArrayRef(T (&Arr)[N]) : ArrayRef<T>(Arr) {}
352 
353  T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
354 
355  iterator begin() const { return data(); }
356  iterator end() const { return data() + this->size(); }
357 
360 
361  /// front - Get the first element.
362  T &front() const {
363  assert(!this->empty());
364  return data()[0];
365  }
366 
367  /// back - Get the last element.
368  T &back() const {
369  assert(!this->empty());
370  return data()[this->size()-1];
371  }
372 
373  /// slice(n, m) - Chop off the first N elements of the array, and keep M
374  /// elements in the array.
375  MutableArrayRef<T> slice(size_t N, size_t M) const {
376  assert(N + M <= this->size() && "Invalid specifier");
377  return MutableArrayRef<T>(this->data() + N, M);
378  }
379 
380  /// slice(n) - Chop off the first N elements of the array.
381  MutableArrayRef<T> slice(size_t N) const {
382  return slice(N, this->size() - N);
383  }
384 
385  /// Drop the first \p N elements of the array.
386  MutableArrayRef<T> drop_front(size_t N = 1) const {
387  assert(this->size() >= N && "Dropping more elements than exist");
388  return slice(N, this->size() - N);
389  }
390 
391  MutableArrayRef<T> drop_back(size_t N = 1) const {
392  assert(this->size() >= N && "Dropping more elements than exist");
393  return slice(0, this->size() - N);
394  }
395 
396  /// Return a copy of *this with the first N elements satisfying the
397  /// given predicate removed.
398  template <class PredicateT>
400  return MutableArrayRef<T>(find_if_not(*this, Pred), end());
401  }
402 
403  /// Return a copy of *this with the first N elements not satisfying
404  /// the given predicate removed.
405  template <class PredicateT>
407  return MutableArrayRef<T>(find_if(*this, Pred), end());
408  }
409 
410  /// Return a copy of *this with only the first \p N elements.
411  MutableArrayRef<T> take_front(size_t N = 1) const {
412  if (N >= this->size())
413  return *this;
414  return drop_back(this->size() - N);
415  }
416 
417  /// Return a copy of *this with only the last \p N elements.
418  MutableArrayRef<T> take_back(size_t N = 1) const {
419  if (N >= this->size())
420  return *this;
421  return drop_front(this->size() - N);
422  }
423 
424  /// Return the first N elements of this Array that satisfy the given
425  /// predicate.
426  template <class PredicateT>
428  return MutableArrayRef<T>(begin(), find_if_not(*this, Pred));
429  }
430 
431  /// Return the first N elements of this Array that don't satisfy the
432  /// given predicate.
433  template <class PredicateT>
435  return MutableArrayRef<T>(begin(), find_if(*this, Pred));
436  }
437 
438  /// @}
439  /// @name Operator Overloads
440  /// @{
441  T &operator[](size_t Index) const {
442  assert(Index < this->size() && "Invalid index!");
443  return data()[Index];
444  }
445  };
446 
447  /// This is a MutableArrayRef that owns its array.
448  template <typename T> class OwningArrayRef : public MutableArrayRef<T> {
449  public:
450  OwningArrayRef() = default;
451  OwningArrayRef(size_t Size) : MutableArrayRef<T>(new T[Size], Size) {}
452 
454  : MutableArrayRef<T>(new T[Data.size()], Data.size()) {
455  std::copy(Data.begin(), Data.end(), this->begin());
456  }
457 
459 
461  delete[] this->data();
463  Other.MutableArrayRef<T>::operator=(MutableArrayRef<T>());
464  return *this;
465  }
466 
467  ~OwningArrayRef() { delete[] this->data(); }
468  };
469 
470  /// @name ArrayRef Convenience constructors
471  /// @{
472 
473  /// Construct an ArrayRef from a single element.
474  template<typename T>
475  ArrayRef<T> makeArrayRef(const T &OneElt) {
476  return OneElt;
477  }
478 
479  /// Construct an ArrayRef from a pointer and length.
480  template<typename T>
481  ArrayRef<T> makeArrayRef(const T *data, size_t length) {
482  return ArrayRef<T>(data, length);
483  }
484 
485  /// Construct an ArrayRef from a range.
486  template<typename T>
487  ArrayRef<T> makeArrayRef(const T *begin, const T *end) {
488  return ArrayRef<T>(begin, end);
489  }
490 
491  /// Construct an ArrayRef from a SmallVector.
492  template <typename T>
494  return Vec;
495  }
496 
497  /// Construct an ArrayRef from a SmallVector.
498  template <typename T, unsigned N>
500  return Vec;
501  }
502 
503  /// Construct an ArrayRef from a std::vector.
504  template<typename T>
505  ArrayRef<T> makeArrayRef(const std::vector<T> &Vec) {
506  return Vec;
507  }
508 
509  /// Construct an ArrayRef from a std::array.
510  template <typename T, std::size_t N>
511  ArrayRef<T> makeArrayRef(const std::array<T, N> &Arr) {
512  return Arr;
513  }
514 
515  /// Construct an ArrayRef from an ArrayRef (no-op) (const)
516  template <typename T> ArrayRef<T> makeArrayRef(const ArrayRef<T> &Vec) {
517  return Vec;
518  }
519 
520  /// Construct an ArrayRef from an ArrayRef (no-op)
521  template <typename T> ArrayRef<T> &makeArrayRef(ArrayRef<T> &Vec) {
522  return Vec;
523  }
524 
525  /// Construct an ArrayRef from a C array.
526  template<typename T, size_t N>
527  ArrayRef<T> makeArrayRef(const T (&Arr)[N]) {
528  return ArrayRef<T>(Arr);
529  }
530 
531  /// Construct a MutableArrayRef from a single element.
532  template<typename T>
534  return OneElt;
535  }
536 
537  /// Construct a MutableArrayRef from a pointer and length.
538  template<typename T>
539  MutableArrayRef<T> makeMutableArrayRef(T *data, size_t length) {
540  return MutableArrayRef<T>(data, length);
541  }
542 
543  /// @}
544  /// @name ArrayRef Comparison Operators
545  /// @{
546 
547  template<typename T>
549  return LHS.equals(RHS);
550  }
551 
552  template <typename T>
554  return ArrayRef<T>(LHS).equals(RHS);
555  }
556 
557  template <typename T>
559  return !(LHS == RHS);
560  }
561 
562  template <typename T>
564  return !(LHS == RHS);
565  }
566 
567  /// @}
568 
569  template <typename T> hash_code hash_value(ArrayRef<T> S) {
570  return hash_combine_range(S.begin(), S.end());
571  }
572 
573  // Provide DenseMapInfo for ArrayRefs.
574  template <typename T> struct DenseMapInfo<ArrayRef<T>, void> {
575  static inline ArrayRef<T> getEmptyKey() {
576  return ArrayRef<T>(
577  reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)), size_t(0));
578  }
579 
580  static inline ArrayRef<T> getTombstoneKey() {
581  return ArrayRef<T>(
582  reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)), size_t(0));
583  }
584 
585  static unsigned getHashValue(ArrayRef<T> Val) {
586  assert(Val.data() != getEmptyKey().data() &&
587  "Cannot hash the empty key!");
588  assert(Val.data() != getTombstoneKey().data() &&
589  "Cannot hash the tombstone key!");
590  return (unsigned)(hash_value(Val));
591  }
592 
594  if (RHS.data() == getEmptyKey().data())
595  return LHS.data() == getEmptyKey().data();
596  if (RHS.data() == getTombstoneKey().data())
597  return LHS.data() == getTombstoneKey().data();
598  return LHS == RHS;
599  }
600  };
601 
602 } // end namespace llvm
603 
604 #endif // LLVM_ADT_ARRAYREF_H
llvm::ArrayRef::drop_back
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:209
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::MutableArrayRef::take_while
MutableArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition: ArrayRef.h:427
llvm::OwningArrayRef
This is a MutableArrayRef that owns its array.
Definition: ArrayRef.h:448
llvm::ArrayRef::ArrayRef
ArrayRef(const SmallVectorTemplateCommon< U *, DummyT > &Vec, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from a SmallVector<T*>.
Definition: ArrayRef.h:134
llvm::ArrayRef::ArrayRef
ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
Definition: ArrayRef.h:78
llvm::coverage::CounterMappingRegion
A Counter mapping region associates a source range with a specific counter.
Definition: CoverageMapping.h:208
pointer
Replace within non kernel function use of LDS with pointer
Definition: AMDGPUReplaceLDSUseWithPointer.cpp:631
llvm::MutableArrayRef::rend
reverse_iterator rend() const
Definition: ArrayRef.h:359
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
llvm::ArrayRef::ArrayRef
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
Construct an ArrayRef from a SmallVector.
Definition: ArrayRef.h:89
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(size_t Size)
Definition: ArrayRef.h:451
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:235
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:226
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:327
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:2004
llvm::DenseMapInfo< ArrayRef< T >, void >::getHashValue
static unsigned getHashValue(ArrayRef< T > Val)
Definition: ArrayRef.h:585
T
#define T
Definition: Mips16ISelLowering.cpp:341
Hashing.h
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(ArrayRef< T > Data)
Definition: ArrayRef.h:453
STLExtras.h
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::MutableArrayRef::take_back
MutableArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition: ArrayRef.h:418
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4821
llvm::ArrayRef::take_while
ArrayRef< T > take_while(PredicateT Pred) const
Return the first N elements of this Array that satisfy the given predicate.
Definition: ArrayRef.h:242
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
size_t
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:161
new
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
Definition: README.txt:125
llvm::MutableArrayRef
class LLVM_NODISCARD MutableArrayRef
Definition: ArrayRef.h:28
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::ArrayRef::ArrayRef
ArrayRef(const T *begin, const T *end)
Construct an ArrayRef from a range.
Definition: ArrayRef.h:82
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::MutableArrayRef::drop_front
MutableArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:386
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:173
llvm::MutableArrayRef::end
iterator end() const
Definition: ArrayRef.h:356
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:306
llvm::MutableArrayRef::drop_while
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:399
ptrdiff_t
llvm::OwningArrayRef::~OwningArrayRef
~OwningArrayRef()
Definition: ArrayRef.h:467
llvm::DenseMapInfo< ArrayRef< T >, void >::getTombstoneKey
static ArrayRef< T > getTombstoneKey()
Definition: ArrayRef.h:580
llvm::DenseMapInfo< ArrayRef< T >, void >::getEmptyKey
static ArrayRef< T > getEmptyKey()
Definition: ArrayRef.h:575
llvm::ArrayRef::operator=
std::enable_if_t< std::is_same< U, T >::value, ArrayRef< T > > & operator=(U &&Temporary)=delete
Disallow accidental assignment from a temporary.
llvm::ArrayRef::operator[]
const T & operator[](size_t Index) const
Definition: ArrayRef.h:255
llvm::ArrayRef::rbegin
reverse_iterator rbegin() const
Definition: ArrayRef.h:155
PredicateT
llvm::ArrayRef::slice
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:194
llvm::DenseMapInfo< ArrayRef< T >, void >::isEqual
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
Definition: ArrayRef.h:593
llvm::ArrayRef::rend
reverse_iterator rend() const
Definition: ArrayRef.h:156
llvm::ArrayRef::take_back
ArrayRef< T > take_back(size_t N=1) const
Return a copy of *this with only the last N elements.
Definition: ArrayRef.h:234
llvm::MutableArrayRef::slice
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:375
llvm::SmallVectorTemplateCommon
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD.
Definition: SmallVector.h:102
llvm::ArrayRef::ArrayRef
constexpr ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
Definition: ArrayRef.h:105
llvm::ArrayRef::drop_front
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:203
uint64_t
llvm::NoneType
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having t...
Definition: None.h:23
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(NoneType)
Construct an empty MutableArrayRef from None.
Definition: ArrayRef.h:324
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::MutableArrayRef::drop_until
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:406
llvm::ArrayRef::ArrayRef
ArrayRef(const std::initializer_list< T > &Vec)
Construct an ArrayRef from a std::initializer_list.
Definition: ArrayRef.h:115
llvm::MutableArrayRef::back
T & back() const
back - Get the last element.
Definition: ArrayRef.h:368
llvm::MutableArrayRef::drop_back
MutableArrayRef< T > drop_back(size_t N=1) const
Definition: ArrayRef.h:391
llvm::ArrayRef::equals
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
Definition: ArrayRef.h:186
llvm::MutableArrayRef::MutableArrayRef
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
Definition: ArrayRef.h:351
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:2002
llvm::MutableArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:355
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:200
llvm::MutableArrayRef::operator[]
T & operator[](size_t Index) const
Definition: ArrayRef.h:441
llvm::ArrayRef< uint64_t >::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: ArrayRef.h:52
llvm::size
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:1588
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
None.h
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef()=default
llvm::ArrayRef::ArrayRef
ArrayRef(const std::vector< T, A > &Vec)
Construct an ArrayRef from a std::vector.
Definition: ArrayRef.h:95
Compiler.h
llvm::MutableArrayRef::take_until
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:434
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MutableArrayRef::front
T & front() const
front - Get the first element.
Definition: ArrayRef.h:362
llvm::MutableArrayRef::data
T * data() const
Definition: ArrayRef.h:353
llvm::MutableArrayRef::slice
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:381
llvm::ArrayRef::front
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:167
llvm::find_if
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:1634
llvm::ArrayRef::ArrayRef
ArrayRef(const ArrayRef< U * > &A, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from ArrayRef<T*>.
Definition: ArrayRef.h:125
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
Definition: ArrayRef.h:341
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:268
llvm::ArrayRef::ArrayRef
ArrayRef(const std::vector< U *, A > &Vec, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=nullptr)
Construct an ArrayRef<const T*> from std::vector<T*>.
Definition: ArrayRef.h:143
llvm::OwningArrayRef::operator=
OwningArrayRef & operator=(OwningArrayRef &&Other)
Definition: ArrayRef.h:460
llvm::ArrayRef::take_until
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:248
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:152
llvm::ArrayRef::take_front
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition: ArrayRef.h:227
llvm::MutableArrayRef::take_front
MutableArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
Definition: ArrayRef.h:411
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T *begin, T *end)
Construct a MutableArrayRef from a range.
Definition: ArrayRef.h:334
LLVM_NODISCARD
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
Definition: Compiler.h:155
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T *data, size_t length)
Construct a MutableArrayRef from a pointer and length.
Definition: ArrayRef.h:330
LLVM_GSL_POINTER
#define LLVM_GSL_POINTER
LLVM_GSL_POINTER - Apply this to non-owning classes like StringRef to enable lifetime warnings.
Definition: Compiler.h:305
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct a MutableArrayRef from a SmallVector.
Definition: ArrayRef.h:337
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
llvm::ArrayRef< uint64_t >::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: ArrayRef.h:51
SmallVector.h
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(OwningArrayRef &&Other)
Definition: ArrayRef.h:458
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:142
N
#define N
llvm::hash_combine_range
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:483
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::ArrayRef::ArrayRef
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
Definition: ArrayRef.h:71
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::makeMutableArrayRef
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:533
llvm::ArrayRef::drop_while
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:216
llvm::ArrayRef::ArrayRef
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:74
llvm::ArrayRef::vec
std::vector< T > vec() const
Definition: ArrayRef.h:279
llvm::ArrayRef::ArrayRef
constexpr ArrayRef(const std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
Definition: ArrayRef.h:100
copy
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same we currently get code like const It could be done with a smaller encoding like local tee $pop5 local copy
Definition: README.txt:101
llvm::MutableArrayRef::MutableArrayRef
constexpr MutableArrayRef(std::array< T, N > &Arr)
Construct a MutableArrayRef from a std::array.
Definition: ArrayRef.h:346
llvm::ArrayRef::drop_until
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:222
llvm::MutableArrayRef::rbegin
reverse_iterator rbegin() const
Definition: ArrayRef.h:358
llvm::find_if_not
auto find_if_not(R &&Range, UnaryPredicate P)
Definition: STLExtras.h:1639
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
llvm::ArrayRef::copy
MutableArrayRef< T > copy(Allocator &A)
Definition: ArrayRef.h:179
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:73