Go to the documentation of this file.
15 #ifndef LLVM_SUPPORT_TYPESIZE_H
16 #define LLVM_SUPPORT_TYPESIZE_H
26 #include <type_traits>
45 template <
typename LeafTy>
51 "Dimensions out of range");
54 std::array<ScalarTy, Dimensions> Coefficients;
64 LHS.Coefficients[
I] +=
RHS.Coefficients[
I];
70 LHS.Coefficients[
I] -=
RHS.Coefficients[
I];
75 for (
auto &
C :
LHS.Coefficients)
95 template <
typename U = ScalarTy>
96 friend typename std::enable_if_t<std::is_signed<U>::value, LeafTy>
103 return std::equal(Coefficients.begin(), Coefficients.end(),
104 RHS.Coefficients.begin());
108 return !(*
this ==
RHS);
127 static constexpr
unsigned Dimensions = 2;
146 return {
Fixed, Scalable};
164 template <
typename LeafTy>
170 "Dimensions out of range");
182 assert(
LHS.UnivariateDim ==
RHS.UnivariateDim &&
"Invalid dimensions");
188 assert(
LHS.UnivariateDim ==
RHS.UnivariateDim &&
"Invalid dimensions");
213 template <
typename U = ScalarTy>
214 friend typename std::enable_if<std::is_signed<U>::value, LeafTy>
::type
226 return !(*
this ==
RHS);
238 return static_cast<LeafTy
>(
244 return static_cast<LeafTy
>(
263 template <
typename LeafTy>
290 return static_cast<LeafTy
>(
314 "Request for a fixed element count on a scalable object");
329 if (!
LHS.isScalable() ||
RHS.isScalable())
330 return LHS.getKnownMinValue() <
RHS.getKnownMinValue();
335 if (
LHS.isScalable() || !
RHS.isScalable())
336 return LHS.getKnownMinValue() >
RHS.getKnownMinValue();
341 if (!
LHS.isScalable() ||
RHS.isScalable())
342 return LHS.getKnownMinValue() <=
RHS.getKnownMinValue();
347 if (
LHS.isScalable() || !
RHS.isScalable())
348 return LHS.getKnownMinValue() >=
RHS.getKnownMinValue();
361 return static_cast<LeafTy
>(
366 return static_cast<LeafTy
>(
401 static constexpr
unsigned Dimensions = 2;
426 static constexpr
unsigned Dimensions = 2;
514 template <
typename LeafTy>
531 return (HashVal - 1U);
543 #endif // LLVM_SUPPORT_TYPESIZE_H
UnivariateLinearPolyBase is a base class for ElementCount and TypeSize.
friend TypeSize operator*(const unsigned LHS, const TypeSize &RHS)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
static constexpr auto Dimensions
This is an optimization pass for GlobalISel generic memory operations.
LinearPolyBase(ArrayRef< ScalarTy > Values)
static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS)
ScalarTy getKnownScalarFactor(const LinearPolySize &RHS) const
Returns a value X where RHS.multiplyCoefficientBy(X) will result in a value whose size matches our ow...
ScalarTy getFixedSize() const
static constexpr auto Dimensions
static bool isKnownLE(const LinearPolySize &LHS, const LinearPolySize &RHS)
TypeSize(const LinearPolySize< TypeSize > &V)
ScalarTy getFixed() const
LeafTy getWithDecrement(ScalarTy RHS) const
Subtract RHS from the value at the univariate dimension.
friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS)
typename LinearPolyBaseTypeTraits< TypeSize >::ScalarTy ScalarTy
TypeSize(ScalarTy MinVal, bool IsScalable)
friend LeafTy & operator+=(LeafTy &LHS, const LeafTy &RHS)
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
friend LeafTy & operator*=(LeafTy &LHS, ScalarTy RHS)
bool isScalable() const
Returns whether the size is scaled by a runtime quantity (vscale).
static bool isKnownLT(const LinearPolySize &LHS, const LinearPolySize &RHS)
friend std::enable_if_t< std::is_signed< U >::value, LeafTy > operator-(const LeafTy &LHS)
bool isScalar() const
Counting predicates.
friend LeafTy & operator-=(LeafTy &LHS, const LeafTy &RHS)
static TypeSize Scalable(ScalarTy MinVal)
ElementCount(const LinearPolySize< ElementCount > &V)
bool hasKnownScalarFactor(const LinearPolySize &RHS) const
Returns true if there exists a value X where RHS.multiplyCoefficientBy(X) will result in a value whos...
An information struct used to provide DenseMap with the various necessary components for a given valu...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static LeafTy get(ScalarTy MinVal, bool Scalable)
LinearPolyBase describes a linear polynomial: c0 * scale0 + c1 * scale1 + ...
UnivariateLinearPolyBase(ScalarTy Val, unsigned UnivariateDim)
static ElementCount getTombstoneKey()
(vector float) vec_cmpeq(*A, *B) C
friend TypeSize operator*(const TypeSize &LHS, const unsigned RHS)
friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS)
friend TypeSize operator*(const TypeSize &LHS, const int64_t RHS)
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
static TypeSize Fixed(ScalarTy MinVal)
bool operator!=(const UnivariateLinearPolyBase &RHS) const
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
friend LeafTy & operator-=(LeafTy &LHS, const LeafTy &RHS)
ScalarTy getValue(unsigned Dim) const
ScalarTy getScalable() const
This struct is a compact representation of a valid (non-zero power of two) alignment.
static LeafTy getFixed(ScalarTy MinVal)
typename UnivariateLinearPolyBase< TypeSize >::ScalarTy ScalarTy
static unsigned getHashValue(const ElementCount &EltCnt)
friend std::enable_if< std::is_signed< U >::value, LeafTy >::type operator-(const LeafTy &LHS)
friend TypeSize operator*(const int LHS, const TypeSize &RHS)
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
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
StackOffset(const LinearPolyBase< StackOffset > &Other)
LeafTy multiplyCoefficientBy(ScalarTy RHS) const
static StackOffset getScalable(ScalarTy Scalable)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(const LinearPolyBase &RHS) const
friend LeafTy operator+(const LeafTy &LHS, const LeafTy &RHS)
static bool isKnownGE(const LinearPolySize &LHS, const LinearPolySize &RHS)
bool operator!=(const LinearPolyBase &RHS) const
static bool isEqual(const ElementCount &LHS, const ElementCount &RHS)
ScalarTy getKnownMinValue() const
Returns the minimum value this size can represent.
bool isVector() const
One or more elements.
bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
void print(raw_ostream &OS) const
Printing function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
friend TypeSize operator*(const uint64_t LHS, const TypeSize &RHS)
ScalarTy getFixedValue() const
typename LinearPolyBaseTypeTraits< StackOffset >::ScalarTy ScalarTy
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
LeafTy getWithIncrement(ScalarTy RHS) const
Add RHS to the value at the univariate dimension.
LinearPolySize is a base class to represent sizes.
static StackOffset getFixed(ScalarTy Fixed)
friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS)
ScalarTy getValue(unsigned Dim) const
const CustomOperand< const MCSubtargetInfo & > Msg[]
bool isKnownEven() const
A return value of true indicates we know at compile time that the number of elements (vscale * Min) i...
LinearPolySize(const UnivariateLinearPolyBase< LeafTy > &V)
friend LeafTy operator-(const LeafTy &LHS, const LeafTy &RHS)
friend LeafTy & operator+=(LeafTy &LHS, const LeafTy &RHS)
static ElementCount getEmptyKey()
static LeafTy getScalable(ScalarTy MinVal)
StackOffset(ScalarTy Fixed, ScalarTy Scalable)
bool operator==(const UnivariateLinearPolyBase &RHS) const
LinearPolySize(ScalarTy MinVal, Dims D)
friend LeafTy & operator*=(LeafTy &LHS, ScalarTy RHS)
friend LeafTy operator*(const LeafTy &LHS, ScalarTy RHS)
ScalarTy getKnownMinSize() const
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
LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
friend TypeSize operator*(const TypeSize &LHS, const int RHS)
LLVM Value Representation.
friend TypeSize operator*(const int64_t LHS, const TypeSize &RHS)
LeafTy coefficientNextPowerOf2() const
Optional< std::vector< StOtherPiece > > Other
void reportInvalidSizeRequest(const char *Msg)
Reports a diagnostic message to indicate an invalid size request has been done on a scalable vector.
static StackOffset get(ScalarTy Fixed, ScalarTy Scalable)