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)) {}
310 return isFloat(FpSemantics::S_x87DoubleExtended);
313 return isFloat(FpSemantics::S_PPCDoubleDouble);
321 "Possible incorrect use of LLT::getNumElements() for "
322 "scalable vector. Scalable flag may be dropped, use "
323 "LLT::getElementCount() instead");
331 return getFieldValue(VectorScalableFieldInfo);
339 unsigned ScalarSize)
const {
349 assert(
isVector() &&
"cannot get number of elements on scalar/aggregate");
374 "cannot get FP info for non float type");
375 return FpSemantics(getFieldValue(FpSemanticFieldInfo));
397 "invalid to directly change element size for pointers");
415 "cannot change vector element count of non-vector type");
435 "cannot divide scalar of size zero and floats");
467 return getFieldValue(PointerSizeFieldInfo);
468 return getFieldValue(ScalarSizeFieldInfo);
473 "cannot get address space of non-pointer type");
474 return getFieldValue(PointerAddressSpaceFieldInfo);
479 assert(
isVector() &&
"cannot get element type of scalar/aggregate");
504#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
517 return Info ==
RHS.Info && RawData ==
RHS.RawData;
590 typedef int BitFieldInfo[2];
592 static constexpr BitFieldInfo VectorScalableFieldInfo{1, 0};
593 static constexpr BitFieldInfo VectorElementsFieldInfo{16, 4};
594 static constexpr BitFieldInfo FpSemanticFieldInfo{8, 20};
595 static constexpr BitFieldInfo PointerAddressSpaceFieldInfo{24, 20};
596 static constexpr BitFieldInfo ScalarSizeFieldInfo{32, 28};
597 static constexpr BitFieldInfo PointerSizeFieldInfo{16, 44};
599 uint64_t RawData : 60;
602 static constexpr uint64_t
getMask(
const BitFieldInfo FieldInfo) {
603 const int FieldSizeInBits = FieldInfo[0];
604 return (((uint64_t)1) << FieldSizeInBits) - 1;
606 static constexpr uint64_t maskAndShift(uint64_t Val, uint64_t Mask,
608 assert(Val <= Mask &&
"Value too large for field");
609 return (Val & Mask) << Shift;
611 static constexpr uint64_t maskAndShift(uint64_t Val,
612 const BitFieldInfo FieldInfo) {
613 return maskAndShift(Val,
getMask(FieldInfo), FieldInfo[1]);
616 constexpr uint64_t getFieldValue(
const BitFieldInfo FieldInfo)
const {
617 return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
621 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits) {
622 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
623 "Not enough bits in LLT to represent size");
626 "Called initializer for wrong LLT Kind");
628 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo);
631 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo) |
632 maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
633 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
638 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits,
640 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
641 "Not enough bits in LLT to represent size");
643 "Called initializer for wrong LLT Kind");
645 RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) |
646 maskAndShift(
AddressSpace, PointerAddressSpaceFieldInfo);
649 RawData |= maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
650 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
654 constexpr void init(
Kind Info, ElementCount EC, uint64_t SizeInBits,
656 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
657 "Not enough bits in LLT to represent size");
659 "Called initializer for wrong LLT Kind");
661 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo) |
662 maskAndShift((uint64_t)Sem, FpSemanticFieldInfo);
665 RawData |= maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
666 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
679 static bool ExtendedLLT;
699 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 isBFloat16() const
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
constexpr bool isX86FP80() 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.
constexpr bool isPPCF128() const
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...