LLVM  14.0.0git
TypeSize.h
Go to the documentation of this file.
1 //===- TypeSize.h - Wrapper around type sizes -------------------*- 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 // This file provides a struct that can be used to query the size of IR types
10 // which may be scalable vectors. It provides convenience operators so that
11 // it can be used in much the same way as a single scalar value.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_SUPPORT_TYPESIZE_H
16 #define LLVM_SUPPORT_TYPESIZE_H
17 
18 #include "llvm/ADT/ArrayRef.h"
21 
22 #include <algorithm>
23 #include <array>
24 #include <cassert>
25 #include <cstdint>
26 #include <type_traits>
27 
28 namespace llvm {
29 
30 /// Reports a diagnostic message to indicate an invalid size request has been
31 /// done on a scalable vector. This function may not return.
32 void reportInvalidSizeRequest(const char *Msg);
33 
34 template <typename LeafTy> struct LinearPolyBaseTypeTraits {};
35 
36 //===----------------------------------------------------------------------===//
37 // LinearPolyBase - a base class for linear polynomials with multiple
38 // dimensions. This can e.g. be used to describe offsets that are have both a
39 // fixed and scalable component.
40 //===----------------------------------------------------------------------===//
41 
42 /// LinearPolyBase describes a linear polynomial:
43 /// c0 * scale0 + c1 * scale1 + ... + cK * scaleK
44 /// where the scale is implicit, so only the coefficients are encoded.
45 template <typename LeafTy>
47 public:
51  "Dimensions out of range");
52 
53 private:
54  std::array<ScalarTy, Dimensions> Coefficients;
55 
56 protected:
58  std::copy(Values.begin(), Values.end(), Coefficients.begin());
59  }
60 
61 public:
62  friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) {
63  for (unsigned I=0; I<Dimensions; ++I)
64  LHS.Coefficients[I] += RHS.Coefficients[I];
65  return LHS;
66  }
67 
68  friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) {
69  for (unsigned I=0; I<Dimensions; ++I)
70  LHS.Coefficients[I] -= RHS.Coefficients[I];
71  return LHS;
72  }
73 
74  friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) {
75  for (auto &C : LHS.Coefficients)
76  C *= RHS;
77  return LHS;
78  }
79 
80  friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) {
81  LeafTy Copy = LHS;
82  return Copy += RHS;
83  }
84 
85  friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) {
86  LeafTy Copy = LHS;
87  return Copy -= RHS;
88  }
89 
90  friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) {
91  LeafTy Copy = LHS;
92  return Copy *= RHS;
93  }
94 
95  template <typename U = ScalarTy>
96  friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy>
97  operator-(const LeafTy &LHS) {
98  LeafTy Copy = LHS;
99  return Copy *= -1;
100  }
101 
102  bool operator==(const LinearPolyBase &RHS) const {
103  return std::equal(Coefficients.begin(), Coefficients.end(),
104  RHS.Coefficients.begin());
105  }
106 
107  bool operator!=(const LinearPolyBase &RHS) const {
108  return !(*this == RHS);
109  }
110 
111  bool isZero() const {
112  return all_of(Coefficients, [](const ScalarTy &C) { return C == 0; });
113  }
114  bool isNonZero() const { return !isZero(); }
115  explicit operator bool() const { return isNonZero(); }
116 
117  ScalarTy getValue(unsigned Dim) const { return Coefficients[Dim]; }
118 };
119 
120 //===----------------------------------------------------------------------===//
121 // StackOffset - Represent an offset with named fixed and scalable components.
122 //===----------------------------------------------------------------------===//
123 
124 class StackOffset;
126  using ScalarTy = int64_t;
127  static constexpr unsigned Dimensions = 2;
128 };
129 
130 /// StackOffset is a class to represent an offset with 2 dimensions,
131 /// named fixed and scalable, respectively. This class allows a value for both
132 /// dimensions to depict e.g. "8 bytes and 16 scalable bytes", which is needed
133 /// to represent stack offsets.
134 class StackOffset : public LinearPolyBase<StackOffset> {
135 protected:
136  StackOffset(ScalarTy Fixed, ScalarTy Scalable)
137  : LinearPolyBase<StackOffset>({Fixed, Scalable}) {}
138 
139 public:
140  StackOffset() : StackOffset({0, 0}) {}
143  static StackOffset getFixed(ScalarTy Fixed) { return {Fixed, 0}; }
144  static StackOffset getScalable(ScalarTy Scalable) { return {0, Scalable}; }
145  static StackOffset get(ScalarTy Fixed, ScalarTy Scalable) {
146  return {Fixed, Scalable};
147  }
148 
149  ScalarTy getFixed() const { return this->getValue(0); }
150  ScalarTy getScalable() const { return this->getValue(1); }
151 };
152 
153 //===----------------------------------------------------------------------===//
154 // UnivariateLinearPolyBase - a base class for linear polynomials with multiple
155 // dimensions, but where only one dimension can be set at any time.
156 // This can e.g. be used to describe sizes that are either fixed or scalable.
157 //===----------------------------------------------------------------------===//
158 
159 /// UnivariateLinearPolyBase is a base class for ElementCount and TypeSize.
160 /// Like LinearPolyBase it tries to represent a linear polynomial
161 /// where only one dimension can be set at any time, e.g.
162 /// 0 * scale0 + 0 * scale1 + ... + cJ * scaleJ + ... + 0 * scaleK
163 /// The dimension that is set is the univariate dimension.
164 template <typename LeafTy>
166 public:
170  "Dimensions out of range");
171 
172 protected:
173  ScalarTy Value; // The value at the univeriate dimension.
174  unsigned UnivariateDim; // The univeriate dimension.
175 
178  assert(UnivariateDim < Dimensions && "Dimension out of range");
179  }
180 
181  friend LeafTy &operator+=(LeafTy &LHS, const LeafTy &RHS) {
182  assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions");
183  LHS.Value += RHS.Value;
184  return LHS;
185  }
186 
187  friend LeafTy &operator-=(LeafTy &LHS, const LeafTy &RHS) {
188  assert(LHS.UnivariateDim == RHS.UnivariateDim && "Invalid dimensions");
189  LHS.Value -= RHS.Value;
190  return LHS;
191  }
192 
193  friend LeafTy &operator*=(LeafTy &LHS, ScalarTy RHS) {
194  LHS.Value *= RHS;
195  return LHS;
196  }
197 
198  friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS) {
199  LeafTy Copy = LHS;
200  return Copy += RHS;
201  }
202 
203  friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS) {
204  LeafTy Copy = LHS;
205  return Copy -= RHS;
206  }
207 
208  friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS) {
209  LeafTy Copy = LHS;
210  return Copy *= RHS;
211  }
212 
213  template <typename U = ScalarTy>
214  friend typename std::enable_if<std::is_signed<U>::value, LeafTy>::type
215  operator-(const LeafTy &LHS) {
216  LeafTy Copy = LHS;
217  return Copy *= -1;
218  }
219 
220 public:
222  return Value == RHS.Value && UnivariateDim == RHS.UnivariateDim;
223  }
224 
226  return !(*this == RHS);
227  }
228 
229  bool isZero() const { return !Value; }
230  bool isNonZero() const { return !isZero(); }
231  explicit operator bool() const { return isNonZero(); }
232  ScalarTy getValue(unsigned Dim) const {
233  return Dim == UnivariateDim ? Value : 0;
234  }
235 
236  /// Add \p RHS to the value at the univariate dimension.
237  LeafTy getWithIncrement(ScalarTy RHS) const {
238  return static_cast<LeafTy>(
240  }
241 
242  /// Subtract \p RHS from the value at the univariate dimension.
243  LeafTy getWithDecrement(ScalarTy RHS) const {
244  return static_cast<LeafTy>(
246  }
247 };
248 
249 
250 //===----------------------------------------------------------------------===//
251 // LinearPolySize - base class for fixed- or scalable sizes.
252 // ^ ^
253 // | |
254 // | +----- ElementCount - Leaf class to represent an element count
255 // | (vscale x unsigned)
256 // |
257 // +-------- TypeSize - Leaf class to represent a type size
258 // (vscale x uint64_t)
259 //===----------------------------------------------------------------------===//
260 
261 /// LinearPolySize is a base class to represent sizes. It is either
262 /// fixed-sized or it is scalable-sized, but it cannot be both.
263 template <typename LeafTy>
264 class LinearPolySize : public UnivariateLinearPolyBase<LeafTy> {
265  // Make the parent class a friend, so that it can access the protected
266  // conversion/copy-constructor for UnivariatePolyBase<LeafTy> ->
267  // LinearPolySize<LeafTy>.
268  friend class UnivariateLinearPolyBase<LeafTy>;
269 
270 public:
272  enum Dims : unsigned { FixedDim = 0, ScalableDim = 1 };
273 
274 protected:
276  : UnivariateLinearPolyBase<LeafTy>(MinVal, D) {}
277 
279  : UnivariateLinearPolyBase<LeafTy>(V) {}
280 
281 public:
282 
283  static LeafTy getFixed(ScalarTy MinVal) {
284  return static_cast<LeafTy>(LinearPolySize(MinVal, FixedDim));
285  }
286  static LeafTy getScalable(ScalarTy MinVal) {
287  return static_cast<LeafTy>(LinearPolySize(MinVal, ScalableDim));
288  }
289  static LeafTy get(ScalarTy MinVal, bool Scalable) {
290  return static_cast<LeafTy>(
291  LinearPolySize(MinVal, Scalable ? ScalableDim : FixedDim));
292  }
293  static LeafTy getNull() { return get(0, false); }
294 
295  /// Returns the minimum value this size can represent.
296  ScalarTy getKnownMinValue() const { return this->Value; }
297  /// Returns whether the size is scaled by a runtime quantity (vscale).
298  bool isScalable() const { return this->UnivariateDim == ScalableDim; }
299  /// A return value of true indicates we know at compile time that the number
300  /// of elements (vscale * Min) is definitely even. However, returning false
301  /// does not guarantee that the total number of elements is odd.
302  bool isKnownEven() const { return (getKnownMinValue() & 0x1) == 0; }
303  /// This function tells the caller whether the element count is known at
304  /// compile time to be a multiple of the scalar value RHS.
306  return getKnownMinValue() % RHS == 0;
307  }
308 
309  // Return the minimum value with the assumption that the count is exact.
310  // Use in places where a scalable count doesn't make sense (e.g. non-vector
311  // types, or vectors in backends which don't support scalable vectors).
313  assert(!isScalable() &&
314  "Request for a fixed element count on a scalable object");
315  return getKnownMinValue();
316  }
317 
318  // For some cases, size ordering between scalable and fixed size types cannot
319  // be determined at compile time, so such comparisons aren't allowed.
320  //
321  // e.g. <vscale x 2 x i16> could be bigger than <4 x i32> with a runtime
322  // vscale >= 5, equal sized with a vscale of 4, and smaller with
323  // a vscale <= 3.
324  //
325  // All the functions below make use of the fact vscale is always >= 1, which
326  // means that <vscale x 4 x i32> is guaranteed to be >= <4 x i32>, etc.
327 
328  static bool isKnownLT(const LinearPolySize &LHS, const LinearPolySize &RHS) {
329  if (!LHS.isScalable() || RHS.isScalable())
330  return LHS.getKnownMinValue() < RHS.getKnownMinValue();
331  return false;
332  }
333 
334  static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS) {
335  if (LHS.isScalable() || !RHS.isScalable())
336  return LHS.getKnownMinValue() > RHS.getKnownMinValue();
337  return false;
338  }
339 
340  static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS) {
341  if (!LHS.isScalable() || RHS.isScalable())
342  return LHS.getKnownMinValue() <= RHS.getKnownMinValue();
343  return false;
344  }
345 
346  static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS) {
347  if (LHS.isScalable() || !RHS.isScalable())
348  return LHS.getKnownMinValue() >= RHS.getKnownMinValue();
349  return false;
350  }
351 
352  /// We do not provide the '/' operator here because division for polynomial
353  /// types does not work in the same way as for normal integer types. We can
354  /// only divide the minimum value (or coefficient) by RHS, which is not the
355  /// same as
356  /// (Min * Vscale) / RHS
357  /// The caller is recommended to use this function in combination with
358  /// isKnownMultipleOf(RHS), which lets the caller know if it's possible to
359  /// perform a lossless divide by RHS.
361  return static_cast<LeafTy>(
363  }
364 
365  LeafTy coefficientNextPowerOf2() const {
366  return static_cast<LeafTy>(LinearPolySize::get(
368  isScalable()));
369  }
370 
371  /// Printing function.
372  void print(raw_ostream &OS) const {
373  if (isScalable())
374  OS << "vscale x ";
375  OS << getKnownMinValue();
376  }
377 };
378 
379 class ElementCount;
381  using ScalarTy = unsigned;
382  static constexpr unsigned Dimensions = 2;
383 };
384 
385 class ElementCount : public LinearPolySize<ElementCount> {
386 public:
388 
390 
391  /// Counting predicates.
392  ///
393  ///@{ Number of elements..
394  /// Exactly one element.
395  bool isScalar() const { return !isScalable() && getKnownMinValue() == 1; }
396  /// One or more elements.
397  bool isVector() const {
398  return (isScalable() && getKnownMinValue() != 0) || getKnownMinValue() > 1;
399  }
400  ///@}
401 };
402 
403 // This class is used to represent the size of types. If the type is of fixed
404 class TypeSize;
405 template <> struct LinearPolyBaseTypeTraits<TypeSize> {
407  static constexpr unsigned Dimensions = 2;
408 };
409 
410 // TODO: Most functionality in this class will gradually be phased out
411 // so it will resemble LinearPolySize as much as possible.
412 //
413 // TypeSize is used to represent the size of types. If the type is of fixed
414 // size, it will represent the exact size. If the type is a scalable vector,
415 // it will represent the known minimum size.
416 class TypeSize : public LinearPolySize<TypeSize> {
417 public:
419  TypeSize(ScalarTy MinVal, bool IsScalable)
420  : LinearPolySize(LinearPolySize::get(MinVal, IsScalable)) {}
421 
422  static TypeSize Fixed(ScalarTy MinVal) { return TypeSize(MinVal, false); }
423  static TypeSize Scalable(ScalarTy MinVal) { return TypeSize(MinVal, true); }
424 
425  ScalarTy getFixedSize() const { return getFixedValue(); }
427 
428  // All code for this class below this point is needed because of the
429  // temporary implicit conversion to uint64_t. The operator overloads are
430  // needed because otherwise the conversion of the parent class
431  // UnivariateLinearPolyBase -> TypeSize is ambiguous.
432  // TODO: Remove the implicit conversion.
433 
434  // Casts to a uint64_t if this is a fixed-width size.
435  //
436  // This interface is deprecated and will be removed in a future version
437  // of LLVM in favour of upgrading uses that rely on this implicit conversion
438  // to uint64_t. Calls to functions that return a TypeSize should use the
439  // proper interfaces to TypeSize.
440  // In practice this is mostly calls to MVT/EVT::getSizeInBits().
441  //
442  // To determine how to upgrade the code:
443  //
444  // if (<algorithm works for both scalable and fixed-width vectors>)
445  // use getKnownMinValue()
446  // else if (<algorithm works only for fixed-width vectors>) {
447  // if <algorithm can be adapted for both scalable and fixed-width vectors>
448  // update the algorithm and use getKnownMinValue()
449  // else
450  // bail out early for scalable vectors and use getFixedValue()
451  // }
452  operator ScalarTy() const;
453 
454  // Additional operators needed to avoid ambiguous parses
455  // because of the implicit conversion hack.
456  friend TypeSize operator*(const TypeSize &LHS, const int RHS) {
457  return LHS * (ScalarTy)RHS;
458  }
459  friend TypeSize operator*(const TypeSize &LHS, const unsigned RHS) {
460  return LHS * (ScalarTy)RHS;
461  }
462  friend TypeSize operator*(const TypeSize &LHS, const int64_t RHS) {
463  return LHS * (ScalarTy)RHS;
464  }
465  friend TypeSize operator*(const int LHS, const TypeSize &RHS) {
466  return RHS * LHS;
467  }
468  friend TypeSize operator*(const unsigned LHS, const TypeSize &RHS) {
469  return RHS * LHS;
470  }
471  friend TypeSize operator*(const int64_t LHS, const TypeSize &RHS) {
472  return RHS * LHS;
473  }
474  friend TypeSize operator*(const uint64_t LHS, const TypeSize &RHS) {
475  return RHS * LHS;
476  }
477 };
478 
479 //===----------------------------------------------------------------------===//
480 // Utilities
481 //===----------------------------------------------------------------------===//
482 
483 /// Returns a TypeSize with a known minimum size that is the next integer
484 /// (mod 2**64) that is greater than or equal to \p Value and is a multiple
485 /// of \p Align. \p Align must be non-zero.
486 ///
487 /// Similar to the alignTo functions in MathExtras.h
489  assert(Align != 0u && "Align must be non-zero");
490  return {(Size.getKnownMinValue() + Align - 1) / Align * Align,
491  Size.isScalable()};
492 }
493 
494 /// Stream operator function for `LinearPolySize`.
495 template <typename LeafTy>
497  const LinearPolySize<LeafTy> &PS) {
498  PS.print(OS);
499  return OS;
500 }
501 
502 template <> struct DenseMapInfo<ElementCount, void> {
503  static inline ElementCount getEmptyKey() {
504  return ElementCount::getScalable(~0U);
505  }
506  static inline ElementCount getTombstoneKey() {
507  return ElementCount::getFixed(~0U - 1);
508  }
509  static unsigned getHashValue(const ElementCount &EltCnt) {
510  unsigned HashVal = EltCnt.getKnownMinValue() * 37U;
511  if (EltCnt.isScalable())
512  return (HashVal - 1U);
513 
514  return HashVal;
515  }
516 
517  static bool isEqual(const ElementCount &LHS, const ElementCount &RHS) {
518  return LHS == RHS;
519  }
520 };
521 
522 } // end namespace llvm
523 
524 #endif // LLVM_SUPPORT_TYPESIZE_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::UnivariateLinearPolyBase
UnivariateLinearPolyBase is a base class for ElementCount and TypeSize.
Definition: TypeSize.h:165
llvm::NextPowerOf2
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
Definition: MathExtras.h:683
llvm::TypeSize::operator*
friend TypeSize operator*(const unsigned LHS, const TypeSize &RHS)
Definition: TypeSize.h:468
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::UnivariateLinearPolyBase::Value
ScalarTy Value
Definition: TypeSize.h:170
MathExtras.h
llvm::LinearPolyBase::Dimensions
static constexpr auto Dimensions
Definition: TypeSize.h:49
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:22
llvm::LinearPolyBase::LinearPolyBase
LinearPolyBase(ArrayRef< ScalarTy > Values)
Definition: TypeSize.h:57
llvm::LinearPolySize::isKnownGT
static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:334
llvm::ElementCount
Definition: TypeSize.h:385
llvm::TypeSize::getFixedSize
ScalarTy getFixedSize() const
Definition: TypeSize.h:425
llvm::UnivariateLinearPolyBase::Dimensions
static constexpr auto Dimensions
Definition: TypeSize.h:168
llvm::LinearPolySize::ScalableDim
@ ScalableDim
Definition: TypeSize.h:272
llvm::LinearPolySize::isKnownLE
static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:340
llvm::StackOffset::StackOffset
StackOffset()
Definition: TypeSize.h:140
llvm::TypeSize::TypeSize
TypeSize(const LinearPolySize< TypeSize > &V)
Definition: TypeSize.h:418
llvm::LinearPolySize::FixedDim
@ FixedDim
Definition: TypeSize.h:272
llvm::StackOffset::getFixed
ScalarTy getFixed() const
Definition: TypeSize.h:149
llvm::UnivariateLinearPolyBase::getWithDecrement
LeafTy getWithDecrement(ScalarTy RHS) const
Subtract RHS from the value at the univariate dimension.
Definition: TypeSize.h:243
llvm::UnivariateLinearPolyBase::operator+
friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:198
llvm::UnivariateLinearPolyBase< TypeSize >::ScalarTy
typename LinearPolyBaseTypeTraits< TypeSize >::ScalarTy ScalarTy
Definition: TypeSize.h:167
llvm::TypeSize::TypeSize
TypeSize(ScalarTy MinVal, bool IsScalable)
Definition: TypeSize.h:419
llvm::LinearPolyBase::operator+=
friend LeafTy & operator+=(LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:62
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::UnivariateLinearPolyBase::operator*=
friend LeafTy & operator*=(LeafTy &LHS, ScalarTy RHS)
Definition: TypeSize.h:193
llvm::LinearPolySize::isScalable
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:298
llvm::LinearPolySize::isKnownLT
static bool isKnownLT(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:328
llvm::lltok::equal
@ equal
Definition: LLToken.h:25
llvm::LinearPolyBase::operator-
friend std::enable_if_t< std::is_signed< U >::value, LeafTy > operator-(const LeafTy &LHS)
Definition: TypeSize.h:97
llvm::ElementCount::isScalar
bool isScalar() const
Counting predicates.
Definition: TypeSize.h:395
llvm::LinearPolyBase::operator-=
friend LeafTy & operator-=(LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:68
llvm::TypeSize::Scalable
static TypeSize Scalable(ScalarTy MinVal)
Definition: TypeSize.h:423
llvm::ElementCount::ElementCount
ElementCount(const LinearPolySize< ElementCount > &V)
Definition: TypeSize.h:389
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1592
llvm::LinearPolySize::get
static LeafTy get(ScalarTy MinVal, bool Scalable)
Definition: TypeSize.h:289
llvm::LinearPolyBase
LinearPolyBase describes a linear polynomial: c0 * scale0 + c1 * scale1 + ...
Definition: TypeSize.h:46
llvm::UnivariateLinearPolyBase::UnivariateLinearPolyBase
UnivariateLinearPolyBase(ScalarTy Val, unsigned UnivariateDim)
Definition: TypeSize.h:176
llvm::DenseMapInfo< ElementCount, void >::getTombstoneKey
static ElementCount getTombstoneKey()
Definition: TypeSize.h:506
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::TypeSize::operator*
friend TypeSize operator*(const TypeSize &LHS, const unsigned RHS)
Definition: TypeSize.h:459
llvm::LinearPolyBase::operator-
friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:85
llvm::TypeSize::operator*
friend TypeSize operator*(const TypeSize &LHS, const int64_t RHS)
Definition: TypeSize.h:462
llvm::TypeSize::Fixed
static TypeSize Fixed(ScalarTy MinVal)
Definition: TypeSize.h:422
llvm::UnivariateLinearPolyBase::operator!=
bool operator!=(const UnivariateLinearPolyBase &RHS) const
Definition: TypeSize.h:225
llvm::LinearPolySize::getNull
static LeafTy getNull()
Definition: TypeSize.h:293
llvm::LinearPolyBaseTypeTraits< StackOffset >::ScalarTy
int64_t ScalarTy
Definition: TypeSize.h:126
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::UnivariateLinearPolyBase::operator-=
friend LeafTy & operator-=(LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:187
llvm::UnivariateLinearPolyBase::getValue
ScalarTy getValue(unsigned Dim) const
Definition: TypeSize.h:232
llvm::StackOffset::getScalable
ScalarTy getScalable() const
Definition: TypeSize.h:150
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::LinearPolySize::getFixed
static LeafTy getFixed(ScalarTy MinVal)
Definition: TypeSize.h:283
llvm::LinearPolySize< TypeSize >::ScalarTy
typename UnivariateLinearPolyBase< TypeSize >::ScalarTy ScalarTy
Definition: TypeSize.h:271
llvm::DenseMapInfo< ElementCount, void >::getHashValue
static unsigned getHashValue(const ElementCount &EltCnt)
Definition: TypeSize.h:509
llvm::UnivariateLinearPolyBase::operator-
friend std::enable_if< std::is_signed< U >::value, LeafTy >::type operator-(const LeafTy &LHS)
Definition: TypeSize.h:215
llvm::TypeSize::operator*
friend TypeSize operator*(const int LHS, const TypeSize &RHS)
Definition: TypeSize.h:465
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
uint64_t
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::StackOffset::StackOffset
StackOffset(const LinearPolyBase< StackOffset > &Other)
Definition: TypeSize.h:141
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::StackOffset::getScalable
static StackOffset getScalable(ScalarTy Scalable)
Definition: TypeSize.h:144
ArrayRef.h
llvm::ElementCount::ElementCount
ElementCount()
Definition: TypeSize.h:387
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::LinearPolyBase::operator==
bool operator==(const LinearPolyBase &RHS) const
Definition: TypeSize.h:102
llvm::LinearPolyBase::operator+
friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:80
llvm::LinearPolySize::isKnownGE
static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:346
llvm::LinearPolyBase::operator!=
bool operator!=(const LinearPolyBase &RHS) const
Definition: TypeSize.h:107
llvm::LinearPolyBaseTypeTraits< ElementCount >::ScalarTy
unsigned ScalarTy
Definition: TypeSize.h:381
llvm::DenseMapInfo< ElementCount, void >::isEqual
static bool isEqual(const ElementCount &LHS, const ElementCount &RHS)
Definition: TypeSize.h:517
llvm::LinearPolySize::getKnownMinValue
ScalarTy getKnownMinValue() const
Returns the minimum value this size can represent.
Definition: TypeSize.h:296
llvm::ElementCount::isVector
bool isVector() const
One or more elements.
Definition: TypeSize.h:397
llvm::LinearPolySize::isKnownMultipleOf
bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
Definition: TypeSize.h:305
llvm::LinearPolySize::print
void print(raw_ostream &OS) const
Printing function.
Definition: TypeSize.h:372
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::TypeSize::operator*
friend TypeSize operator*(const uint64_t LHS, const TypeSize &RHS)
Definition: TypeSize.h:474
llvm::LinearPolySize::getFixedValue
ScalarTy getFixedValue() const
Definition: TypeSize.h:312
llvm::LinearPolyBase< StackOffset >::ScalarTy
typename LinearPolyBaseTypeTraits< StackOffset >::ScalarTy ScalarTy
Definition: TypeSize.h:48
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::UnivariateLinearPolyBase::UnivariateDim
unsigned UnivariateDim
Definition: TypeSize.h:174
llvm::UnivariateLinearPolyBase::getWithIncrement
LeafTy getWithIncrement(ScalarTy RHS) const
Add RHS to the value at the univariate dimension.
Definition: TypeSize.h:237
llvm::LinearPolySize
LinearPolySize is a base class to represent sizes.
Definition: TypeSize.h:264
llvm::StackOffset::getFixed
static StackOffset getFixed(ScalarTy Fixed)
Definition: TypeSize.h:143
llvm::UnivariateLinearPolyBase::operator*
friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS)
Definition: TypeSize.h:208
llvm::LinearPolyBase::getValue
ScalarTy getValue(unsigned Dim) const
Definition: TypeSize.h:117
llvm::LinearPolySize::isKnownEven
bool isKnownEven() const
A return value of true indicates we know at compile time that the number of elements (vscale * Min) i...
Definition: TypeSize.h:302
llvm::LinearPolyBaseTypeTraits
Definition: TypeSize.h:34
llvm::LinearPolySize::LinearPolySize
LinearPolySize(const UnivariateLinearPolyBase< LeafTy > &V)
Definition: TypeSize.h:278
llvm::UnivariateLinearPolyBase::operator-
friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:203
llvm::UnivariateLinearPolyBase::operator+=
friend LeafTy & operator+=(LeafTy &LHS, const LeafTy &RHS)
Definition: TypeSize.h:181
llvm::DenseMapInfo< ElementCount, void >::getEmptyKey
static ElementCount getEmptyKey()
Definition: TypeSize.h:503
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:151
llvm::TypeSize
Definition: TypeSize.h:416
llvm::LinearPolyBase::isZero
bool isZero() const
Definition: TypeSize.h:111
llvm::LinearPolySize::getScalable
static LeafTy getScalable(ScalarTy MinVal)
Definition: TypeSize.h:286
llvm::UnivariateLinearPolyBase::isZero
bool isZero() const
Definition: TypeSize.h:229
llvm::StackOffset::StackOffset
StackOffset(ScalarTy Fixed, ScalarTy Scalable)
Definition: TypeSize.h:136
llvm::UnivariateLinearPolyBase::operator==
bool operator==(const UnivariateLinearPolyBase &RHS) const
Definition: TypeSize.h:221
llvm::LinearPolySize::LinearPolySize
LinearPolySize(ScalarTy MinVal, Dims D)
Definition: TypeSize.h:275
llvm::LinearPolyBase::isNonZero
bool isNonZero() const
Definition: TypeSize.h:114
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::LinearPolyBase::operator*=
friend LeafTy & operator*=(LeafTy &LHS, ScalarTy RHS)
Definition: TypeSize.h:74
llvm::LinearPolyBase::operator*
friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS)
Definition: TypeSize.h:90
llvm::TypeSize::getKnownMinSize
ScalarTy getKnownMinSize() const
Definition: TypeSize.h:426
llvm::UnivariateLinearPolyBase::isNonZero
bool isNonZero() const
Definition: TypeSize.h:230
raw_ostream.h
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::LinearPolySize::divideCoefficientBy
LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
Definition: TypeSize.h:360
llvm::TypeSize::operator*
friend TypeSize operator*(const TypeSize &LHS, const int RHS)
Definition: TypeSize.h:456
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::TypeSize::operator*
friend TypeSize operator*(const int64_t LHS, const TypeSize &RHS)
Definition: TypeSize.h:471
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:152
llvm::LinearPolySize::coefficientNextPowerOf2
LeafTy coefficientNextPowerOf2() const
Definition: TypeSize.h:365
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1198
llvm::LinearPolySize::Dims
Dims
Definition: TypeSize.h:272
llvm::FloatStyle::Fixed
@ Fixed
llvm::reportInvalidSizeRequest
void reportInvalidSizeRequest(const char *Msg)
Reports a diagnostic message to indicate an invalid size request has been done on a scalable vector.
Definition: TypeSize.cpp:39
llvm::StackOffset::get
static StackOffset get(ScalarTy Fixed, ScalarTy Scalable)
Definition: TypeSize.h:145