LLVM  14.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 
29  template<typename T> struct DenseMapInfo;
30 
31  /// ArrayRef - Represent a constant reference to an array (0 or more elements
32  /// consecutively in memory), i.e. a start pointer and a length. It allows
33  /// various APIs to take consecutive elements easily and conveniently.
34  ///
35  /// This class does not own the underlying data, it is expected to be used in
36  /// situations where the data resides in some other buffer, whose lifetime
37  /// extends past that of the ArrayRef. For this reason, it is not in general
38  /// safe to store an ArrayRef.
39  ///
40  /// This is intended to be trivially copyable, so it should be passed by
41  /// value.
42  template<typename T>
43  class LLVM_GSL_POINTER LLVM_NODISCARD ArrayRef {
44  public:
45  using value_type = T;
46  using pointer = value_type *;
47  using const_pointer = const value_type *;
48  using reference = value_type &;
49  using const_reference = const value_type &;
52  using reverse_iterator = std::reverse_iterator<iterator>;
53  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
54  using size_type = size_t;
56 
57  private:
58  /// The start of the array, in an external buffer.
59  const T *Data = nullptr;
60 
61  /// The number of elements.
62  size_type Length = 0;
63 
64  public:
65  /// @name Constructors
66  /// @{
67 
68  /// Construct an empty ArrayRef.
69  /*implicit*/ ArrayRef() = default;
70 
71  /// Construct an empty ArrayRef from None.
72  /*implicit*/ ArrayRef(NoneType) {}
73 
74  /// Construct an ArrayRef from a single element.
75  /*implicit*/ ArrayRef(const T &OneElt)
76  : Data(&OneElt), Length(1) {}
77 
78  /// Construct an ArrayRef from a pointer and length.
79  /*implicit*/ ArrayRef(const T *data, size_t length)
80  : Data(data), Length(length) {}
81 
82  /// Construct an ArrayRef from a range.
83  ArrayRef(const T *begin, const T *end)
84  : Data(begin), Length(end - begin) {}
85 
86  /// Construct an ArrayRef from a SmallVector. This is templated in order to
87  /// avoid instantiating SmallVectorTemplateCommon<T> whenever we
88  /// copy-construct an ArrayRef.
89  template<typename U>
90  /*implicit*/ ArrayRef(const SmallVectorTemplateCommon<T, U> &Vec)
91  : Data(Vec.data()), Length(Vec.size()) {
92  }
93 
94  /// Construct an ArrayRef from a std::vector.
95  template<typename A>
96  /*implicit*/ ArrayRef(const std::vector<T, A> &Vec)
97  : Data(Vec.data()), Length(Vec.size()) {}
98 
99  /// Construct an ArrayRef from a std::array
100  template <size_t N>
101  /*implicit*/ constexpr ArrayRef(const std::array<T, N> &Arr)
102  : Data(Arr.data()), Length(N) {}
103 
104  /// Construct an ArrayRef from a C array.
105  template <size_t N>
106  /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
107 
108  /// Construct an ArrayRef from a std::initializer_list.
109 #if LLVM_GNUC_PREREQ(9, 0, 0)
110 // Disable gcc's warning in this constructor as it generates an enormous amount
111 // of messages. Anyone using ArrayRef should already be aware of the fact that
112 // it does not do lifetime extension.
113 #pragma GCC diagnostic push
114 #pragma GCC diagnostic ignored "-Winit-list-lifetime"
115 #endif
116  /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
117  : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
118  Length(Vec.size()) {}
119 #if LLVM_GNUC_PREREQ(9, 0, 0)
120 #pragma GCC diagnostic pop
121 #endif
122 
123  /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
124  /// ensure that only ArrayRefs of pointers can be converted.
125  template <typename U>
127  std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
128  * = nullptr)
129  : Data(A.data()), Length(A.size()) {}
130 
131  /// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
132  /// templated in order to avoid instantiating SmallVectorTemplateCommon<T>
133  /// whenever we copy-construct an ArrayRef.
134  template <typename U, typename DummyT>
135  /*implicit*/ ArrayRef(
137  std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
138  nullptr)
139  : Data(Vec.data()), Length(Vec.size()) {}
140 
141  /// Construct an ArrayRef<const T*> from std::vector<T*>. This uses SFINAE
142  /// to ensure that only vectors of pointers can be converted.
143  template <typename U, typename A>
144  ArrayRef(const std::vector<U *, A> &Vec,
145  std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
146  * = 0)
147  : Data(Vec.data()), Length(Vec.size()) {}
148 
149  /// @}
150  /// @name Simple Operations
151  /// @{
152 
153  iterator begin() const { return Data; }
154  iterator end() const { return Data + Length; }
155 
158 
159  /// empty - Check if the array is empty.
160  bool empty() const { return Length == 0; }
161 
162  const T *data() const { return Data; }
163 
164  /// size - Get the array size.
165  size_t size() const { return Length; }
166 
167  /// front - Get the first element.
168  const T &front() const {
169  assert(!empty());
170  return Data[0];
171  }
172 
173  /// back - Get the last element.
174  const T &back() const {
175  assert(!empty());
176  return Data[Length-1];
177  }
178 
179  // copy - Allocate copy in Allocator and return ArrayRef<T> to it.
180  template <typename Allocator> ArrayRef<T> copy(Allocator &A) {
181  T *Buff = A.template Allocate<T>(Length);
182  std::uninitialized_copy(begin(), end(), Buff);
183  return ArrayRef<T>(Buff, Length);
184  }
185 
186  /// equals - Check for element-wise equality.
187  bool equals(ArrayRef RHS) const {
188  if (Length != RHS.Length)
189  return false;
190  return std::equal(begin(), end(), RHS.begin());
191  }
192 
193  /// slice(n, m) - Chop off the first N elements of the array, and keep M
194  /// elements in the array.
195  ArrayRef<T> slice(size_t N, size_t M) const {
196  assert(N+M <= size() && "Invalid specifier");
197  return ArrayRef<T>(data()+N, M);
198  }
199 
200  /// slice(n) - Chop off the first N elements of the array.
201  ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
202 
203  /// Drop the first \p N elements of the array.
204  ArrayRef<T> drop_front(size_t N = 1) const {
205  assert(size() >= N && "Dropping more elements than exist");
206  return slice(N, size() - N);
207  }
208 
209  /// Drop the last \p N elements of the array.
210  ArrayRef<T> drop_back(size_t N = 1) const {
211  assert(size() >= N && "Dropping more elements than exist");
212  return slice(0, size() - N);
213  }
214 
215  /// Return a copy of *this with the first N elements satisfying the
216  /// given predicate removed.
217  template <class PredicateT> ArrayRef<T> drop_while(PredicateT Pred) const {
218  return ArrayRef<T>(find_if_not(*this, Pred), end());
219  }
220 
221  /// Return a copy of *this with the first N elements not satisfying
222  /// the given predicate removed.
223  template <class PredicateT> ArrayRef<T> drop_until(PredicateT Pred) const {
224  return ArrayRef<T>(find_if(*this, Pred), end());
225  }
226 
227  /// Return a copy of *this with only the first \p N elements.
228  ArrayRef<T> take_front(size_t N = 1) const {
229  if (N >= size())
230  return *this;
231  return drop_back(size() - N);
232  }
233 
234  /// Return a copy of *this with only the last \p N elements.
235  ArrayRef<T> take_back(size_t N = 1) const {
236  if (N >= size())
237  return *this;
238  return drop_front(size() - N);
239  }
240 
241  /// Return the first N elements of this Array that satisfy the given
242  /// predicate.
243  template <class PredicateT> ArrayRef<T> take_while(PredicateT Pred) const {
244  return ArrayRef<T>(begin(), find_if_not(*this, Pred));
245  }
246 
247  /// Return the first N elements of this Array that don't satisfy the
248  /// given predicate.
249  template <class PredicateT> ArrayRef<T> take_until(PredicateT Pred) const {
250  return ArrayRef<T>(begin(), find_if(*this, Pred));
251  }
252 
253  /// @}
254  /// @name Operator Overloads
255  /// @{
256  const T &operator[](size_t Index) const {
257  assert(Index < Length && "Invalid index!");
258  return Data[Index];
259  }
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=(U &&Temporary) = delete;
268 
269  /// Disallow accidental assignment from a temporary.
270  ///
271  /// The declaration here is extra complicated so that "arrayRef = {}"
272  /// continues to select the move assignment operator.
273  template <typename U>
274  std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
275  operator=(std::initializer_list<U>) = delete;
276 
277  /// @}
278  /// @name Expensive Operations
279  /// @{
280  std::vector<T> vec() const {
281  return std::vector<T>(Data, Data+Length);
282  }
283 
284  /// @}
285  /// @name Conversion operators
286  /// @{
287  operator std::vector<T>() const {
288  return std::vector<T>(Data, Data+Length);
289  }
290 
291  /// @}
292  };
293 
294  /// MutableArrayRef - Represent a mutable reference to an array (0 or more
295  /// elements consecutively in memory), i.e. a start pointer and a length. It
296  /// allows various APIs to take and modify consecutive elements easily and
297  /// conveniently.
298  ///
299  /// This class does not own the underlying data, it is expected to be used in
300  /// situations where the data resides in some other buffer, whose lifetime
301  /// extends past that of the MutableArrayRef. For this reason, it is not in
302  /// general safe to store a MutableArrayRef.
303  ///
304  /// This is intended to be trivially copyable, so it should be passed by
305  /// value.
306  template<typename T>
308  public:
309  using value_type = T;
310  using pointer = value_type *;
311  using const_pointer = const value_type *;
313  using const_reference = const value_type &;
314  using iterator = pointer;
316  using reverse_iterator = std::reverse_iterator<iterator>;
317  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
318  using size_type = size_t;
320 
321  /// Construct an empty MutableArrayRef.
322  /*implicit*/ MutableArrayRef() = default;
323 
324  /// Construct an empty MutableArrayRef from None.
325  /*implicit*/ MutableArrayRef(NoneType) : ArrayRef<T>() {}
326 
327  /// Construct a MutableArrayRef from a single element.
328  /*implicit*/ MutableArrayRef(T &OneElt) : ArrayRef<T>(OneElt) {}
329 
330  /// Construct a MutableArrayRef from a pointer and length.
331  /*implicit*/ MutableArrayRef(T *data, size_t length)
332  : ArrayRef<T>(data, length) {}
333 
334  /// Construct a MutableArrayRef from a range.
336 
337  /// Construct a MutableArrayRef from a SmallVector.
339  : ArrayRef<T>(Vec) {}
340 
341  /// Construct a MutableArrayRef from a std::vector.
342  /*implicit*/ MutableArrayRef(std::vector<T> &Vec)
343  : ArrayRef<T>(Vec) {}
344 
345  /// Construct a MutableArrayRef from a std::array
346  template <size_t N>
347  /*implicit*/ constexpr MutableArrayRef(std::array<T, N> &Arr)
348  : ArrayRef<T>(Arr) {}
349 
350  /// Construct a MutableArrayRef from a C array.
351  template <size_t N>
352  /*implicit*/ constexpr MutableArrayRef(T (&Arr)[N]) : ArrayRef<T>(Arr) {}
353 
354  T *data() const { return const_cast<T*>(ArrayRef<T>::data()); }
355 
356  iterator begin() const { return data(); }
357  iterator end() const { return data() + this->size(); }
358 
361 
362  /// front - Get the first element.
363  T &front() const {
364  assert(!this->empty());
365  return data()[0];
366  }
367 
368  /// back - Get the last element.
369  T &back() const {
370  assert(!this->empty());
371  return data()[this->size()-1];
372  }
373 
374  /// slice(n, m) - Chop off the first N elements of the array, and keep M
375  /// elements in the array.
376  MutableArrayRef<T> slice(size_t N, size_t M) const {
377  assert(N + M <= this->size() && "Invalid specifier");
378  return MutableArrayRef<T>(this->data() + N, M);
379  }
380 
381  /// slice(n) - Chop off the first N elements of the array.
382  MutableArrayRef<T> slice(size_t N) const {
383  return slice(N, this->size() - N);
384  }
385 
386  /// Drop the first \p N elements of the array.
387  MutableArrayRef<T> drop_front(size_t N = 1) const {
388  assert(this->size() >= N && "Dropping more elements than exist");
389  return slice(N, this->size() - N);
390  }
391 
392  MutableArrayRef<T> drop_back(size_t N = 1) const {
393  assert(this->size() >= N && "Dropping more elements than exist");
394  return slice(0, this->size() - N);
395  }
396 
397  /// Return a copy of *this with the first N elements satisfying the
398  /// given predicate removed.
399  template <class PredicateT>
401  return MutableArrayRef<T>(find_if_not(*this, Pred), end());
402  }
403 
404  /// Return a copy of *this with the first N elements not satisfying
405  /// the given predicate removed.
406  template <class PredicateT>
408  return MutableArrayRef<T>(find_if(*this, Pred), end());
409  }
410 
411  /// Return a copy of *this with only the first \p N elements.
412  MutableArrayRef<T> take_front(size_t N = 1) const {
413  if (N >= this->size())
414  return *this;
415  return drop_back(this->size() - N);
416  }
417 
418  /// Return a copy of *this with only the last \p N elements.
419  MutableArrayRef<T> take_back(size_t N = 1) const {
420  if (N >= this->size())
421  return *this;
422  return drop_front(this->size() - N);
423  }
424 
425  /// Return the first N elements of this Array that satisfy the given
426  /// predicate.
427  template <class PredicateT>
429  return MutableArrayRef<T>(begin(), find_if_not(*this, Pred));
430  }
431 
432  /// Return the first N elements of this Array that don't satisfy the
433  /// given predicate.
434  template <class PredicateT>
436  return MutableArrayRef<T>(begin(), find_if(*this, Pred));
437  }
438 
439  /// @}
440  /// @name Operator Overloads
441  /// @{
442  T &operator[](size_t Index) const {
443  assert(Index < this->size() && "Invalid index!");
444  return data()[Index];
445  }
446  };
447 
448  /// This is a MutableArrayRef that owns its array.
449  template <typename T> class OwningArrayRef : public MutableArrayRef<T> {
450  public:
451  OwningArrayRef() = default;
453 
455  : MutableArrayRef<T>(new T[Data.size()], Data.size()) {
456  std::copy(Data.begin(), Data.end(), this->begin());
457  }
458 
460 
462  delete[] this->data();
464  Other.MutableArrayRef<T>::operator=(MutableArrayRef<T>());
465  return *this;
466  }
467 
468  ~OwningArrayRef() { delete[] this->data(); }
469  };
470 
471  /// @name ArrayRef Convenience constructors
472  /// @{
473 
474  /// Construct an ArrayRef from a single element.
475  template<typename T>
476  ArrayRef<T> makeArrayRef(const T &OneElt) {
477  return OneElt;
478  }
479 
480  /// Construct an ArrayRef from a pointer and length.
481  template<typename T>
482  ArrayRef<T> makeArrayRef(const T *data, size_t length) {
483  return ArrayRef<T>(data, length);
484  }
485 
486  /// Construct an ArrayRef from a range.
487  template<typename T>
488  ArrayRef<T> makeArrayRef(const T *begin, const T *end) {
489  return ArrayRef<T>(begin, end);
490  }
491 
492  /// Construct an ArrayRef from a SmallVector.
493  template <typename T>
495  return Vec;
496  }
497 
498  /// Construct an ArrayRef from a SmallVector.
499  template <typename T, unsigned N>
501  return Vec;
502  }
503 
504  /// Construct an ArrayRef from a std::vector.
505  template<typename T>
506  ArrayRef<T> makeArrayRef(const std::vector<T> &Vec) {
507  return Vec;
508  }
509 
510  /// Construct an ArrayRef from a std::array.
511  template <typename T, std::size_t N>
512  ArrayRef<T> makeArrayRef(const std::array<T, N> &Arr) {
513  return Arr;
514  }
515 
516  /// Construct an ArrayRef from an ArrayRef (no-op) (const)
517  template <typename T> ArrayRef<T> makeArrayRef(const ArrayRef<T> &Vec) {
518  return Vec;
519  }
520 
521  /// Construct an ArrayRef from an ArrayRef (no-op)
522  template <typename T> ArrayRef<T> &makeArrayRef(ArrayRef<T> &Vec) {
523  return Vec;
524  }
525 
526  /// Construct an ArrayRef from a C array.
527  template<typename T, size_t N>
528  ArrayRef<T> makeArrayRef(const T (&Arr)[N]) {
529  return ArrayRef<T>(Arr);
530  }
531 
532  /// Construct a MutableArrayRef from a single element.
533  template<typename T>
535  return OneElt;
536  }
537 
538  /// Construct a MutableArrayRef from a pointer and length.
539  template<typename T>
540  MutableArrayRef<T> makeMutableArrayRef(T *data, size_t length) {
541  return MutableArrayRef<T>(data, length);
542  }
543 
544  /// @}
545  /// @name ArrayRef Comparison Operators
546  /// @{
547 
548  template<typename T>
549  inline bool operator==(ArrayRef<T> LHS, ArrayRef<T> RHS) {
550  return LHS.equals(RHS);
551  }
552 
553  template <typename T>
554  inline bool operator==(SmallVectorImpl<T> &LHS, ArrayRef<T> RHS) {
555  return ArrayRef<T>(LHS).equals(RHS);
556  }
557 
558  template <typename T>
559  inline bool operator!=(ArrayRef<T> LHS, ArrayRef<T> RHS) {
560  return !(LHS == RHS);
561  }
562 
563  template <typename T>
564  inline bool operator!=(SmallVectorImpl<T> &LHS, ArrayRef<T> RHS) {
565  return !(LHS == RHS);
566  }
567 
568  /// @}
569 
570  template <typename T> hash_code hash_value(ArrayRef<T> S) {
571  return hash_combine_range(S.begin(), S.end());
572  }
573 
574  // Provide DenseMapInfo for ArrayRefs.
575  template <typename T> struct DenseMapInfo<ArrayRef<T>> {
576  static inline ArrayRef<T> getEmptyKey() {
577  return ArrayRef<T>(
578  reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)), size_t(0));
579  }
580 
581  static inline ArrayRef<T> getTombstoneKey() {
582  return ArrayRef<T>(
583  reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)), size_t(0));
584  }
585 
586  static unsigned getHashValue(ArrayRef<T> Val) {
587  assert(Val.data() != getEmptyKey().data() &&
588  "Cannot hash the empty key!");
589  assert(Val.data() != getTombstoneKey().data() &&
590  "Cannot hash the tombstone key!");
591  return (unsigned)(hash_value(Val));
592  }
593 
594  static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
595  if (RHS.data() == getEmptyKey().data())
596  return LHS.data() == getEmptyKey().data();
597  if (RHS.data() == getTombstoneKey().data())
598  return LHS.data() == getTombstoneKey().data();
599  return LHS == RHS;
600  }
601  };
602 
603 } // end namespace llvm
604 
605 #endif // LLVM_ADT_ARRAYREF_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::ArrayRef::drop_back
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:210
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
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:428
llvm::OwningArrayRef
This is a MutableArrayRef that owns its array.
Definition: ArrayRef.h:449
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:135
llvm::ArrayRef::ArrayRef
ArrayRef(const T *data, size_t length)
Construct an ArrayRef from a pointer and length.
Definition: ArrayRef.h:79
llvm::ArrayRef::copy
ArrayRef< T > copy(Allocator &A)
Definition: ArrayRef.h:180
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:443
llvm::MutableArrayRef::rend
reverse_iterator rend() const
Definition: ArrayRef.h:360
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::ArrayRef::ArrayRef
ArrayRef(const SmallVectorTemplateCommon< T, U > &Vec)
Construct an ArrayRef from a SmallVector.
Definition: ArrayRef.h:90
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(size_t Size)
Definition: ArrayRef.h:452
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::OperandBundleDefT
A container for an operand bundle being viewed as a set of values rather than a set of uses.
Definition: InstrTypes.h:1114
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:328
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1976
T
#define T
Definition: Mips16ISelLowering.cpp:341
Hashing.h
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(ArrayRef< T > Data)
Definition: ArrayRef.h:454
llvm::DenseMapInfo< ArrayRef< T > >::getTombstoneKey
static ArrayRef< T > getTombstoneKey()
Definition: ArrayRef.h:581
STLExtras.h
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:419
llvm::hash_value
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
Definition: APFloat.cpp:4827
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:243
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
size_t
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:162
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::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:83
llvm::DenseMapInfo
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:387
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:174
llvm::MutableArrayRef::end
iterator end() const
Definition: ArrayRef.h:357
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
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:400
ptrdiff_t
llvm::OwningArrayRef::~OwningArrayRef
~OwningArrayRef()
Definition: ArrayRef.h:468
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:256
llvm::ArrayRef::rbegin
reverse_iterator rbegin() const
Definition: ArrayRef.h:156
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:195
llvm::ArrayRef::rend
reverse_iterator rend() const
Definition: ArrayRef.h:157
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:235
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:376
llvm::DenseMapInfo< ArrayRef< T > >::isEqual
static bool isEqual(ArrayRef< T > LHS, ArrayRef< T > RHS)
Definition: ArrayRef.h:594
llvm::SmallVectorTemplateCommon
This is the part of SmallVectorTemplateBase which does not depend on whether the type T is a POD.
Definition: SmallVector.h:106
llvm::ArrayRef::ArrayRef
constexpr ArrayRef(const T(&Arr)[N])
Construct an ArrayRef from a C array.
Definition: ArrayRef.h:106
llvm::ArrayRef::drop_front
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:204
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::NoneType
NoneType
A simple null object to allow implicit construction of Optional<T> and similar types without having t...
Definition: None.h:22
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(NoneType)
Construct an empty MutableArrayRef from None.
Definition: ArrayRef.h:325
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:407
llvm::ArrayRef::ArrayRef
ArrayRef(const std::initializer_list< T > &Vec)
Construct an ArrayRef from a std::initializer_list.
Definition: ArrayRef.h:116
llvm::MutableArrayRef::back
T & back() const
back - Get the last element.
Definition: ArrayRef.h:369
llvm::MutableArrayRef::drop_back
MutableArrayRef< T > drop_back(size_t N=1) const
Definition: ArrayRef.h:392
llvm::ArrayRef::equals
bool equals(ArrayRef RHS) const
equals - Check for element-wise equality.
Definition: ArrayRef.h:187
llvm::MutableArrayRef::MutableArrayRef
constexpr MutableArrayRef(T(&Arr)[N])
Construct a MutableArrayRef from a C array.
Definition: ArrayRef.h:352
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ArrayRef::ArrayRef
ArrayRef(const std::vector< U *, A > &Vec, std::enable_if_t< std::is_convertible< U *const *, T const * >::value > *=0)
Construct an ArrayRef<const T*> from std::vector<T*>.
Definition: ArrayRef.h:144
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1974
llvm::MutableArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:356
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:201
llvm::MutableArrayRef::operator[]
T & operator[](size_t Index) const
Definition: ArrayRef.h:442
llvm::ArrayRef< llvm::OperandBundleDefT >::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: ArrayRef.h:53
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:1528
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:96
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:435
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:363
llvm::MutableArrayRef::data
T * data() const
Definition: ArrayRef.h:354
llvm::MutableArrayRef::slice
MutableArrayRef< T > slice(size_t N) const
slice(n) - Chop off the first N elements of the array.
Definition: ArrayRef.h:382
llvm::ArrayRef::front
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:168
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:1574
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:126
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(std::vector< T > &Vec)
Construct a MutableArrayRef from a std::vector.
Definition: ArrayRef.h:342
llvm::empty
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
Definition: STLExtras.h:254
llvm::OwningArrayRef::operator=
OwningArrayRef & operator=(OwningArrayRef &&Other)
Definition: ArrayRef.h:461
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:249
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:153
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:228
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:412
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T *begin, T *end)
Construct a MutableArrayRef from a range.
Definition: ArrayRef.h:335
LLVM_NODISCARD
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
Definition: Compiler.h:161
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(T *data, size_t length)
Construct a MutableArrayRef from a pointer and length.
Definition: ArrayRef.h:331
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:298
llvm::MutableArrayRef::MutableArrayRef
MutableArrayRef(SmallVectorImpl< T > &Vec)
Construct a MutableArrayRef from a SmallVector.
Definition: ArrayRef.h:338
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
llvm::ArrayRef< llvm::OperandBundleDefT >::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: ArrayRef.h:52
SmallVector.h
llvm::OwningArrayRef::OwningArrayRef
OwningArrayRef(OwningArrayRef &&Other)
Definition: ArrayRef.h:459
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
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:482
llvm::DenseMapInfo< ArrayRef< T > >::getEmptyKey
static ArrayRef< T > getEmptyKey()
Definition: ArrayRef.h:576
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
llvm::ArrayRef::ArrayRef
ArrayRef(NoneType)
Construct an empty ArrayRef from None.
Definition: ArrayRef.h:72
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::makeMutableArrayRef
MutableArrayRef< T > makeMutableArrayRef(T &OneElt)
Construct a MutableArrayRef from a single element.
Definition: ArrayRef.h:534
llvm::DenseMapInfo< ArrayRef< T > >::getHashValue
static unsigned getHashValue(ArrayRef< T > Val)
Definition: ArrayRef.h:586
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:217
llvm::ArrayRef::ArrayRef
ArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:75
llvm::ArrayRef::vec
std::vector< T > vec() const
Definition: ArrayRef.h:280
llvm::ArrayRef::ArrayRef
constexpr ArrayRef(const std::array< T, N > &Arr)
Construct an ArrayRef from a std::array.
Definition: ArrayRef.h:101
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:347
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:223
llvm::MutableArrayRef::rbegin
reverse_iterator rbegin() const
Definition: ArrayRef.h:359
llvm::find_if_not
auto find_if_not(R &&Range, UnaryPredicate P)
Definition: STLExtras.h:1579
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:154
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:72