1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[SVE] Add new VectorType subclasses

Summary:
Introduce new types for fixed width and scalable vectors.

Does not remove getNumElements yet so as to not break code during transition
period.

Reviewers: deadalnix, efriedma, sdesmalen, craig.topper, huntergr

Reviewed By: sdesmalen

Subscribers: jholewinski, arsenm, jvesely, nhaehnle, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, kerbowa, Joonsoo, grosul1, frgossen, lldb-commits, tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D77587
This commit is contained in:
Christopher Tetreault 2020-04-22 08:02:02 -07:00
parent 5e27e52ade
commit 7f0438624e
21 changed files with 231 additions and 149 deletions

View File

@ -157,10 +157,11 @@ typedef enum {
LLVMStructTypeKind, /**< Structures */ LLVMStructTypeKind, /**< Structures */
LLVMArrayTypeKind, /**< Arrays */ LLVMArrayTypeKind, /**< Arrays */
LLVMPointerTypeKind, /**< Pointers */ LLVMPointerTypeKind, /**< Pointers */
LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
LLVMMetadataTypeKind, /**< Metadata */ LLVMMetadataTypeKind, /**< Metadata */
LLVMX86_MMXTypeKind, /**< X86 MMX */ LLVMX86_MMXTypeKind, /**< X86 MMX */
LLVMTokenTypeKind /**< Tokens */ LLVMTokenTypeKind, /**< Tokens */
LLVMFixedVectorTypeKind, /**< Fixed width SIMD vector type */
LLVMScalableVectorTypeKind /**< Scalable SIMD vector type */
} LLVMTypeKind; } LLVMTypeKind;
typedef enum { typedef enum {

View File

@ -664,7 +664,8 @@ inline TypeSize DataLayout::getTypeSizeInBits(Type *Ty) const {
// only 80 bits contain information. // only 80 bits contain information.
case Type::X86_FP80TyID: case Type::X86_FP80TyID:
return TypeSize::Fixed(80); return TypeSize::Fixed(80);
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty); VectorType *VTy = cast<VectorType>(Ty);
auto EltCnt = VTy->getElementCount(); auto EltCnt = VTy->getElementCount();
uint64_t MinBits = EltCnt.Min * uint64_t MinBits = EltCnt.Min *

View File

@ -386,7 +386,7 @@ uint64_t Type::getArrayNumElements() const {
return cast<ArrayType>(this)->getNumElements(); return cast<ArrayType>(this)->getNumElements();
} }
/// Class to represent vector types. /// Base class of all SIMD vector types
class VectorType : public Type { class VectorType : public Type {
/// A fully specified VectorType is of the form <vscale x n x Ty>. 'n' is the /// 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 /// minimum number of elements of type Ty contained within the vector, and
@ -403,24 +403,22 @@ class VectorType : public Type {
/// The element type of the vector. /// The element type of the vector.
Type *ContainedType; Type *ContainedType;
/// Minumum number of elements in the vector.
uint64_t NumElements;
VectorType(Type *ElType, unsigned NumEl, bool Scalable = false); /// The element count of this vector
VectorType(Type *ElType, ElementCount EC); ElementCount EC;
// If true, the total number of elements is an unknown multiple of the protected:
// minimum 'NumElements'. Otherwise the total number of elements is exactly VectorType(Type *ElType, ElementCount EC, Type::TypeID TID);
// equal to 'NumElements'.
bool Scalable;
public: public:
VectorType(const VectorType &) = delete; VectorType(const VectorType &) = delete;
VectorType &operator=(const VectorType &) = delete; VectorType &operator=(const VectorType &) = delete;
/// For scalable vectors, this will return the minimum number of elements /// Get the number of elements in this vector. It does not make sense to call
/// in the vector. /// this function on a scalable vector, and this will be moved into
unsigned getNumElements() const { return NumElements; } /// FixedVectorType in a future commit
unsigned getNumElements() const { return EC.Min; }
Type *getElementType() const { return ContainedType; } Type *getElementType() const { return ContainedType; }
/// This static method is the primary way to construct an VectorType. /// This static method is the primary way to construct an VectorType.
@ -430,6 +428,10 @@ public:
return VectorType::get(ElementType, {NumElements, Scalable}); 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 /// 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 /// the input type, and the element type is an integer type of the same width
/// as the input element type. /// as the input element type.
@ -507,26 +509,53 @@ public:
/// Return an ElementCount instance to represent the (possibly scalable) /// Return an ElementCount instance to represent the (possibly scalable)
/// number of elements in the vector. /// number of elements in the vector.
ElementCount getElementCount() const { ElementCount getElementCount() const { return EC; }
uint64_t MinimumEltCnt = getNumElements();
assert(MinimumEltCnt <= UINT_MAX && "Too many elements in vector");
return { (unsigned)MinimumEltCnt, Scalable };
}
/// Returns whether or not this is a scalable vector (meaning the total /// Returns whether or not this is a scalable vector (meaning the total
/// element count is a multiple of the minimum). /// element count is a multiple of the minimum).
bool isScalable() const { bool isScalable() const { return EC.Scalable; }
return Scalable;
}
/// Methods for support type inquiry through isa, cast, and dyn_cast. /// Methods for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Type *T) { 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); } 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 to represent pointers.
class PointerType : public Type { class PointerType : public Type {
explicit PointerType(Type *ElType, unsigned AddrSpace); explicit PointerType(Type *ElType, unsigned AddrSpace);

View File

@ -54,26 +54,27 @@ public:
/// ///
enum TypeID { enum TypeID {
// PrimitiveTypes - make sure LastPrimitiveTyID stays up to date. // PrimitiveTypes - make sure LastPrimitiveTyID stays up to date.
VoidTyID = 0, ///< 0: type with no size VoidTyID = 0, ///< 0: type with no size
HalfTyID, ///< 1: 16-bit floating point type HalfTyID, ///< 1: 16-bit floating point type
FloatTyID, ///< 2: 32-bit floating point type FloatTyID, ///< 2: 32-bit floating point type
DoubleTyID, ///< 3: 64-bit floating point type DoubleTyID, ///< 3: 64-bit floating point type
X86_FP80TyID, ///< 4: 80-bit floating point type (X87) X86_FP80TyID, ///< 4: 80-bit floating point type (X87)
FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa) FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa)
PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC) PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC)
LabelTyID, ///< 7: Labels LabelTyID, ///< 7: Labels
MetadataTyID, ///< 8: Metadata MetadataTyID, ///< 8: Metadata
X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific) X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific)
TokenTyID, ///< 10: Tokens TokenTyID, ///< 10: Tokens
// Derived types... see DerivedTypes.h file. // Derived types... see DerivedTypes.h file.
// Make sure FirstDerivedTyID stays up to date! // Make sure FirstDerivedTyID stays up to date!
IntegerTyID, ///< 11: Arbitrary bit width integers IntegerTyID, ///< 11: Arbitrary bit width integers
FunctionTyID, ///< 12: Functions FunctionTyID, ///< 12: Functions
StructTyID, ///< 13: Structures StructTyID, ///< 13: Structures
ArrayTyID, ///< 14: Arrays ArrayTyID, ///< 14: Arrays
PointerTyID, ///< 15: Pointers PointerTyID, ///< 15: Pointers
VectorTyID ///< 16: SIMD 'packed' format, or other vector type FixedVectorTyID, ///< 16: Fixed width SIMD vector type
ScalableVectorTyID ///< 17: Scalable SIMD vector type
}; };
private: private:
@ -266,8 +267,7 @@ public:
return true; return true;
// If it is not something that can have a size (e.g. a function or label), // If it is not something that can have a size (e.g. a function or label),
// it doesn't have a size. // it doesn't have a size.
if (getTypeID() != StructTyID && getTypeID() != ArrayTyID && if (getTypeID() != StructTyID && getTypeID() != ArrayTyID && !isVectorTy())
getTypeID() != VectorTyID)
return false; return false;
// Otherwise we have to try harder to decide. // Otherwise we have to try harder to decide.
return isSizedDerivedType(Visited); return isSizedDerivedType(Visited);

