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

Clean up usages of asserting vector getters in Type

Summary:
Remove usages of asserting vector getters in Type in preparation for the
VectorType refactor. The existence of these functions complicates the
refactor while adding little value.

Reviewers: sdesmalen, efriedma, jonpa

Reviewed By: sdesmalen

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77265
This commit is contained in:
Christopher Tetreault 2020-04-10 07:53:02 -07:00
parent 98fd2737b2
commit 7c8e48cac4

View File

@ -359,7 +359,8 @@ static unsigned getScalarSizeInBits(Type *Ty) {
// 3. // 3.
static unsigned getNumVectorRegs(Type *Ty) { static unsigned getNumVectorRegs(Type *Ty) {
assert(Ty->isVectorTy() && "Expected vector type"); assert(Ty->isVectorTy() && "Expected vector type");
unsigned WideBits = getScalarSizeInBits(Ty) * Ty->getVectorNumElements(); unsigned WideBits =
getScalarSizeInBits(Ty) * cast<VectorType>(Ty)->getNumElements();
assert(WideBits > 0 && "Could not compute size of vector"); assert(WideBits > 0 && "Could not compute size of vector");
return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U)); return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U));
} }
@ -459,7 +460,7 @@ int SystemZTTIImpl::getArithmeticInstrCost(
return DivInstrCost; return DivInstrCost;
} }
else if (ST->hasVector()) { else if (ST->hasVector()) {
unsigned VF = Ty->getVectorNumElements(); unsigned VF = cast<VectorType>(Ty)->getNumElements();
unsigned NumVectors = getNumVectorRegs(Ty); unsigned NumVectors = getNumVectorRegs(Ty);
// These vector operations are custom handled, but are still supported // These vector operations are custom handled, but are still supported
@ -580,8 +581,9 @@ getVectorTruncCost(Type *SrcTy, Type *DstTy) {
assert (SrcTy->isVectorTy() && DstTy->isVectorTy()); assert (SrcTy->isVectorTy() && DstTy->isVectorTy());
assert (SrcTy->getPrimitiveSizeInBits() > DstTy->getPrimitiveSizeInBits() && assert (SrcTy->getPrimitiveSizeInBits() > DstTy->getPrimitiveSizeInBits() &&
"Packing must reduce size of vector type."); "Packing must reduce size of vector type.");
assert (SrcTy->getVectorNumElements() == DstTy->getVectorNumElements() && assert(cast<VectorType>(SrcTy)->getNumElements() ==
"Packing should not change number of elements."); cast<VectorType>(DstTy)->getNumElements() &&
"Packing should not change number of elements.");
// TODO: Since fp32 is expanded, the extract cost should always be 0. // TODO: Since fp32 is expanded, the extract cost should always be 0.
@ -596,7 +598,7 @@ getVectorTruncCost(Type *SrcTy, Type *DstTy) {
unsigned Cost = 0; unsigned Cost = 0;
unsigned Log2Diff = getElSizeLog2Diff(SrcTy, DstTy); unsigned Log2Diff = getElSizeLog2Diff(SrcTy, DstTy);
unsigned VF = SrcTy->getVectorNumElements(); unsigned VF = cast<VectorType>(SrcTy)->getNumElements();
for (unsigned P = 0; P < Log2Diff; ++P) { for (unsigned P = 0; P < Log2Diff; ++P) {
if (NumParts > 1) if (NumParts > 1)
NumParts /= 2; NumParts /= 2;
@ -670,7 +672,7 @@ unsigned SystemZTTIImpl::
getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
const Instruction *I) { const Instruction *I) {
assert (Dst->isVectorTy()); assert (Dst->isVectorTy());
unsigned VF = Dst->getVectorNumElements(); unsigned VF = cast<VectorType>(Dst)->getNumElements();
unsigned Cost = 0; unsigned Cost = 0;
// If we know what the widths of the compared operands, get any cost of // If we know what the widths of the compared operands, get any cost of
// converting it to match Dst. Otherwise assume same widths. // converting it to match Dst. Otherwise assume same widths.
@ -719,7 +721,7 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
} }
else if (ST->hasVector()) { else if (ST->hasVector()) {
assert (Dst->isVectorTy()); assert (Dst->isVectorTy());
unsigned VF = Src->getVectorNumElements(); unsigned VF = cast<VectorType>(Src)->getNumElements();
unsigned NumDstVectors = getNumVectorRegs(Dst); unsigned NumDstVectors = getNumVectorRegs(Dst);
unsigned NumSrcVectors = getNumVectorRegs(Src); unsigned NumSrcVectors = getNumVectorRegs(Src);
@ -846,7 +848,7 @@ int SystemZTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
} }
} }
else if (ST->hasVector()) { else if (ST->hasVector()) {
unsigned VF = ValTy->getVectorNumElements(); unsigned VF = cast<VectorType>(ValTy)->getNumElements();
// Called with a compare instruction. // Called with a compare instruction.
if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) { if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
@ -1089,7 +1091,7 @@ int SystemZTTIImpl::getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
// Return the ceiling of dividing A by B. // Return the ceiling of dividing A by B.
auto ceil = [](unsigned A, unsigned B) { return (A + B - 1) / B; }; auto ceil = [](unsigned A, unsigned B) { return (A + B - 1) / B; };
unsigned NumElts = VecTy->getVectorNumElements(); unsigned NumElts = cast<VectorType>(VecTy)->getNumElements();
assert(Factor > 1 && NumElts % Factor == 0 && "Invalid interleave factor"); assert(Factor > 1 && NumElts % Factor == 0 && "Invalid interleave factor");
unsigned VF = NumElts / Factor; unsigned VF = NumElts / Factor;
unsigned NumEltsPerVecReg = (128U / getScalarSizeInBits(VecTy)); unsigned NumEltsPerVecReg = (128U / getScalarSizeInBits(VecTy));