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

[SVE] Deprecate default false variant of VectorType::get

Reviewers: efriedma, fpetrogalli, kmclaughlin, huntergr

Reviewed By: fpetrogalli

Subscribers: cfe-commits, tschuett, rkruppe, psnobl, llvm-commits

Tags: #llvm, #clang

Differential Revision: https://reviews.llvm.org/D80342
This commit is contained in:
Christopher Tetreault 2020-06-16 14:55:32 -07:00
parent f22e6d55bc
commit 61e16ba8f2
9 changed files with 50 additions and 37 deletions

View File

@ -443,8 +443,20 @@ public:
/// This static method is the primary way to construct an VectorType. /// This static method is the primary way to construct an VectorType.
static VectorType *get(Type *ElementType, ElementCount EC); static VectorType *get(Type *ElementType, ElementCount EC);
/// Base class getter that specifically constructs a FixedVectorType. This
/// function is deprecated, and will be removed after LLVM 11 ships. Since
/// this always returns a FixedVectorType via a base VectorType pointer,
/// FixedVectorType::get(Type *, unsigned) is strictly better since no cast is
/// required to call getNumElements() on the result.
LLVM_ATTRIBUTE_DEPRECATED(
inline static VectorType *get(Type *ElementType, unsigned NumElements),
"The base class version of get with the scalable argument defaulted to "
"false is deprecated. Either call VectorType::get(Type *, unsigned, "
"bool) and pass false, or call FixedVectorType::get(Type *, unsigned).");
static VectorType *get(Type *ElementType, unsigned NumElements, static VectorType *get(Type *ElementType, unsigned NumElements,
bool Scalable = false) { bool Scalable) {
return VectorType::get(ElementType, {NumElements, Scalable}); return VectorType::get(ElementType, {NumElements, Scalable});
} }
@ -537,6 +549,10 @@ public:
} }
}; };
inline VectorType *VectorType::get(Type *ElementType, unsigned NumElements) {
return VectorType::get(ElementType, NumElements, false);
}
/// Class to represent fixed width SIMD vectors /// Class to represent fixed width SIMD vectors
class FixedVectorType : public VectorType { class FixedVectorType : public VectorType {
protected: protected:

View File

@ -77,7 +77,7 @@ struct BasicTest : public testing::Test {
} // namespace } // namespace
TEST_F(BasicTest, isSplat) { TEST_F(BasicTest, isSplat) {
Value *UndefVec = UndefValue::get(VectorType::get(IRB.getInt8Ty(), 4)); Value *UndefVec = UndefValue::get(FixedVectorType::get(IRB.getInt8Ty(), 4));
EXPECT_TRUE(isSplatValue(UndefVec)); EXPECT_TRUE(isSplatValue(UndefVec));
Constant *UndefScalar = UndefValue::get(IRB.getInt8Ty()); Constant *UndefScalar = UndefValue::get(IRB.getInt8Ty());

View File

@ -85,7 +85,7 @@ TEST(LowLevelTypeTest, Vector) {
// Test Type->LLT conversion. // Test Type->LLT conversion.
Type *IRSTy = IntegerType::get(C, S); Type *IRSTy = IntegerType::get(C, S);
Type *IRTy = VectorType::get(IRSTy, Elts); Type *IRTy = FixedVectorType::get(IRSTy, Elts);
EXPECT_EQ(VTy, getLLTForType(*IRTy, DL)); EXPECT_EQ(VTy, getLLTForType(*IRTy, DL));
} }
} }
@ -222,8 +222,8 @@ TEST(LowLevelTypeTest, Pointer) {
// Test Type->LLT conversion. // Test Type->LLT conversion.
Type *IRTy = PointerType::get(IntegerType::get(C, 8), AS); Type *IRTy = PointerType::get(IntegerType::get(C, 8), AS);
EXPECT_EQ(Ty, getLLTForType(*IRTy, DL)); EXPECT_EQ(Ty, getLLTForType(*IRTy, DL));
Type *IRVTy = Type *IRVTy = FixedVectorType::get(
VectorType::get(PointerType::get(IntegerType::get(C, 8), AS), NumElts); PointerType::get(IntegerType::get(C, 8), AS), NumElts);
EXPECT_EQ(VTy, getLLTForType(*IRVTy, DL)); EXPECT_EQ(VTy, getLLTForType(*IRVTy, DL));
} }
} }