View File

@ -949,7 +949,8 @@ void ModuleBitcodeWriter::writeTypeTable() {
AbbrevToUse = ArrayAbbrev; AbbrevToUse = ArrayAbbrev;
break; break;
} }
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
VectorType *VT = cast<VectorType>(T); VectorType *VT = cast<VectorType>(T);
// VECTOR [numelts, eltty] or // VECTOR [numelts, eltty] or
// [numelts, eltty, scalable] // [numelts, eltty, scalable]

View File

@ -362,7 +362,8 @@ MVT MVT::getVT(Type *Ty, bool HandleUnknown){
case Type::FP128TyID: return MVT(MVT::f128); case Type::FP128TyID: return MVT(MVT::f128);
case Type::PPC_FP128TyID: return MVT(MVT::ppcf128); case Type::PPC_FP128TyID: return MVT(MVT::ppcf128);
case Type::PointerTyID: return MVT(MVT::iPTR); case Type::PointerTyID: return MVT(MVT::iPTR);
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty); VectorType *VTy = cast<VectorType>(Ty);
return getVectorVT( return getVectorVT(
getVT(VTy->getElementType(), /*HandleUnknown=*/ false), getVT(VTy->getElementType(), /*HandleUnknown=*/ false),
@ -380,7 +381,8 @@ EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
return MVT::getVT(Ty, HandleUnknown); return MVT::getVT(Ty, HandleUnknown);
case Type::IntegerTyID: case Type::IntegerTyID:
return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth()); return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
VectorType *VTy = cast<VectorType>(Ty); VectorType *VTy = cast<VectorType>(Ty);
return getVectorVT(Ty->getContext(), return getVectorVT(Ty->getContext(),
getEVT(VTy->getElementType(), /*HandleUnknown=*/ false), getEVT(VTy->getElementType(), /*HandleUnknown=*/ false),

View File

@ -624,17 +624,18 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
} }
} }
break; break;
case Type::VectorTyID: case Type::FixedVectorTyID:
// if the whole vector is 'undef' just reserve memory for the value. case Type::ScalableVectorTyID:
auto* VTy = cast<VectorType>(C->getType()); // if the whole vector is 'undef' just reserve memory for the value.
Type *ElemTy = VTy->getElementType(); auto *VTy = cast<VectorType>(C->getType());
unsigned int elemNum = VTy->getNumElements(); Type *ElemTy = VTy->getElementType();
Result.AggregateVal.resize(elemNum); unsigned int elemNum = VTy->getNumElements();
if (ElemTy->isIntegerTy()) Result.AggregateVal.resize(elemNum);
for (unsigned int i = 0; i < elemNum; ++i) if (ElemTy->isIntegerTy())
Result.AggregateVal[i].IntVal = for (unsigned int i = 0; i < elemNum; ++i)
APInt(ElemTy->getPrimitiveSizeInBits(), 0); Result.AggregateVal[i].IntVal =
break; APInt(ElemTy->getPrimitiveSizeInBits(), 0);
break;
} }
return Result; return Result;
} }
@ -914,7 +915,8 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
else else
llvm_unreachable("Unknown constant pointer type!"); llvm_unreachable("Unknown constant pointer type!");
break; break;
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
unsigned elemNum; unsigned elemNum;
Type* ElemTy; Type* ElemTy;
const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C); const ConstantDataVector *CDV = dyn_cast<ConstantDataVector>(C);
@ -1006,8 +1008,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
break; break;
} }
llvm_unreachable("Unknown constant pointer type!"); llvm_unreachable("Unknown constant pointer type!");
} } break;
break;
default: default:
SmallString<256> Msg; SmallString<256> Msg;
@ -1046,7 +1047,8 @@ void ExecutionEngine::StoreValueToMemory(const GenericValue &Val,
*((PointerTy*)Ptr) = Val.PointerVal; *((PointerTy*)Ptr) = Val.PointerVal;
break; break;
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
for (unsigned i = 0; i < Val.AggregateVal.size(); ++i) { for (unsigned i = 0; i < Val.AggregateVal.size(); ++i) {
if (cast<VectorType>(Ty)->getElementType()->isDoubleTy()) if (cast<VectorType>(Ty)->getElementType()->isDoubleTy())
*(((double*)Ptr)+i) = Val.AggregateVal[i].DoubleVal; *(((double*)Ptr)+i) = Val.AggregateVal[i].DoubleVal;
@ -1096,7 +1098,8 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
Result.IntVal = APInt(80, y); Result.IntVal = APInt(80, y);
break; break;
} }
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
auto *VT = cast<VectorType>(Ty); auto *VT = cast<VectorType>(Ty);
Type *ElemT = VT->getElementType(); Type *ElemT = VT->getElementType();
const unsigned numElems = VT->getNumElements(); const unsigned numElems = VT->getNumElements();

View File

@ -169,13 +169,14 @@ static void executeFRemInst(GenericValue &Dest, GenericValue Src1,
Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \ Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \
break; break;
#define IMPLEMENT_VECTOR_INTEGER_ICMP(OP, TY) \ #define IMPLEMENT_VECTOR_INTEGER_ICMP(OP, TY) \
case Type::VectorTyID: { \ case Type::FixedVectorTyID: \
assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \ case Type::ScalableVectorTyID: { \
Dest.AggregateVal.resize( Src1.AggregateVal.size() ); \ assert(Src1.AggregateVal.size() == Src2.AggregateVal.size()); \
for( uint32_t _i=0;_i<Src1.AggregateVal.size();_i++) \ Dest.AggregateVal.resize(Src1.AggregateVal.size()); \
Dest.AggregateVal[_i].IntVal = APInt(1, \ for (uint32_t _i = 0; _i < Src1.AggregateVal.size(); _i++) \
Src1.AggregateVal[_i].IntVal.OP(Src2.AggregateVal[_i].IntVal));\ Dest.AggregateVal[_i].IntVal = APInt( \
1, Src1.AggregateVal[_i].IntVal.OP(Src2.AggregateVal[_i].IntVal)); \
} break; } break;
// Handle pointers specially because they must be compared with only as much // Handle pointers specially because they must be compared with only as much
@ -367,12 +368,13 @@ void Interpreter::visitICmpInst(ICmpInst &I) {
Src1.AggregateVal[_i].TY##Val OP Src2.AggregateVal[_i].TY##Val);\ Src1.AggregateVal[_i].TY##Val OP Src2.AggregateVal[_i].TY##Val);\
break; break;
#define IMPLEMENT_VECTOR_FCMP(OP) \ #define IMPLEMENT_VECTOR_FCMP(OP) \
case Type::VectorTyID: \ case Type::FixedVectorTyID: \
if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) { \ case Type::ScalableVectorTyID: \
IMPLEMENT_VECTOR_FCMP_T(OP, Float); \ if (cast<VectorType>(Ty)->getElementType()->isFloatTy()) { \
} else { \ IMPLEMENT_VECTOR_FCMP_T(OP, Float); \
IMPLEMENT_VECTOR_FCMP_T(OP, Double); \ } else { \
IMPLEMENT_VECTOR_FCMP_T(OP, Double); \
} }
static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2, static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
@ -1327,7 +1329,7 @@ GenericValue Interpreter::executeFPTruncInst(Value *SrcVal, Type *DstTy,
ExecutionContext &SF) { ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcVal->getType()->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcVal->getType())) {
assert(SrcVal->getType()->getScalarType()->isDoubleTy() && assert(SrcVal->getType()->getScalarType()->isDoubleTy() &&
DstTy->getScalarType()->isFloatTy() && DstTy->getScalarType()->isFloatTy() &&
"Invalid FPTrunc instruction"); "Invalid FPTrunc instruction");
@ -1350,7 +1352,7 @@ GenericValue Interpreter::executeFPExtInst(Value *SrcVal, Type *DstTy,
ExecutionContext &SF) { ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcVal->getType()->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcVal->getType())) {
assert(SrcVal->getType()->getScalarType()->isFloatTy() && assert(SrcVal->getType()->getScalarType()->isFloatTy() &&
DstTy->getScalarType()->isDoubleTy() && "Invalid FPExt instruction"); DstTy->getScalarType()->isDoubleTy() && "Invalid FPExt instruction");
@ -1373,7 +1375,7 @@ GenericValue Interpreter::executeFPToUIInst(Value *SrcVal, Type *DstTy,
Type *SrcTy = SrcVal->getType(); Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcTy->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcTy)) {
Type *DstVecTy = DstTy->getScalarType(); Type *DstVecTy = DstTy->getScalarType();
Type *SrcVecTy = SrcTy->getScalarType(); Type *SrcVecTy = SrcTy->getScalarType();
uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth(); uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth();
@ -1411,7 +1413,7 @@ GenericValue Interpreter::executeFPToSIInst(Value *SrcVal, Type *DstTy,
Type *SrcTy = SrcVal->getType(); Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcTy->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcTy)) {
Type *DstVecTy = DstTy->getScalarType(); Type *DstVecTy = DstTy->getScalarType();
Type *SrcVecTy = SrcTy->getScalarType(); Type *SrcVecTy = SrcTy->getScalarType();
uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth(); uint32_t DBitWidth = cast<IntegerType>(DstVecTy)->getBitWidth();
@ -1447,7 +1449,7 @@ GenericValue Interpreter::executeUIToFPInst(Value *SrcVal, Type *DstTy,
ExecutionContext &SF) { ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcVal->getType()->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcVal->getType())) {
Type *DstVecTy = DstTy->getScalarType(); Type *DstVecTy = DstTy->getScalarType();
unsigned size = Src.AggregateVal.size(); unsigned size = Src.AggregateVal.size();
// the sizes of src and dst vectors must be equal // the sizes of src and dst vectors must be equal
@ -1479,7 +1481,7 @@ GenericValue Interpreter::executeSIToFPInst(Value *SrcVal, Type *DstTy,
ExecutionContext &SF) { ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if (SrcVal->getType()->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcVal->getType())) {
Type *DstVecTy = DstTy->getScalarType(); Type *DstVecTy = DstTy->getScalarType();
unsigned size = Src.AggregateVal.size(); unsigned size = Src.AggregateVal.size();
// the sizes of src and dst vectors must be equal // the sizes of src and dst vectors must be equal
@ -1540,8 +1542,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, Type *DstTy,
Type *SrcTy = SrcVal->getType(); Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF); GenericValue Dest, Src = getOperandValue(SrcVal, SF);
if ((SrcTy->getTypeID() == Type::VectorTyID) || if (isa<VectorType>(SrcTy) || isa<VectorType>(DstTy)) {
(DstTy->getTypeID() == Type::VectorTyID)) {
// vector src bitcast to vector dst or vector src bitcast to scalar dst or // vector src bitcast to vector dst or vector src bitcast to scalar dst or
// scalar src bitcast to vector dst // scalar src bitcast to vector dst
bool isLittleEndian = getDataLayout().isLittleEndian(); bool isLittleEndian = getDataLayout().isLittleEndian();
@ -1553,7 +1554,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, Type *DstTy,
unsigned SrcNum; unsigned SrcNum;
unsigned DstNum; unsigned DstNum;
if (SrcTy->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(SrcTy)) {
SrcElemTy = SrcTy->getScalarType(); SrcElemTy = SrcTy->getScalarType();
SrcBitSize = SrcTy->getScalarSizeInBits(); SrcBitSize = SrcTy->getScalarSizeInBits();
SrcNum = Src.AggregateVal.size(); SrcNum = Src.AggregateVal.size();
@ -1566,7 +1567,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, Type *DstTy,
SrcVec.AggregateVal.push_back(Src); SrcVec.AggregateVal.push_back(Src);
} }
if (DstTy->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(DstTy)) {
DstElemTy = DstTy->getScalarType(); DstElemTy = DstTy->getScalarType();
DstBitSize = DstTy->getScalarSizeInBits(); DstBitSize = DstTy->getScalarSizeInBits();
DstNum = (SrcNum * SrcBitSize) / DstBitSize; DstNum = (SrcNum * SrcBitSize) / DstBitSize;
@ -1639,7 +1640,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, Type *DstTy,
} }
// convert result from integer to specified type // convert result from integer to specified type
if (DstTy->getTypeID() == Type::VectorTyID) { if (isa<VectorType>(DstTy)) {
if (DstElemTy->isDoubleTy()) { if (DstElemTy->isDoubleTy()) {
Dest.AggregateVal.resize(DstNum); Dest.AggregateVal.resize(DstNum);
for (unsigned i = 0; i < DstNum; i++) for (unsigned i = 0; i < DstNum; i++)
@ -1662,8 +1663,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, Type *DstTy,
Dest.IntVal = TempDst.AggregateVal[0].IntVal; Dest.IntVal = TempDst.AggregateVal[0].IntVal;
} }
} }
} else { // if ((SrcTy->getTypeID() == Type::VectorTyID) || } else { // if (isa<VectorType>(SrcTy)) || isa<VectorType>(DstTy))
// (DstTy->getTypeID() == Type::VectorTyID))
// scalar src bitcast to scalar dst // scalar src bitcast to scalar dst
if (DstTy->isPointerTy()) { if (DstTy->isPointerTy()) {
@ -1954,7 +1954,8 @@ void Interpreter::visitExtractValueInst(ExtractValueInst &I) {
break; break;
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::StructTyID: case Type::StructTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
Dest.AggregateVal = pSrc->AggregateVal; Dest.AggregateVal = pSrc->AggregateVal;
break; break;
case Type::PointerTyID: case Type::PointerTyID:
@ -2001,7 +2002,8 @@ void Interpreter::visitInsertValueInst(InsertValueInst &I) {
break; break;
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::StructTyID: case Type::StructTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
pDest->AggregateVal = Src2.AggregateVal; pDest->AggregateVal = Src2.AggregateVal;
break; break;
case Type::PointerTyID: case Type::PointerTyID:

View File

@ -650,7 +650,8 @@ void TypePrinting::print(Type *Ty, raw_ostream &OS) {
OS << ']'; OS << ']';
return; return;
} }
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
VectorType *PTy = cast<VectorType>(Ty); VectorType *PTy = cast<VectorType>(Ty);
OS << "<"; OS << "<";
if (PTy->isScalable()) if (PTy->isScalable())

View File

@ -352,7 +352,8 @@ Constant *Constant::getNullValue(Type *Ty) {
return ConstantPointerNull::get(cast<PointerType>(Ty)); return ConstantPointerNull::get(cast<PointerType>(Ty));
case Type::StructTyID: case Type::StructTyID:
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
return ConstantAggregateZero::get(Ty); return ConstantAggregateZero::get(Ty);
case Type::TokenTyID: case Type::TokenTyID:
return ConstantTokenNone::get(Ty->getContext()); return ConstantTokenNone::get(Ty->getContext());
@ -1780,8 +1781,8 @@ Constant *ConstantExpr::getFPCast(Constant *C, Type *Ty) {
Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer"); assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer");
@ -1794,8 +1795,8 @@ Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getSExt(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getSExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "SExt operand must be integral"); assert(C->getType()->isIntOrIntVectorTy() && "SExt operand must be integral");
@ -1808,8 +1809,8 @@ Constant *ConstantExpr::getSExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getZExt(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getZExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && "ZEXt operand must be integral"); assert(C->getType()->isIntOrIntVectorTy() && "ZEXt operand must be integral");
@ -1822,8 +1823,8 @@ Constant *ConstantExpr::getZExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
@ -1834,8 +1835,8 @@ Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
@ -1846,8 +1847,8 @@ Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
@ -1857,8 +1858,8 @@ Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() &&
@ -1868,8 +1869,8 @@ Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&
@ -1879,8 +1880,8 @@ Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) {
Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced) { Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG #ifndef NDEBUG
bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool fromVec = isa<VectorType>(C->getType());
bool toVec = Ty->getTypeID() == Type::VectorTyID; bool toVec = isa<VectorType>(Ty);
#endif #endif
assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() &&

View File

@ -501,12 +501,14 @@ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
return LLVMArrayTypeKind; return LLVMArrayTypeKind;
case Type::PointerTyID: case Type::PointerTyID:
return LLVMPointerTypeKind; return LLVMPointerTypeKind;
case Type::VectorTyID:
return LLVMVectorTypeKind;
case Type::X86_MMXTyID: case Type::X86_MMXTyID:
return LLVMX86_MMXTypeKind; return LLVMX86_MMXTypeKind;
case Type::TokenTyID: case Type::TokenTyID:
return LLVMTokenTypeKind; return LLVMTokenTypeKind;
case Type::FixedVectorTyID:
return LLVMFixedVectorTypeKind;
case Type::ScalableVectorTyID:
return LLVMScalableVectorTypeKind;
} }
llvm_unreachable("Unhandled TypeID."); llvm_unreachable("Unhandled TypeID.");
} }

View File

@ -739,7 +739,8 @@ Align DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const {
AlignType = FLOAT_ALIGN; AlignType = FLOAT_ALIGN;
break; break;
case Type::X86_MMXTyID: case Type::X86_MMXTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
AlignType = VECTOR_ALIGN; AlignType = VECTOR_ALIGN;
break; break;
default: default:

View File

@ -73,13 +73,10 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const {
return getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits(); return getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits();
// 64-bit fixed width vector types can be losslessly converted to x86mmx. // 64-bit fixed width vector types can be losslessly converted to x86mmx.
if (((isa<VectorType>(this) && if (((isa<FixedVectorType>(this)) && Ty->isX86_MMXTy()) &&
!cast<VectorType>(this)->getElementCount().Scalable) &&
Ty->isX86_MMXTy()) &&
getPrimitiveSizeInBits().getFixedSize() == 64) getPrimitiveSizeInBits().getFixedSize() == 64)
return true; return true;
if ((isX86_MMXTy() && (isa<VectorType>(Ty) && if ((isX86_MMXTy() && isa<FixedVectorType>(Ty)) &&
!cast<VectorType>(Ty)->getElementCount().Scalable)) &&
Ty->getPrimitiveSizeInBits().getFixedSize() == 64) Ty->getPrimitiveSizeInBits().getFixedSize() == 64)
return true; return true;
@ -123,7 +120,8 @@ TypeSize Type::getPrimitiveSizeInBits() const {
case Type::X86_MMXTyID: return TypeSize::Fixed(64); case Type::X86_MMXTyID: return TypeSize::Fixed(64);
case Type::IntegerTyID: case Type::IntegerTyID:
return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth()); return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth());
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
const VectorType *VTy = cast<VectorType>(this); const VectorType *VTy = cast<VectorType>(this);
ElementCount EC = VTy->getElementCount(); ElementCount EC = VTy->getElementCount();
TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits(); TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
@ -586,30 +584,65 @@ bool ArrayType::isValidElementType(Type *ElemTy) {
// VectorType Implementation // VectorType Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
VectorType::VectorType(Type *ElType, ElementCount EC) VectorType::VectorType(Type *ElType, ElementCount EC, Type::TypeID TID)
: Type(ElType->getContext(), VectorTyID), ContainedType(ElType), : Type(ElType->getContext(), TID), ContainedType(ElType), EC(EC) {
NumElements(EC.Min), Scalable(EC.Scalable) {
ContainedTys = &ContainedType; ContainedTys = &ContainedType;
NumContainedTys = 1; NumContainedTys = 1;
} }
VectorType *VectorType::get(Type *ElementType, ElementCount EC) { VectorType *VectorType::get(Type *ElementType, ElementCount EC) {
assert(EC.Min > 0 && "#Elements of a VectorType must be greater than 0"); if (EC.Scalable)
assert(isValidElementType(ElementType) && "Element type of a VectorType must " return ScalableVectorType::get(ElementType, EC.Min);
"be an integer, floating point, or " else
"pointer type."); return FixedVectorType::get(ElementType, EC.Min);
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
VectorType *&Entry = ElementType->getContext().pImpl
->VectorTypes[std::make_pair(ElementType, EC)];
if (!Entry)
Entry = new (pImpl->Alloc) VectorType(ElementType, EC);
return Entry;
} }
bool VectorType::isValidElementType(Type *ElemTy) { bool VectorType::isValidElementType(Type *ElemTy) {
return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() || return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() ||
ElemTy->isPointerTy(); 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)];
if (!Entry)
Entry = new (pImpl->Alloc) FixedVectorType(ElementType, NumElts);
return cast<FixedVectorType>(Entry);
}
//===----------------------------------------------------------------------===//
// 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);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -305,7 +305,8 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
case Type::ArrayTyID: case Type::ArrayTyID:
return *Entry = ArrayType::get(ElementTypes[0], return *Entry = ArrayType::get(ElementTypes[0],
cast<ArrayType>(Ty)->getNumElements()); cast<ArrayType>(Ty)->getNumElements());
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
return *Entry = VectorType::get(ElementTypes[0], return *Entry = VectorType::get(ElementTypes[0],
cast<VectorType>(Ty)->getNumElements()); cast<VectorType>(Ty)->getNumElements());
case Type::PointerTyID: case Type::PointerTyID:

View File

@ -152,7 +152,7 @@ ValueType MetadataStreamerV2::getValueType(Type *Ty, StringRef TypeName) const {
return ValueType::F64; return ValueType::F64;
case Type::PointerTyID: case Type::PointerTyID:
return getValueType(Ty->getPointerElementType(), TypeName); return getValueType(Ty->getPointerElementType(), TypeName);
case Type::VectorTyID: case Type::FixedVectorTyID:
return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName); return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName);
default: default:
return ValueType::Struct; return ValueType::Struct;
@ -185,7 +185,7 @@ std::string MetadataStreamerV2::getTypeName(Type *Ty, bool Signed) const {
return "float"; return "float";
case Type::DoubleTyID: case Type::DoubleTyID:
return "double"; return "double";
case Type::VectorTyID: { case Type::FixedVectorTyID: {
auto VecTy = cast<VectorType>(Ty); auto VecTy = cast<VectorType>(Ty);
auto ElTy = VecTy->getElementType(); auto ElTy = VecTy->getElementType();
auto NumElements = VecTy->getNumElements(); auto NumElements = VecTy->getNumElements();
@ -599,7 +599,7 @@ StringRef MetadataStreamerV3::getValueType(Type *Ty, StringRef TypeName) const {
return "f64"; return "f64";
case Type::PointerTyID: case Type::PointerTyID:
return getValueType(Ty->getPointerElementType(), TypeName); return getValueType(Ty->getPointerElementType(), TypeName);
case Type::VectorTyID: case Type::FixedVectorTyID:
return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName); return getValueType(cast<VectorType>(Ty)->getElementType(), TypeName);
default: default:
return "struct"; return "struct";
@ -632,7 +632,7 @@ std::string MetadataStreamerV3::getTypeName(Type *Ty, bool Signed) const {
return "float"; return "float";
case Type::DoubleTyID: case Type::DoubleTyID:
return "double"; return "double";
case Type::VectorTyID: { case Type::FixedVectorTyID: {
auto VecTy = cast<VectorType>(Ty); auto VecTy = cast<VectorType>(Ty);
auto ElTy = VecTy->getElementType(); auto ElTy = VecTy->getElementType();
auto NumElements = VecTy->getNumElements(); auto NumElements = VecTy->getNumElements();

View File

@ -408,8 +408,7 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
Value *Arg = CI->getArgOperand(ArgCount); Value *Arg = CI->getArgOperand(ArgCount);
Type *ArgType = Arg->getType(); Type *ArgType = Arg->getType();
SmallVector<Value *, 32> WhatToStore; SmallVector<Value *, 32> WhatToStore;
if (ArgType->isFPOrFPVectorTy() && if (ArgType->isFPOrFPVectorTy() && !isa<VectorType>(ArgType)) {
(ArgType->getTypeID() != Type::VectorTyID)) {
Type *IType = (ArgType->isFloatTy()) ? Int32Ty : Int64Ty; Type *IType = (ArgType->isFloatTy()) ? Int32Ty : Int64Ty;
if (OpConvSpecifiers[ArgCount - 1] == 'f') { if (OpConvSpecifiers[ArgCount - 1] == 'f') {
ConstantFP *fpCons = dyn_cast<ConstantFP>(Arg); ConstantFP *fpCons = dyn_cast<ConstantFP>(Arg);
@ -478,7 +477,7 @@ bool AMDGPUPrintfRuntimeBinding::lowerPrintfForGpu(
Arg = new PtrToIntInst(Arg, DstType, "PrintArgPtr", Brnch); Arg = new PtrToIntInst(Arg, DstType, "PrintArgPtr", Brnch);
WhatToStore.push_back(Arg); WhatToStore.push_back(Arg);
} }
} else if (ArgType->getTypeID() == Type::VectorTyID) { } else if (isa<FixedVectorType>(ArgType)) {
Type *IType = NULL; Type *IType = NULL;
uint32_t EleCount = cast<VectorType>(ArgType)->getNumElements(); uint32_t EleCount = cast<VectorType>(ArgType)->getNumElements();
uint32_t EleSize = ArgType->getScalarSizeInBits(); uint32_t EleSize = ArgType->getScalarSizeInBits();

View File

@ -307,7 +307,7 @@ unsigned HexagonTargetObjectFile::getSmallestAddressableSize(const Type *Ty,
const ArrayType *ATy = cast<const ArrayType>(Ty); const ArrayType *ATy = cast<const ArrayType>(Ty);
return getSmallestAddressableSize(ATy->getElementType(), GV, TM); return getSmallestAddressableSize(ATy->getElementType(), GV, TM);
} }
case Type::VectorTyID: { case Type::FixedVectorTyID: {
const VectorType *PTy = cast<const VectorType>(Ty); const VectorType *PTy = cast<const VectorType>(Ty);
return getSmallestAddressableSize(PTy->getElementType(), GV, TM); return getSmallestAddressableSize(PTy->getElementType(), GV, TM);
} }

View File

@ -1184,7 +1184,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
case Type::IntegerTyID: // Integers larger than 64 bits case Type::IntegerTyID: // Integers larger than 64 bits
case Type::StructTyID: case Type::StructTyID:
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
ElementSize = DL.getTypeStoreSize(ETy); ElementSize = DL.getTypeStoreSize(ETy);
// Ptx allows variable initilization only for constant and // Ptx allows variable initilization only for constant and
// global state spaces. // global state spaces.
@ -1358,7 +1358,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
switch (ETy->getTypeID()) { switch (ETy->getTypeID()) {
case Type::StructTyID: case Type::StructTyID:
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
ElementSize = DL.getTypeStoreSize(ETy); ElementSize = DL.getTypeStoreSize(ETy);
O << " .b8 "; O << " .b8 ";
getSymbol(GVar)->print(O, MAI); getSymbol(GVar)->print(O, MAI);
@ -1892,7 +1892,7 @@ void NVPTXAsmPrinter::bufferLEByte(const Constant *CPV, int Bytes,
} }
case Type::ArrayTyID: case Type::ArrayTyID:
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::StructTyID: { case Type::StructTyID: {
if (isa<ConstantAggregate>(CPV) || isa<ConstantDataSequential>(CPV)) { if (isa<ConstantAggregate>(CPV) || isa<ConstantDataSequential>(CPV)) {
int ElementSize = DL.getTypeAllocSize(CPV->getType()); int ElementSize = DL.getTypeAllocSize(CPV->getType());

View File

@ -129,7 +129,8 @@ static bool isLeakCheckerRoot(GlobalVariable *GV) {
default: break; default: break;
case Type::PointerTyID: case Type::PointerTyID:
return true; return true;
case Type::VectorTyID: case Type::FixedVectorTyID:
case Type::ScalableVectorTyID:
if (cast<VectorType>(Ty)->getElementType()->isPointerTy()) if (cast<VectorType>(Ty)->getElementType()->isPointerTy())
return true; return true;
break; break;

View File

@ -488,7 +488,8 @@ int FunctionComparator::cmpTypes(Type *TyL, Type *TyR) const {
return cmpNumbers(STyL->getNumElements(), STyR->getNumElements()); return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
return cmpTypes(STyL->getElementType(), STyR->getElementType()); return cmpTypes(STyL->getElementType(), STyR->getElementType());
} }
case Type::VectorTyID: { case Type::FixedVectorTyID:
case Type::ScalableVectorTyID: {
auto *STyL = cast<VectorType>(TyL); auto *STyL = cast<VectorType>(TyL);
auto *STyR = cast<VectorType>(TyR); auto *STyR = cast<VectorType>(TyR);
if (STyL->getElementCount().Scalable != STyR->getElementCount().Scalable) if (STyL->getElementCount().Scalable != STyR->getElementCount().Scalable)

View File

@ -137,7 +137,10 @@ struct TypeCloner {
Clone(LLVMGetElementType(Src)), Clone(LLVMGetElementType(Src)),
LLVMGetPointerAddressSpace(Src) LLVMGetPointerAddressSpace(Src)
); );
case LLVMVectorTypeKind: case LLVMScalableVectorTypeKind:
// FIXME: scalable vectors unsupported
break;
case LLVMFixedVectorTypeKind:
return LLVMVectorType( return LLVMVectorType(
Clone(LLVMGetElementType(Src)), Clone(LLVMGetElementType(Src)),
LLVMGetVectorSize(Src) LLVMGetVectorSize(Src)