1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[SVE] Remove VectorType::getBitWidth()

Summary:
* VectorType::getBitWidth() is just an unsafe version of
getPrimitiveSizeInBits() that assumes all vectors are fixed width.

Reviewers: efriedma, sdesmalen, huntergr, craig.topper

Reviewed By: efriedma

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

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77833
This commit is contained in:
Christopher Tetreault 2020-04-21 13:02:23 -07:00
parent 6eb54478ab
commit 47b07ad5b9
3 changed files with 19 additions and 22 deletions

View File

@ -519,12 +519,6 @@ public:
return Scalable; return Scalable;
} }
/// Return the minimum number of bits in the Vector type.
/// Returns zero when the vector is a vector of pointers.
unsigned getBitWidth() const {
return getNumElements() * getElementType()->getPrimitiveSizeInBits();
}
/// 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() == VectorTyID;

View File

@ -68,20 +68,20 @@ bool Type::canLosslesslyBitCastTo(Type *Ty) const {
return false; return false;
// Vector -> Vector conversions are always lossless if the two vector types // Vector -> Vector conversions are always lossless if the two vector types
// have the same size, otherwise not. Also, 64-bit vector types can be // have the same size, otherwise not.
// converted to x86mmx. if (isa<VectorType>(this) && isa<VectorType>(Ty))
if (auto *thisPTy = dyn_cast<VectorType>(this)) { return getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits();
if (auto *thatPTy = dyn_cast<VectorType>(Ty))
return thisPTy->getBitWidth() == thatPTy->getBitWidth();
if (Ty->getTypeID() == Type::X86_MMXTyID &&
thisPTy->getBitWidth() == 64)
return true;
}
if (this->getTypeID() == Type::X86_MMXTyID) // 64-bit fixed width vector types can be losslessly converted to x86mmx.
if (auto *thatPTy = dyn_cast<VectorType>(Ty)) if (((isa<VectorType>(this) &&
if (thatPTy->getBitWidth() == 64) !cast<VectorType>(this)->getElementCount().Scalable) &&
return true; Ty->isX86_MMXTy()) &&
getPrimitiveSizeInBits().getFixedSize() == 64)
return true;
if ((isX86_MMXTy() && (isa<VectorType>(Ty) &&
!cast<VectorType>(Ty)->getElementCount().Scalable)) &&
Ty->getPrimitiveSizeInBits().getFixedSize() == 64)
return true;
// At this point we have only various mismatches of the first class types // At this point we have only various mismatches of the first class types
// remaining and ptr->ptr. Just select the lossless conversions. Everything // remaining and ptr->ptr. Just select the lossless conversions. Everything
@ -125,7 +125,10 @@ TypeSize Type::getPrimitiveSizeInBits() const {
return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth()); return TypeSize::Fixed(cast<IntegerType>(this)->getBitWidth());
case Type::VectorTyID: { case Type::VectorTyID: {
const VectorType *VTy = cast<VectorType>(this); const VectorType *VTy = cast<VectorType>(this);
return TypeSize(VTy->getBitWidth(), VTy->isScalable()); ElementCount EC = VTy->getElementCount();
TypeSize ETS = VTy->getElementType()->getPrimitiveSizeInBits();
assert(!ETS.isScalable() && "Vector type should have fixed-width elements");
return {ETS.getFixedSize() * EC.Min, EC.Scalable};
} }
default: return TypeSize::Fixed(0); default: return TypeSize::Fixed(0);
} }

View File

@ -232,7 +232,7 @@ TEST(AsmParserTest, TypeWithSlotMappingParsing) {
// Check the details of the vector. // Check the details of the vector.
VectorType *VT = cast<VectorType>(Ty); VectorType *VT = cast<VectorType>(Ty);
ASSERT_TRUE(VT->getNumElements() == 5); ASSERT_TRUE(VT->getNumElements() == 5);
ASSERT_TRUE(VT->getBitWidth() == 160); ASSERT_TRUE(VT->getPrimitiveSizeInBits().getFixedSize() == 160);
Ty = VT->getElementType(); Ty = VT->getElementType();
ASSERT_TRUE(Ty->isIntegerTy()); ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32); ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
@ -364,7 +364,7 @@ TEST(AsmParserTest, TypeAtBeginningWithSlotMappingParsing) {
// Check the details of the vector. // Check the details of the vector.
VectorType *VT = cast<VectorType>(Ty); VectorType *VT = cast<VectorType>(Ty);
ASSERT_TRUE(VT->getNumElements() == 5); ASSERT_TRUE(VT->getNumElements() == 5);
ASSERT_TRUE(VT->getBitWidth() == 160); ASSERT_TRUE(VT->getPrimitiveSizeInBits().getFixedSize() == 160);
Ty = VT->getElementType(); Ty = VT->getElementType();
ASSERT_TRUE(Ty->isIntegerTy()); ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32); ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);