28#ifndef LLVM_CODEGEN_LOWLEVELTYPE_H
29#define LLVM_CODEGEN_LOWLEVELTYPE_H
116 assert(SizeInBits > 0 &&
"invalid pointer size");
123 assert(!EC.isScalar() &&
"invalid number of vector elements");
129 assert(!EC.isScalar() &&
"invalid number of vector elements");
148 switch (SizeInBits) {
165 FpSemantics::S_BFloat};
170 FpSemantics::S_IEEEhalf};
175 FpSemantics::S_IEEEsingle};
180 FpSemantics::S_IEEEdouble};
186 FpSemantics::S_x87DoubleExtended};
192 FpSemantics::S_IEEEquad};
198 FpSemantics::S_PPCDoubleDouble};
204 unsigned ScalarSizeInBits) {
218 unsigned ScalarSizeInBits) {
230 return EC.isScalar() ? ScalarTy :
LLT::vector(EC, ScalarTy);
234 assert(ScalarSize <= std::numeric_limits<unsigned>::max() &&
235 "Not enough bits in LLT to represent size");
241 init(Info, EC, SizeInBits);
253 init(Info, EC, SizeInBits, Sem);
257 explicit constexpr LLT() : RawData(0), Info(static_cast<
Kind>(0)) {}
332 return isFloat(FpSemantics::S_BFloat);
337 return isFloat(FpSemantics::S_x87DoubleExtended);
342 return isFloat(FpSemantics::S_PPCDoubleDouble);
350 "Possible incorrect use of LLT::getNumElements() for "
351 "scalable vector. Scalable flag may be dropped, use "
352 "LLT::getElementCount() instead");
360 return getFieldValue(VectorScalableFieldInfo);
368 unsigned ScalarSize)
const {
378 assert(
isVector() &&
"cannot get number of elements on scalar/aggregate");
403 "cannot get FP info for non float type");
404 return FpSemantics(getFieldValue(FpSemanticFieldInfo));
426 "invalid to directly change element size for pointers");
444 "cannot change vector element count of non-vector type");
464 "cannot divide scalar of size zero and floats");
496 return getFieldValue(PointerSizeFieldInfo);
497 return getFieldValue(ScalarSizeFieldInfo);
502 "cannot get address space of non-pointer type");
503 return getFieldValue(PointerAddressSpaceFieldInfo);
508 assert(
isVector() &&
"cannot get element type of scalar/aggregate");
533#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
546 return Info ==
RHS.Info && RawData ==
RHS.RawData;
619 typedef int BitFieldInfo[2];
621 static constexpr BitFieldInfo VectorScalableFieldInfo{1, 0};
622 static constexpr BitFieldInfo VectorElementsFieldInfo{16, 4};
623 static constexpr BitFieldInfo FpSemanticFieldInfo{8, 20};
624 static constexpr BitFieldInfo PointerAddressSpaceFieldInfo{24, 20};
625 static constexpr BitFieldInfo ScalarSizeFieldInfo{32, 28};
626 static constexpr BitFieldInfo PointerSizeFieldInfo{16, 44};
628 uint64_t RawData : 60;
631 static constexpr uint64_t
getMask(
const BitFieldInfo FieldInfo) {
632 const int FieldSizeInBits = FieldInfo[0];
633 return (((uint64_t)1) << FieldSizeInBits) - 1;
635 static constexpr uint64_t maskAndShift(uint64_t Val, uint64_t Mask,
637 assert(Val <= Mask &&
"Value too large for field");
638 return (Val & Mask) << Shift;
640 static constexpr uint64_t maskAndShift(uint64_t Val,
641 const BitFieldInfo FieldInfo) {
642 return maskAndShift(Val,
getMask(FieldInfo), FieldInfo[1]);
645 constexpr uint64_t getFieldValue(
const BitFieldInfo FieldInfo)
const {
646 return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
650 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits) {
651 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
652 "Not enough bits in LLT to represent size");
655 "Called initializer for wrong LLT Kind");
657 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo);
660 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo) |
661 maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
662 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
667 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits,
669 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
670 "Not enough bits in LLT to represent size");
672 "Called initializer for wrong LLT Kind");
674 RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) |
675 maskAndShift(
AddressSpace, PointerAddressSpaceFieldInfo);
678 RawData |= maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
679 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
683 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits,
685 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
686 "Not enough bits in LLT to represent size");
688 "Called initializer for wrong LLT Kind");
690 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo) |
691 maskAndShift((uint64_t)Sem, FpSemanticFieldInfo);
694 RawData |= maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
695 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
708 static bool ExtendedLLT;
728 uint64_t Val = Ty.getUniqueRAWLLTData();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines DenseMapInfo traits for DenseMap.
static std::pair< Value *, APInt > getMask(Value *WideMask, unsigned Factor, ElementCount LeafValueEC)
This file implements the C++20 <bit> header.
static LLVM_ABI const llvm::fltSemantics & EnumToSemantics(Semantics S)
static LLVM_ABI unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
static constexpr ElementCount getScalable(ScalarTy MinVal)
static constexpr ElementCount getFixed(ScalarTy MinVal)
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
static constexpr LLT float64()
Get a 64-bit IEEE double value.
constexpr bool isFloatVector() const
LLT changeElementCount(ElementCount EC) const
Return a vector or scalar with the same element type and the new element count.
static constexpr Kind toVector(Kind Ty)
constexpr LLT(Kind Info, ElementCount EC, uint64_t SizeInBits, FpSemantics Sem)
LLVM_ABI void print(raw_ostream &OS) const
static constexpr LLT x86fp80()
Get a 80-bit X86 floating point value.
constexpr bool isScalableVector() const
Returns true if the LLT is a scalable vector.
constexpr bool isFixedVector(unsigned NumElements, unsigned ScalarSize) const
static constexpr LLT scalarOrVector(ElementCount EC, uint64_t ScalarSize)
bool operator==(const LLT &RHS) const
constexpr unsigned getScalarSizeInBits() const
static bool getUseExtended()
constexpr bool isScalar() const
constexpr bool isAnyVector() const
static constexpr LLT scalable_vector(unsigned MinNumElements, unsigned ScalarSizeInBits)
Get a low-level scalable vector of some number of elements and element width.
constexpr Kind getKind() const
LLT multiplyElements(int Factor) const
Produce a vector type that is Factor times bigger, preserving the element type.
APFloat::Semantics FpSemantics
constexpr LLT changeElementType(LLT NewEltTy) const
If this type is a vector, return a vector with the same number of elements but the new element type.
static constexpr LLT vector(ElementCount EC, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
LLT getScalarType() const
constexpr bool isPointerVector() const
constexpr bool isInteger() const
static void setUseExtended(bool Enable)
constexpr bool isIntegerVector() const
constexpr FpSemantics getFpSemantics() const
bool operator!=(const LLT &RHS) const
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
constexpr bool isValid() const
constexpr uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
constexpr bool isFloat() const
friend class GISelInstProfileBuilder
constexpr bool isToken() const
static constexpr LLT float128()
Get a 128-bit IEEE quad value.
constexpr bool isVector() const
static constexpr LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
constexpr bool isScalable() const
Returns true if the LLT is a scalable vector.
constexpr uint64_t getUniqueRAWLLTData() const
constexpr bool isByteSized() const
LLT changeToInteger() const
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
constexpr bool isFloat(FpSemantics Sem) const
constexpr bool isPointer() const
constexpr bool isAnyScalar() const
static constexpr LLT vector(ElementCount EC, LLT ScalarTy)
Get a low-level vector of some number of elements and element type.
constexpr bool isInteger(unsigned Size) const
static constexpr LLT ppcf128()
Get a 128-bit PowerPC double double value.
constexpr ElementCount getElementCount() const
static constexpr LLT fixed_vector(unsigned NumElements, LLT ScalarTy)
Get a low-level fixed-width vector of some number of elements and element type.
LLT divide(int Factor) const
Return a type that is Factor times smaller.
static constexpr Kind toScalar(Kind Ty)
static constexpr LLT float16()
Get a 16-bit IEEE half value.
constexpr unsigned getAddressSpace() const
constexpr bool isFloat(unsigned Size) const
static constexpr LLT fixed_vector(unsigned NumElements, unsigned ScalarSizeInBits)
Get a low-level fixed-width vector of some number of elements and element width.
constexpr bool isPointerOrPointerVector() const
constexpr bool isFixedVector() const
Returns true if the LLT is a fixed vector.
static constexpr LLT token()
Get a low-level token; just a scalar with zero bits (or no size).
constexpr LLT(Kind Info, ElementCount EC, uint64_t SizeInBits, unsigned AddressSpace)
static LLT integer(unsigned SizeInBits)
constexpr LLT(Kind Info, ElementCount EC, uint64_t SizeInBits)
LLVM_DUMP_METHOD void dump() const
constexpr bool isFloatIEEE() const
static constexpr LLT bfloat16()
LLT changeElementCount(unsigned NumElements) const
constexpr LLT changeVectorElementType(LLT NewEltTy) const
Returns a vector with the same number of elements but the new element type.
constexpr TypeSize getSizeInBytes() const
Returns the total size of the type in bytes, i.e.
LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
static constexpr LLT scalable_vector(unsigned MinNumElements, LLT ScalarTy)
Get a low-level scalable vector of some number of elements and element type.
static constexpr LLT scalarOrVector(ElementCount EC, LLT ScalarTy)
constexpr bool isScalar(unsigned Size) const
LLT changeVectorElementCount(ElementCount EC) const
Return a vector with the same element type and the new element count.
static constexpr LLT float32()
Get a 32-bit IEEE float value.
static LLT floatIEEE(unsigned SizeInBits)
static LLT floatingPoint(const FpSemantics &Sem)
LLT changeElementSize(unsigned NewEltSize) const
If this type is a vector, return a vector with the same number of elements but the new element size.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
constexpr bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
constexpr int bit_width_constexpr(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
static LLT getTombstoneKey()
static bool isEqual(const LLT &LHS, const LLT &RHS)
static unsigned getHashValue(const LLT &Ty)
An information struct used to provide DenseMap with the various necessary components for a given valu...