View File

@ -337,7 +337,7 @@ TEST(OperationsTest, ExtractAndInsertValue) {
Type *OpaqueTy = StructType::create(Ctx, "OpaqueStruct"); Type *OpaqueTy = StructType::create(Ctx, "OpaqueStruct");
Type *ZeroSizedArrayTy = ArrayType::get(Int64Ty, 0); Type *ZeroSizedArrayTy = ArrayType::get(Int64Ty, 0);
Type *ArrayTy = ArrayType::get(Int64Ty, 4); Type *ArrayTy = ArrayType::get(Int64Ty, 4);
Type *VectorTy = VectorType::get(Int32Ty, 2); Type *VectorTy = FixedVectorType::get(Int32Ty, 2);
auto EVOp = fuzzerop::extractValueDescriptor(1); auto EVOp = fuzzerop::extractValueDescriptor(1);
auto IVOp = fuzzerop::insertValueDescriptor(1); auto IVOp = fuzzerop::insertValueDescriptor(1);

View File

@ -131,9 +131,9 @@ TEST(ConstantsTest, PointerCast) {
Type *Int8PtrTy = Type::getInt8PtrTy(C); Type *Int8PtrTy = Type::getInt8PtrTy(C);
Type *Int32PtrTy = Type::getInt32PtrTy(C); Type *Int32PtrTy = Type::getInt32PtrTy(C);
Type *Int64Ty = Type::getInt64Ty(C); Type *Int64Ty = Type::getInt64Ty(C);
VectorType *Int8PtrVecTy = VectorType::get(Int8PtrTy, 4); VectorType *Int8PtrVecTy = FixedVectorType::get(Int8PtrTy, 4);
VectorType *Int32PtrVecTy = VectorType::get(Int32PtrTy, 4); VectorType *Int32PtrVecTy = FixedVectorType::get(Int32PtrTy, 4);
VectorType *Int64VecTy = VectorType::get(Int64Ty, 4); VectorType *Int64VecTy = FixedVectorType::get(Int64Ty, 4);
// ptrtoint i8* to i64 // ptrtoint i8* to i64
EXPECT_EQ(Constant::getNullValue(Int64Ty), EXPECT_EQ(Constant::getNullValue(Int64Ty),
@ -210,7 +210,7 @@ TEST(ConstantsTest, AsInstructionsTest) {
Constant *P3 = ConstantExpr::getTrunc(P0, Int1Ty); Constant *P3 = ConstantExpr::getTrunc(P0, Int1Ty);
Constant *P4 = ConstantExpr::getPtrToInt(Global2, Int32Ty); Constant *P4 = ConstantExpr::getPtrToInt(Global2, Int32Ty);
Constant *P5 = ConstantExpr::getUIToFP(P4, FloatTy); Constant *P5 = ConstantExpr::getUIToFP(P4, FloatTy);
Constant *P6 = ConstantExpr::getBitCast(P4, VectorType::get(Int16Ty, 2)); Constant *P6 = ConstantExpr::getBitCast(P4, FixedVectorType::get(Int16Ty, 2));
Constant *One = ConstantInt::get(Int32Ty, 1); Constant *One = ConstantInt::get(Int32Ty, 1);
Constant *Two = ConstantInt::get(Int64Ty, 2); Constant *Two = ConstantInt::get(Int64Ty, 2);

View File

@ -807,7 +807,7 @@ TEST_F(IRBuilderTest, createArtificialSubprogram) {
TEST_F(IRBuilderTest, InsertExtractElement) { TEST_F(IRBuilderTest, InsertExtractElement) {
IRBuilder<> Builder(BB); IRBuilder<> Builder(BB);
auto VecTy = VectorType::get(Builder.getInt64Ty(), 4); auto VecTy = FixedVectorType::get(Builder.getInt64Ty(), 4);
auto Elt1 = Builder.getInt64(-1); auto Elt1 = Builder.getInt64(-1);
auto Elt2 = Builder.getInt64(-2); auto Elt2 = Builder.getInt64(-2);
Value *Vec = UndefValue::get(VecTy); Value *Vec = UndefValue::get(VecTy);

View File

@ -186,18 +186,18 @@ TEST(InstructionsTest, CastInst) {
Type *Int16Ty = Type::getInt16Ty(C); Type *Int16Ty = Type::getInt16Ty(C);
Type *Int32Ty = Type::getInt32Ty(C); Type *Int32Ty = Type::getInt32Ty(C);
Type *Int64Ty = Type::getInt64Ty(C); Type *Int64Ty = Type::getInt64Ty(C);
Type *V8x8Ty = VectorType::get(Int8Ty, 8); Type *V8x8Ty = FixedVectorType::get(Int8Ty, 8);
Type *V8x64Ty = VectorType::get(Int64Ty, 8); Type *V8x64Ty = FixedVectorType::get(Int64Ty, 8);
Type *X86MMXTy = Type::getX86_MMXTy(C); Type *X86MMXTy = Type::getX86_MMXTy(C);
Type *HalfTy = Type::getHalfTy(C); Type *HalfTy = Type::getHalfTy(C);
Type *FloatTy = Type::getFloatTy(C); Type *FloatTy = Type::getFloatTy(C);
Type *DoubleTy = Type::getDoubleTy(C); Type *DoubleTy = Type::getDoubleTy(C);
Type *V2Int32Ty = VectorType::get(Int32Ty, 2); Type *V2Int32Ty = FixedVectorType::get(Int32Ty, 2);
Type *V2Int64Ty = VectorType::get(Int64Ty, 2); Type *V2Int64Ty = FixedVectorType::get(Int64Ty, 2);
Type *V4Int16Ty = VectorType::get(Int16Ty, 4); Type *V4Int16Ty = FixedVectorType::get(Int16Ty, 4);
Type *V1Int16Ty = VectorType::get(Int16Ty, 1); Type *V1Int16Ty = FixedVectorType::get(Int16Ty, 1);
Type *VScaleV2Int32Ty = VectorType::get(Int32Ty, 2, true); Type *VScaleV2Int32Ty = VectorType::get(Int32Ty, 2, true);
Type *VScaleV2Int64Ty = VectorType::get(Int64Ty, 2, true); Type *VScaleV2Int64Ty = VectorType::get(Int64Ty, 2, true);
@ -210,16 +210,16 @@ TEST(InstructionsTest, CastInst) {
Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1); Type *Int32PtrAS1Ty = PointerType::get(Int32Ty, 1);
Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1); Type *Int64PtrAS1Ty = PointerType::get(Int64Ty, 1);
Type *V2Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 2); Type *V2Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 2);
Type *V2Int64PtrAS1Ty = VectorType::get(Int64PtrAS1Ty, 2); Type *V2Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 2);
Type *V4Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 4); Type *V4Int32PtrAS1Ty = FixedVectorType::get(Int32PtrAS1Ty, 4);
Type *VScaleV4Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 4, true); Type *VScaleV4Int32PtrAS1Ty = VectorType::get(Int32PtrAS1Ty, 4, true);
Type *V4Int64PtrAS1Ty = VectorType::get(Int64PtrAS1Ty, 4); Type *V4Int64PtrAS1Ty = FixedVectorType::get(Int64PtrAS1Ty, 4);
Type *V2Int64PtrTy = VectorType::get(Int64PtrTy, 2); Type *V2Int64PtrTy = FixedVectorType::get(Int64PtrTy, 2);
Type *V2Int32PtrTy = VectorType::get(Int32PtrTy, 2); Type *V2Int32PtrTy = FixedVectorType::get(Int32PtrTy, 2);
Type *VScaleV2Int32PtrTy = VectorType::get(Int32PtrTy, 2, true); Type *VScaleV2Int32PtrTy = VectorType::get(Int32PtrTy, 2, true);
Type *V4Int32PtrTy = VectorType::get(Int32PtrTy, 4); Type *V4Int32PtrTy = FixedVectorType::get(Int32PtrTy, 4);
Type *VScaleV4Int32PtrTy = VectorType::get(Int32PtrTy, 4, true); Type *VScaleV4Int32PtrTy = VectorType::get(Int32PtrTy, 4, true);
Type *VScaleV4Int64PtrTy = VectorType::get(Int64PtrTy, 4, true); Type *VScaleV4Int64PtrTy = VectorType::get(Int64PtrTy, 4, true);
@ -390,8 +390,8 @@ TEST(InstructionsTest, VectorGep) {
PointerType *Ptri8Ty = PointerType::get(I8Ty, 0); PointerType *Ptri8Ty = PointerType::get(I8Ty, 0);
PointerType *Ptri32Ty = PointerType::get(I32Ty, 0); PointerType *Ptri32Ty = PointerType::get(I32Ty, 0);
VectorType *V2xi8PTy = VectorType::get(Ptri8Ty, 2); VectorType *V2xi8PTy = FixedVectorType::get(Ptri8Ty, 2);
VectorType *V2xi32PTy = VectorType::get(Ptri32Ty, 2); VectorType *V2xi32PTy = FixedVectorType::get(Ptri32Ty, 2);
// Test different aspects of the vector-of-pointers type // Test different aspects of the vector-of-pointers type
// and GEPs which use this type. // and GEPs which use this type.
@ -1174,7 +1174,7 @@ TEST(InstructionsTest, FPCallIsFPMathOperator) {
std::unique_ptr<CallInst> ICall(CallInst::Create(IFnTy, ICallee, {}, "")); std::unique_ptr<CallInst> ICall(CallInst::Create(IFnTy, ICallee, {}, ""));
EXPECT_FALSE(isa<FPMathOperator>(ICall)); EXPECT_FALSE(isa<FPMathOperator>(ICall));
Type *VITy = VectorType::get(ITy, 2); Type *VITy = FixedVectorType::get(ITy, 2);
FunctionType *VIFnTy = FunctionType::get(VITy, {}); FunctionType *VIFnTy = FunctionType::get(VITy, {});
Value *VICallee = Constant::getNullValue(VIFnTy->getPointerTo()); Value *VICallee = Constant::getNullValue(VIFnTy->getPointerTo());
std::unique_ptr<CallInst> VICall(CallInst::Create(VIFnTy, VICallee, {}, "")); std::unique_ptr<CallInst> VICall(CallInst::Create(VIFnTy, VICallee, {}, ""));
@ -1192,7 +1192,7 @@ TEST(InstructionsTest, FPCallIsFPMathOperator) {
std::unique_ptr<CallInst> FCall(CallInst::Create(FFnTy, FCallee, {}, "")); std::unique_ptr<CallInst> FCall(CallInst::Create(FFnTy, FCallee, {}, ""));
EXPECT_TRUE(isa<FPMathOperator>(FCall)); EXPECT_TRUE(isa<FPMathOperator>(FCall));
Type *VFTy = VectorType::get(FTy, 2); Type *VFTy = FixedVectorType::get(FTy, 2);
FunctionType *VFFnTy = FunctionType::get(VFTy, {}); FunctionType *VFFnTy = FunctionType::get(VFTy, {});
Value *VFCallee = Constant::getNullValue(VFFnTy->getPointerTo()); Value *VFCallee = Constant::getNullValue(VFFnTy->getPointerTo());
std::unique_ptr<CallInst> VFCall(CallInst::Create(VFFnTy, VFCallee, {}, "")); std::unique_ptr<CallInst> VFCall(CallInst::Create(VFFnTy, VFCallee, {}, ""));

View File

@ -928,9 +928,9 @@ TEST_F(PatternMatchTest, VectorOps) {
// //
// SP1 = VectorSplat(2, i8 2) // SP1 = VectorSplat(2, i8 2)
// SP2 = VectorSplat(2, i8 %Val) // SP2 = VectorSplat(2, i8 %Val)
Type *VecTy = VectorType::get(IRB.getInt8Ty(), 2); Type *VecTy = FixedVectorType::get(IRB.getInt8Ty(), 2);
Type *i32 = IRB.getInt32Ty(); Type *i32 = IRB.getInt32Ty();
Type *i32VecTy = VectorType::get(i32, 2); Type *i32VecTy = FixedVectorType::get(i32, 2);
Value *Val = IRB.CreateAdd(IRB.getInt8(0), IRB.getInt8(1)); Value *Val = IRB.CreateAdd(IRB.getInt8(0), IRB.getInt8(1));
Value *Val2 = IRB.CreateAdd(Val, IRB.getInt8(3)); Value *Val2 = IRB.CreateAdd(Val, IRB.getInt8(3));
@ -1021,7 +1021,7 @@ TEST_F(PatternMatchTest, VectorOps) {
TEST_F(PatternMatchTest, VectorUndefInt) { TEST_F(PatternMatchTest, VectorUndefInt) {
Type *ScalarTy = IRB.getInt8Ty(); Type *ScalarTy = IRB.getInt8Ty();
Type *VectorTy = VectorType::get(ScalarTy, 4); Type *VectorTy = FixedVectorType::get(ScalarTy, 4);
Constant *ScalarUndef = UndefValue::get(ScalarTy); Constant *ScalarUndef = UndefValue::get(ScalarTy);
Constant *VectorUndef = UndefValue::get(VectorTy); Constant *VectorUndef = UndefValue::get(VectorTy);
Constant *ScalarZero = Constant::getNullValue(ScalarTy); Constant *ScalarZero = Constant::getNullValue(ScalarTy);
@ -1086,7 +1086,7 @@ TEST_F(PatternMatchTest, VectorUndefInt) {
TEST_F(PatternMatchTest, VectorUndefFloat) { TEST_F(PatternMatchTest, VectorUndefFloat) {
Type *ScalarTy = IRB.getFloatTy(); Type *ScalarTy = IRB.getFloatTy();
Type *VectorTy = VectorType::get(ScalarTy, 4); Type *VectorTy = FixedVectorType::get(ScalarTy, 4);
Constant *ScalarUndef = UndefValue::get(ScalarTy); Constant *ScalarUndef = UndefValue::get(ScalarTy);
Constant *VectorUndef = UndefValue::get(VectorTy); Constant *VectorUndef = UndefValue::get(VectorTy);
Constant *ScalarZero = Constant::getNullValue(ScalarTy); Constant *ScalarZero = Constant::getNullValue(ScalarTy);

View File

@ -43,15 +43,12 @@ TEST(VectorTypesTest, FixedLength) {
EXPECT_EQ(V16Int8Ty->getNumElements(), 16U); EXPECT_EQ(V16Int8Ty->getNumElements(), 16U);
EXPECT_EQ(V16Int8Ty->getElementType()->getScalarSizeInBits(), 8U); EXPECT_EQ(V16Int8Ty->getElementType()->getScalarSizeInBits(), 8U);
auto *V8Int32Ty = dyn_cast<FixedVectorType>(VectorType::get(Int32Ty, 8)); auto *V8Int32Ty =
dyn_cast<FixedVectorType>(VectorType::get(Int32Ty, 8, false));
ASSERT_NE(nullptr, V8Int32Ty); ASSERT_NE(nullptr, V8Int32Ty);
EXPECT_EQ(V8Int32Ty->getNumElements(), 8U); EXPECT_EQ(V8Int32Ty->getNumElements(), 8U);
EXPECT_EQ(V8Int32Ty->getElementType()->getScalarSizeInBits(), 32U); EXPECT_EQ(V8Int32Ty->getElementType()->getScalarSizeInBits(), 32U);
auto *V8Int32TyExplicitFalse =
dyn_cast<FixedVectorType>(VectorType::get(Int32Ty, 8, false));
EXPECT_VTY_EQ(V8Int32Ty, V8Int32TyExplicitFalse);
auto *V8Int8Ty = auto *V8Int8Ty =
dyn_cast<FixedVectorType>(VectorType::get(Int8Ty, V8Int32Ty)); dyn_cast<FixedVectorType>(VectorType::get(Int8Ty, V8Int32Ty));
EXPECT_VTY_NE(V8Int32Ty, V8Int8Ty); EXPECT_VTY_NE(V8Int32Ty, V8Int8Ty);