26#ifndef LLVM_CODEGEN_LOWLEVELTYPE_H
27#define LLVM_CODEGEN_LOWLEVELTYPE_H
43 return LLT{
false,
false,
true,
50 assert(SizeInBits > 0 &&
"invalid pointer size");
51 return LLT{
true,
false,
false,
57 assert(!EC.isScalar() &&
"invalid number of vector elements");
58 return LLT{
false,
true,
false,
59 EC, ScalarSizeInBits, 0};
64 assert(!EC.isScalar() &&
"invalid number of vector elements");
93 unsigned ScalarSizeInBits) {
106 unsigned ScalarSizeInBits) {
117 return EC.isScalar() ? ScalarTy :
LLT::vector(EC, ScalarTy);
121 assert(ScalarSize <= std::numeric_limits<unsigned>::max() &&
122 "Not enough bits in LLT to represent size");
137 constexpr bool isValid()
const {
return IsScalar || RawData != 0; }
139 constexpr bool isScalar()
const {
return IsScalar; }
142 return isValid() && IsPointer && !IsVector;
152 "Possible incorrect use of LLT::getNumElements() for "
153 "scalable vector. Scalable flag may be dropped, use "
154 "LLT::getElementCount() instead");
162 return IsPointer ? getFieldValue(PointerVectorScalableFieldInfo)
163 : getFieldValue(VectorScalableFieldInfo);
175 assert(IsVector &&
"cannot get number of elements on scalar/aggregate");
177 ? getFieldValue(PointerVectorElementsFieldInfo)
178 : getFieldValue(VectorElementsFieldInfo),
213 "invalid to directly change element size for pointers");
230 "cannot divide scalar of size zero");
259 return getFieldValue(ScalarSizeFieldInfo);
262 return getFieldValue(VectorSizeFieldInfo);
264 return getFieldValue(PointerVectorSizeFieldInfo);
266 assert(IsPointer &&
"unexpected LLT");
267 return getFieldValue(PointerSizeFieldInfo);
271 assert(RawData != 0 &&
"Invalid Type");
272 assert(IsPointer &&
"cannot get address space of non-pointer type");
274 return getFieldValue(PointerAddressSpaceFieldInfo);
276 return getFieldValue(PointerVectorAddressSpaceFieldInfo);
281 assert(
isVector() &&
"cannot get element type of scalar/aggregate");
290#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
295 return IsPointer ==
RHS.IsPointer && IsVector ==
RHS.IsVector &&
296 IsScalar ==
RHS.IsScalar &&
RHS.RawData == RawData;
315 typedef int BitFieldInfo[2];
323 static const constexpr BitFieldInfo ScalarSizeFieldInfo{32, 0};
327 static const constexpr BitFieldInfo PointerSizeFieldInfo{16, 0};
328 static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{
329 24, PointerSizeFieldInfo[0] + PointerSizeFieldInfo[1]};
330 static_assert((PointerAddressSpaceFieldInfo[0] +
331 PointerAddressSpaceFieldInfo[1]) <= 61,
332 "Insufficient bits to encode all data");
337 static const constexpr BitFieldInfo VectorElementsFieldInfo{16, 0};
338 static const constexpr BitFieldInfo VectorSizeFieldInfo{
339 32, VectorElementsFieldInfo[0] + VectorElementsFieldInfo[1]};
340 static const constexpr BitFieldInfo VectorScalableFieldInfo{
341 1, VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]};
342 static_assert((VectorSizeFieldInfo[0] + VectorSizeFieldInfo[1]) <= 61,
343 "Insufficient bits to encode all data");
349 static const constexpr BitFieldInfo PointerVectorElementsFieldInfo{16, 0};
350 static const constexpr BitFieldInfo PointerVectorSizeFieldInfo{
352 PointerVectorElementsFieldInfo[1] + PointerVectorElementsFieldInfo[0]};
353 static const constexpr BitFieldInfo PointerVectorAddressSpaceFieldInfo{
354 24, PointerVectorSizeFieldInfo[1] + PointerVectorSizeFieldInfo[0]};
355 static const constexpr BitFieldInfo PointerVectorScalableFieldInfo{
356 1, PointerVectorAddressSpaceFieldInfo[0] +
357 PointerVectorAddressSpaceFieldInfo[1]};
358 static_assert((PointerVectorAddressSpaceFieldInfo[0] +
359 PointerVectorAddressSpaceFieldInfo[1]) <= 61,
360 "Insufficient bits to encode all data");
367 static constexpr uint64_t getMask(
const BitFieldInfo FieldInfo) {
368 const int FieldSizeInBits = FieldInfo[0];
369 return (((
uint64_t)1) << FieldSizeInBits) - 1;
373 assert(Val <= Mask &&
"Value too large for field");
374 return (Val & Mask) << Shift;
377 const BitFieldInfo FieldInfo) {
378 return maskAndShift(Val, getMask(FieldInfo), FieldInfo[1]);
381 constexpr uint64_t getFieldValue(
const BitFieldInfo FieldInfo)
const {
382 return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
385 constexpr void init(
bool IsPointer,
bool IsVector,
bool IsScalar,
386 ElementCount EC,
uint64_t SizeInBits,
388 assert(SizeInBits <= std::numeric_limits<unsigned>::max() &&
389 "Not enough bits in LLT to represent size");
391 this->IsVector = IsVector;
392 this->IsScalar = IsScalar;
394 RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo);
396 assert(
EC.isVector() &&
"invalid number of vector elements");
399 maskAndShift(
EC.getKnownMinValue(), VectorElementsFieldInfo) |
400 maskAndShift(SizeInBits, VectorSizeFieldInfo) |
401 maskAndShift(
EC.isScalable() ? 1 : 0, VectorScalableFieldInfo);
404 maskAndShift(
EC.getKnownMinValue(),
405 PointerVectorElementsFieldInfo) |
406 maskAndShift(SizeInBits, PointerVectorSizeFieldInfo) |
407 maskAndShift(
AddressSpace, PointerVectorAddressSpaceFieldInfo) |
408 maskAndShift(
EC.isScalable() ? 1 : 0,
409 PointerVectorScalableFieldInfo);
410 }
else if (IsPointer)
411 RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) |
412 maskAndShift(
AddressSpace, PointerAddressSpaceFieldInfo);
#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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
void print(raw_ostream &OS) const
constexpr bool isScalableVector() const
Returns true if the LLT is a scalable vector.
static constexpr LLT scalarOrVector(ElementCount EC, uint64_t ScalarSize)
constexpr unsigned getScalarSizeInBits() const
constexpr LLT(bool isPointer, bool isVector, bool isScalar, ElementCount EC, uint64_t SizeInBits, unsigned AddressSpace)
constexpr bool isScalar() 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 bool operator==(const LLT &RHS) const
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.
constexpr LLT multiplyElements(int Factor) const
Produce a vector type that is Factor times bigger, preserving the element type.
static constexpr LLT vector(ElementCount EC, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
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 operator!=(const LLT &RHS) const
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
constexpr TypeSize getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
constexpr bool isPointer() const
constexpr LLT getElementType() const
Returns the vector's element type. Only valid for vector types.
static constexpr LLT vector(ElementCount EC, LLT ScalarTy)
Get a low-level vector of some number of elements and element type.
constexpr ElementCount getElementCount() const
constexpr 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 LLT fixed_vector(unsigned NumElements, LLT ScalarTy)
Get a low-level fixed-width vector of some number of elements and element type.
static constexpr LLT float16()
Get a 16-bit IEEE half value.
constexpr unsigned getAddressSpace() 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 isFixedVector() const
Returns true if the LLT is a fixed vector.
constexpr LLT changeElementCount(ElementCount EC) const
Return a vector or scalar with the same element type and the new element count.
LLVM_DUMP_METHOD void dump() const
constexpr LLT getScalarType() const
constexpr TypeSize getSizeInBytes() const
Returns the total size of the type in bytes, i.e.
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)
static constexpr LLT float32()
Get a 32-bit IEEE float value.
constexpr LLT divide(int Factor) const
Return a type that is Factor times smaller.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
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.
void reportInvalidSizeRequest(const char *Msg)
Reports a diagnostic message to indicate an invalid size request has been done on a scalable vector.
@ Invalid
Denotes invalid value.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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...