switch (operand_type->getTypeID()) {
default:
break;
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
LLDB_LOGF(log, "Unsupported operand type: %s",
PrintType(operand_type).c_str());
error.SetErrorString(unsupported_operand_error);
LLVMStructTypeKind, /**< Structures */
LLVMArrayTypeKind, /**< Arrays */
LLVMPointerTypeKind, /**< Pointers */
- LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
LLVMMetadataTypeKind, /**< Metadata */
LLVMX86_MMXTypeKind, /**< X86 MMX */
- LLVMTokenTypeKind /**< Tokens */
+ LLVMTokenTypeKind, /**< Tokens */
+ LLVMFixedVectorTypeKind, /**< Fixed width SIMD vector type */
+ LLVMScalableVectorTypeKind /**< Scalable SIMD vector type */
} LLVMTypeKind;
typedef enum {
// only 80 bits contain information.
case Type::X86_FP80TyID:
return TypeSize::Fixed(80);
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty);
auto EltCnt = VTy->getElementCount();
uint64_t MinBits = EltCnt.Min *
return cast<ArrayType>(this)->getNumElements();
}
-/// Class to represent vector types.
+/// Base class of all SIMD vector types
class VectorType : public Type {
/// A fully specified VectorType is of the form <vscale x n x Ty>. 'n' is the
/// minimum number of elements of type Ty contained within the vector, and
/// The element type of the vector.
Type *ContainedType;
- /// Minumum number of elements in the vector.
- uint64_t NumElements;
- VectorType(Type *ElType, unsigned NumEl, bool Scalable = false);
- VectorType(Type *ElType, ElementCount EC);
+ /// The element count of this vector
+ ElementCount EC;
- // If true, the total number of elements is an unknown multiple of the
- // minimum 'NumElements'. Otherwise the total number of elements is exactly
- // equal to 'NumElements'.
- bool Scalable;
+protected:
+ VectorType(Type *ElType, ElementCount EC, Type::TypeID TID);
public:
VectorType(const VectorType &) = delete;
VectorType &operator=(const VectorType &) = delete;
- /// For scalable vectors, this will return the minimum number of elements
- /// in the vector.
- unsigned getNumElements() const { return NumElements; }
+ /// Get the number of elements in this vector. It does not make sense to call
+ /// this function on a scalable vector, and this will be moved into
+ /// FixedVectorType in a future commit
+ unsigned getNumElements() const { return EC.Min; }
+
Type *getElementType() const { return ContainedType; }
/// This static method is the primary way to construct an VectorType.
return VectorType::get(ElementType, {NumElements, Scalable});
}
+ static VectorType *get(Type *ElementType, const VectorType *Other) {
+ return VectorType::get(ElementType, Other->getElementCount());
+ }
+
/// This static method gets a VectorType with the same number of elements as
/// the input type, and the element type is an integer type of the same width
/// as the input element type.
/// Return an ElementCount instance to represent the (possibly scalable)
/// number of elements in the vector.
- ElementCount getElementCount() const {
- uint64_t MinimumEltCnt = getNumElements();
- assert(MinimumEltCnt <= UINT_MAX && "Too many elements in vector");
- return { (unsigned)MinimumEltCnt, Scalable };
- }
+ ElementCount getElementCount() const { return EC; }
/// Returns whether or not this is a scalable vector (meaning the total
/// element count is a multiple of the minimum).
- bool isScalable() const {
- return Scalable;
- }
+ bool isScalable() const { return EC.Scalable; }
/// Methods for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Type *T) {
- return T->getTypeID() == VectorTyID;
+ return T->getTypeID() == FixedVectorTyID ||
+ T->getTypeID() == ScalableVectorTyID;
}
};
bool Type::isVectorTy() const { return isa<VectorType>(this); }
+/// Class to represent fixed width SIMD vectors
+class FixedVectorType : public VectorType {
+protected:
+ FixedVectorType(Type *ElTy, unsigned NumElts)
+ : VectorType(ElTy, {NumElts, false}, FixedVectorTyID) {}
+
+public:
+ static FixedVectorType *get(Type *ElementType, unsigned NumElts);
+
+ static bool classof(const Type *T) {
+ return T->getTypeID() == FixedVectorTyID;
+ }
+};
+
+/// Class to represent scalable SIMD vectors
+class ScalableVectorType : public VectorType {
+protected:
+ ScalableVectorType(Type *ElTy, unsigned MinNumElts)
+ : VectorType(ElTy, {MinNumElts, true}, ScalableVectorTyID) {}
+
+public:
+ static ScalableVectorType *get(Type *ElementType, unsigned MinNumElts);
+
+ /// Get the minimum number of elements in this vector. The actual number of
+ /// elements in the vector is an integer multiple of this value.
+ uint64_t getMinNumElements() const { return getElementCount().Min; }
+
+ static bool classof(const Type *T) {
+ return T->getTypeID() == ScalableVectorTyID;
+ }
+};
+
/// Class to represent pointers.
class PointerType : public Type {
explicit PointerType(Type *ElType, unsigned AddrSpace);
///
enum TypeID {
// PrimitiveTypes - make sure LastPrimitiveTyID stays up to date.
- VoidTyID = 0, ///< 0: type with no size
- HalfTyID, ///< 1: 16-bit floating point type
- FloatTyID, ///< 2: 32-bit floating point type
- DoubleTyID, ///< 3: 64-bit floating point type
- X86_FP80TyID, ///< 4: 80-bit floating point type (X87)
- FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa)
- PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC)
- LabelTyID, ///< 7: Labels
- MetadataTyID, ///< 8: Metadata
- X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific)
- TokenTyID, ///< 10: Tokens
+ VoidTyID = 0, ///< 0: type with no size
+ HalfTyID, ///< 1: 16-bit floating point type
+ FloatTyID, ///< 2: 32-bit floating point type
+ DoubleTyID, ///< 3: 64-bit floating point type
+ X86_FP80TyID, ///< 4: 80-bit floating point type (X87)
+ FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa)
+ PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC)
+ LabelTyID, ///< 7: Labels
+ MetadataTyID, ///< 8: Metadata
+ X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific)
+ TokenTyID, ///< 10: Tokens
// Derived types... see DerivedTypes.h file.
// Make sure FirstDerivedTyID stays up to date!
- IntegerTyID, ///< 11: Arbitrary bit width integers
- FunctionTyID, ///< 12: Functions
- StructTyID, ///< 13: Structures
- ArrayTyID, ///< 14: Arrays
- PointerTyID, ///< 15: Pointers
- VectorTyID ///< 16: SIMD 'packed' format, or other vector type
+ IntegerTyID, ///< 11: Arbitrary bit width integers
+ FunctionTyID, ///< 12: Functions
+ StructTyID, ///< 13: Structures
+ ArrayTyID, ///< 14: Arrays
+ PointerTyID, ///< 15: Pointers
+ FixedVectorTyID, ///< 16: Fixed width SIMD vector type
+ ScalableVectorTyID ///< 17: Scalable SIMD vector type
};
private:
return true;
// If it is not something that can have a size (e.g. a function or label),
// it doesn't have a size.
- if (getTypeID() != StructTyID && getTypeID() != ArrayTyID &&
- getTypeID() != VectorTyID)
+ if (getTypeID() != StructTyID && getTypeID() != ArrayTyID && !isVectorTy())
return false;
// Otherwise we have to try harder to decide.
return isSizedDerivedType(Visited);
AbbrevToUse = ArrayAbbrev;
break;
}
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
VectorType *VT = cast<VectorType>(T);
// VECTOR [numelts, eltty] or
// [numelts, eltty, scalable]
case Type::FP128TyID: return MVT(MVT::f128);
case Type::PPC_FP128TyID: return MVT(MVT::ppcf128);
case Type::PointerTyID: return MVT(MVT::iPTR);
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty);
return getVectorVT(
getVT(VTy->getElementType(), /*HandleUnknown=*/ false),
return MVT::getVT(Ty, HandleUnknown);
case Type::IntegerTyID:
return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty);
return getVectorVT(Ty->getContext(),
getEVT(VTy->getElementType(), /*HandleUnknown=*/ false),
}
}
break;
- case Type::VectorTyID:
- // if the whole vector is 'undef' just reserve memory for the value.
- auto* VTy = cast<VectorType>(C->getType());
- Type *ElemTy = VTy->getElementType();
- unsigned int elemNum = VTy->getNumElements();
- Result.AggregateVal.resize(elemNum);
- if (ElemTy->isIntegerTy())
- for (unsigned int i = 0; i < elemNum; ++i)
- Result.AggregateVal[i].IntVal =
- APInt(ElemTy->getPrimitiveSizeInBits(), 0);
- break;
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
+ // if the whole vector is 'undef' just reserve memory for the value.
+ auto *VTy = cast<VectorType>(C->getType());
+ Type *ElemTy = VTy->getElementType();
+ unsigned int elemNum = VTy->getNumElements();
+ Result.AggregateVal.resize(elemNum);
+ if (ElemTy->isIntegerTy())
+ for (unsigned int i = 0; i < elemNum; ++i)
+ Result.AggregateVal[i].IntVal =
+ APInt(ElemTy->getPrimitiveSizeInBits(), 0);
+ break;
}
return Result;
}
else
llvm_unreachable("Unknown constant pointer type!");
break;
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
unsigned elemNum;
Type* ElemTy;
const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C);
break;
}
llvm_unreachable("Unknown constant pointer type!");
- }
- break;
+ } break;
default:
SmallString<256> Msg;
*((PointerTy*)Ptr) = Val.PointerVal;
break;
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
for (unsigned i = 0; i < Val.AggregateVal.size(); ++i) {
if (cast<VectorType>(Ty)->getElementType()->isDoubleTy())
*(((double*)Ptr)+i) = Val.AggregateVal[i].DoubleVal;
Result.IntVal = APInt(80, y);
break;
}
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
auto *VT = cast<VectorType>(Ty);
Type *ElemT = VT->getElementType();
const unsigned numElems = VT->getNumElements();
Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \
break;
-#define IMPLEMENT_VECTOR_INTEGER_ICMP(OP, TY) \
- case Type::VectorTyID: { \
- assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \
- Dest.AggregateVal.resize( Src1.AggregateVal.size() ); \
- for( uint32_t _i=0;_i<Src1.AggregateVal.size();_i++) \
- Dest.AggregateVal[_i].IntVal = APInt(1, \
- Src1.AggregateVal[_i].IntVal.OP(Src2.AggregateVal[_i].IntVal));\
+#define IMPLEMENT_VECTOR_INTEGER_ICMP(OP, TY) \
+ case Type::FixedVectorTyID: \
+ case Type::ScalableVectorTyID: { \
+ assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \
+ Dest.AggregateVal.resize(Src1.AggregateVal.size()); \
+ for (uint32_t _i = 0; _i < Src1.AggregateVal.size(); _i++) \
+ Dest.AggregateVal[_i].IntVal = APInt( \
+ 1, Src1.AggregateVal[_i].IntVal.OP(Src2.AggregateVal[_i].IntVal)); \
} break;
// Handle pointers specially because they must be compared with only as much
Src1.AggregateVal[_i].TY##Val OP Src2.AggregateVal[_i].TY##Val);\
break;
-#define IMPLEMENT_VECTOR_FCMP(OP) \
- case Type::VectorTyID: \
- if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) { \
- IMPLEMENT_VECTOR_FCMP_T(OP, Float); \
- } else { \
- IMPLEMENT_VECTOR_FCMP_T(OP, Double); \
+#define IMPLEMENT_VECTOR_FCMP(OP) \
+ case Type::FixedVectorTyID: \
+ case Type::ScalableVectorTyID: \
+ if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) { \
+ IMPLEMENT_VECTOR_FCMP_T(OP, Float); \
+ } else { \
+ IMPLEMENT_VECTOR_FCMP_T(OP, Double); \
}
static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcVal->getType()->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcVal->getType())) {
assert(SrcVal->getType()->getScalarType()->isDoubleTy() &&
DstTy->getScalarType()->isFloatTy() &&
"Invalid FPTrunc instruction");
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcVal->getType()->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcVal->getType())) {
assert(SrcVal->getType()->getScalarType()->isFloatTy() &&
DstTy->getScalarType()->isDoubleTy() && "Invalid FPExt instruction");
Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcTy->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcTy)) {
Type *DstVecTy = DstTy->getScalarType();
Type *SrcVecTy = SrcTy->getScalarType();
uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth();
Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcTy->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcTy)) {
Type *DstVecTy = DstTy->getScalarType();
Type *SrcVecTy = SrcTy->getScalarType();
uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth();
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcVal->getType()->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcVal->getType())) {
Type *DstVecTy = DstTy->getScalarType();
unsigned size = Src.AggregateVal.size();
// the sizes of src and dst vectors must be equal
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if (SrcVal->getType()->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcVal->getType())) {
Type *DstVecTy = DstTy->getScalarType();
unsigned size = Src.AggregateVal.size();
// the sizes of src and dst vectors must be equal
Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- if ((SrcTy->getTypeID() == Type::VectorTyID) ||
- (DstTy->getTypeID() == Type::VectorTyID)) {
+ if (isa<VectorType>(SrcTy) || isa<VectorType>(DstTy)) {
// vector src bitcast to vector dst or vector src bitcast to scalar dst or
// scalar src bitcast to vector dst
bool isLittleEndian = getDataLayout().isLittleEndian();
unsigned SrcNum;
unsigned DstNum;
- if (SrcTy->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(SrcTy)) {
SrcElemTy = SrcTy->getScalarType();
SrcBitSize = SrcTy->getScalarSizeInBits();
SrcNum = Src.AggregateVal.size();
SrcVec.AggregateVal.push_back(Src);
}
- if (DstTy->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(DstTy)) {
DstElemTy = DstTy->getScalarType();
DstBitSize = DstTy->getScalarSizeInBits();
DstNum = (SrcNum * SrcBitSize) / DstBitSize;
}
// convert result from integer to specified type
- if (DstTy->getTypeID() == Type::VectorTyID) {
+ if (isa<VectorType>(DstTy)) {
if (DstElemTy->isDoubleTy()) {
Dest.AggregateVal.resize(DstNum);
for (unsigned i = 0; i < DstNum; i++)
Dest.IntVal = TempDst.AggregateVal[0].IntVal;
}
}
- } else { // if ((SrcTy->getTypeID() == Type::VectorTyID) ||
- // (DstTy->getTypeID() == Type::VectorTyID))
+ } else { // if (isa<VectorType>(SrcTy)) || isa<VectorType>(DstTy))
// scalar src bitcast to scalar dst
if (DstTy->isPointerTy()) {
break;
case Type::ArrayTyID:
case Type::StructTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
Dest.AggregateVal = pSrc->AggregateVal;
break;
case Type::PointerTyID:
break;
case Type::ArrayTyID:
case Type::StructTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
pDest->AggregateVal = Src2.AggregateVal;
break;
case Type::PointerTyID:
OS << ']';
return;
}
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
VectorType *PTy = cast<VectorType>(Ty);
OS << "<";
if (PTy->isScalable())
return ConstantPointerNull::get(cast<PointerType>(Ty));
case Type::StructTyID:
case Type::ArrayTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
return ConstantAggregateZero::get(Ty);
case Type::TokenTyID:
return ConstantTokenNone::get(Ty->getContext());
Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer");
Constant *ConstantExpr::getSExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "SExt operand must be integral");
Constant *ConstantExpr::getZExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "ZEXt operand must be integral");
Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&
Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
- bool fromVec = C->getType()->getTypeID() == Type::VectorTyID;
- bool toVec = Ty->getTypeID() == Type::VectorTyID;
+ bool fromVec = isa<VectorType>(C->getType());
+ bool toVec = isa<VectorType>(Ty);
#endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&
return LLVMArrayTypeKind;
case Type::PointerTyID:
return LLVMPointerTypeKind;
- case Type::VectorTyID:
- return LLVMVectorTypeKind;
case Type::X86_MMXTyID:
return LLVMX86_MMXTypeKind;
case Type::TokenTyID:
return LLVMTokenTypeKind;
+ case Type::FixedVectorTyID:
+ return LLVMFixedVectorTypeKind;
+ case Type::ScalableVectorTyID:
+ return LLVMScalableVectorTypeKind;
}
llvm_unreachable("Unhandled TypeID.");
}
AlignType = FLOAT_ALIGN;
break;
case Type::X86_MMXTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
AlignType = VECTOR_ALIGN;
break;
default:
return getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits();
// 64-bit fixed width vector types can be losslessly converted to x86mmx.
- if (((isa<VectorType>(this) &&
- !cast<VectorType>(this)->getElementCount().Scalable) &&
- Ty->isX86_MMXTy()) &&
+ if (((isa<FixedVectorType>(this)) && Ty->isX86_MMXTy()) &&
getPrimitiveSizeInBits().getFixedSize() == 64)
return true;
- if ((isX86_MMXTy() && (isa<VectorType>(Ty) &&
- !cast<VectorType>(Ty)->getElementCount().Scalable)) &&
+ if ((isX86_MMXTy() && isa<FixedVectorType>(Ty)) &&
Ty->getPrimitiveSizeInBits().getFixedSize() == 64)
return true;
case Type::X86_MMXTyID: return TypeSize::Fixed(64);
case Type::IntegerTyID:
return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth());
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
const VectorType *VTy = cast<VectorType>(this);
ElementCount EC = VTy->getElementCount();
TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
// VectorType Implementation
//===----------------------------------------------------------------------===//
-VectorType::VectorType(Type *ElType, ElementCount EC)
- : Type(ElType->getContext(), VectorTyID), ContainedType(ElType),
- NumElements(EC.Min), Scalable(EC.Scalable) {
+VectorType::VectorType(Type *ElType, ElementCount EC, Type::TypeID TID)
+ : Type(ElType->getContext(), TID), ContainedType(ElType), EC(EC) {
ContainedTys = &ContainedType;
NumContainedTys = 1;
}
VectorType *VectorType::get(Type *ElementType, ElementCount EC) {
- assert(EC.Min > 0 && "#Elements of a VectorType must be greater than 0");
+ if (EC.Scalable)
+ return ScalableVectorType::get(ElementType, EC.Min);
+ else
+ return FixedVectorType::get(ElementType, EC.Min);
+}
+
+bool VectorType::isValidElementType(Type *ElemTy) {
+ return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
+ ElemTy->isPointerTy();
+}
+
+//===----------------------------------------------------------------------===//
+// FixedVectorType Implementation
+//===----------------------------------------------------------------------===//
+
+FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) {
+ assert(NumElts > 0 && "#Elements of a VectorType must be greater than 0");
assert(isValidElementType(ElementType) && "Element type of a VectorType must "
"be an integer, floating point, or "
"pointer type.");
+ ElementCount EC(NumElts, false);
+
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
- VectorType *&Entry = ElementType->getContext().pImpl
- ->VectorTypes[std::make_pair(ElementType, EC)];
+ VectorType *&Entry = ElementType->getContext()
+ .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
+
if (!Entry)
- Entry = new (pImpl->Alloc) VectorType(ElementType, EC);
- return Entry;
+ Entry = new (pImpl->Alloc) FixedVectorType(ElementType, NumElts);
+ return cast<FixedVectorType>(Entry);
}
-bool VectorType::isValidElementType(Type *ElemTy) {
- return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
- ElemTy->isPointerTy();
+//===----------------------------------------------------------------------===//
+// ScalableVectorType Implementation
+//===----------------------------------------------------------------------===//
+
+ScalableVectorType *ScalableVectorType::get(Type *ElementType,
+ unsigned MinNumElts) {
+ assert(MinNumElts > 0 && "#Elements of a VectorType must be greater than 0");
+ assert(isValidElementType(ElementType) && "Element type of a VectorType must "
+ "be an integer, floating point, or "
+ "pointer type.");
+
+ ElementCount EC(MinNumElts, true);
+
+ LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
+ VectorType *&Entry = ElementType->getContext()
+ .pImpl->VectorTypes[std::make_pair(ElementType, EC)];
+
+ if (!Entry)
+ Entry = new (pImpl->Alloc) ScalableVectorType(ElementType, MinNumElts);
+ return cast<ScalableVectorType>(Entry);
}
//===----------------------------------------------------------------------===//
case Type::ArrayTyID:
return *Entry = ArrayType::get(ElementTypes[0],
cast<ArrayType>(Ty)->getNumElements());
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
return *Entry = VectorType::get(ElementTypes[0],
cast<VectorType>(Ty)->getNumElements());
case Type::PointerTyID:
return ValueType::F64;
case Type::PointerTyID:
return getValueType(Ty->getPointerElementType(), TypeName);
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName);
default:
return ValueType::Struct;
return "float";
case Type::DoubleTyID:
return "double";
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID: {
auto VecTy = cast<VectorType>(Ty);
auto ElTy = VecTy->getElementType();
auto NumElements = VecTy->getNumElements();
return "f64";
case Type::PointerTyID:
return getValueType(Ty->getPointerElementType(), TypeName);
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName);
default:
return "struct";
return "float";
case Type::DoubleTyID:
return "double";
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID: {
auto VecTy = cast<VectorType>(Ty);
auto ElTy = VecTy->getElementType();
auto NumElements = VecTy->getNumElements();
Value *Arg = CI->getArgOperand(ArgCount);
Type *ArgType = Arg->getType();
SmallVector<Value *, 32> WhatToStore;
- if (ArgType->isFPOrFPVectorTy() &&
- (ArgType->getTypeID() != Type::VectorTyID)) {
+ if (ArgType->isFPOrFPVectorTy() && !isa<VectorType>(ArgType)) {
Type *IType = (ArgType->isFloatTy()) ? Int32Ty : Int64Ty;
if (OpConvSpecifiers[ArgCount - 1] == 'f') {
ConstantFP *fpCons = dyn_cast<ConstantFP>(Arg);
Arg = new PtrToIntInst(Arg, DstType, "PrintArgPtr", Brnch);
WhatToStore.push_back(Arg);
}
- } else if (ArgType->getTypeID() == Type::VectorTyID) {
+ } else if (isa<FixedVectorType>(ArgType)) {
Type *IType = NULL;
uint32_t EleCount = cast<VectorType>(ArgType)->getNumElements();
uint32_t EleSize = ArgType->getScalarSizeInBits();
const ArrayType *ATy = cast<const ArrayType>(Ty);
return getSmallestAddressableSize(ATy->getElementType(), GV, TM);
}
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID: {
const VectorType *PTy = cast<const VectorType>(Ty);
return getSmallestAddressableSize(PTy->getElementType(), GV, TM);
}
case Type::IntegerTyID: // Integers larger than 64 bits
case Type::StructTyID:
case Type::ArrayTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
ElementSize = DL.getTypeStoreSize(ETy);
// Ptx allows variable initilization only for constant and
// global state spaces.
switch (ETy->getTypeID()) {
case Type::StructTyID:
case Type::ArrayTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
ElementSize = DL.getTypeStoreSize(ETy);
O << " .b8 ";
getSymbol(GVar)->print(O, MAI);
}
case Type::ArrayTyID:
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
case Type::StructTyID: {
if (isa<ConstantAggregate>(CPV) || isa<ConstantDataSequential>(CPV)) {
int ElementSize = DL.getTypeAllocSize(CPV->getType());
default: break;
case Type::PointerTyID:
return true;
- case Type::VectorTyID:
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID:
if (cast<VectorType>(Ty)->getElementType()->isPointerTy())
return true;
break;
return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
return cmpTypes(STyL->getElementType(), STyR->getElementType());
}
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
auto *STyL = cast<VectorType>(TyL);
auto *STyR = cast<VectorType>(TyR);
if (STyL->getElementCount().Scalable != STyR->getElementCount().Scalable)
Clone(LLVMGetElementType(Src)),
LLVMGetPointerAddressSpace(Src)
);
- case LLVMVectorTypeKind:
+ case LLVMScalableVectorTypeKind:
+ // FIXME: scalable vectors unsupported
+ break;
+ case LLVMFixedVectorTypeKind:
return LLVMVectorType(
Clone(LLVMGetElementType(Src)),
LLVMGetVectorSize(Src)
return nullptr;
return LLVMType::getArrayTy(elementType, type->getArrayNumElements());
}
- case llvm::Type::VectorTyID: {
- auto *typeVTy = llvm::cast<llvm::VectorType>(type);
- if (typeVTy->isScalable()) {
- emitError(unknownLoc) << "scalable vector types not supported";
- return nullptr;
- }
+ case llvm::Type::ScalableVectorTyID: {
+ emitError(unknownLoc) << "scalable vector types not supported";
+ return nullptr;
+ }
+ case llvm::Type::FixedVectorTyID: {
+ auto *typeVTy = llvm::cast<llvm::FixedVectorType>(type);
LLVMType elementType = processType(typeVTy->getElementType());
if (!elementType)
return nullptr;