mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Remove asserting getters from base Type
Summary: Remove asserting vector getters from Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: dexonsmith, sdesmalen, efriedma Reviewed By: efriedma Subscribers: cfe-commits, hiraditya, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D77278
This commit is contained in:
parent
2bae4464ae
commit
2b02937417
@ -531,18 +531,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
unsigned Type::getVectorNumElements() const {
|
||||
return cast<VectorType>(this)->getNumElements();
|
||||
}
|
||||
|
||||
bool Type::getVectorIsScalable() const {
|
||||
return cast<VectorType>(this)->isScalable();
|
||||
}
|
||||
|
||||
ElementCount Type::getVectorElementCount() const {
|
||||
return cast<VectorType>(this)->getElementCount();
|
||||
}
|
||||
|
||||
bool Type::isVectorTy() const { return isa<VectorType>(this); }
|
||||
|
||||
/// Class to represent pointers.
|
||||
@ -597,8 +585,8 @@ Type *Type::getWithNewBitWidth(unsigned NewBitWidth) const {
|
||||
isIntOrIntVectorTy() &&
|
||||
"Original type expected to be a vector of integers or a scalar integer.");
|
||||
Type *NewType = getIntNTy(getContext(), NewBitWidth);
|
||||
if (isVectorTy())
|
||||
NewType = VectorType::get(NewType, getVectorElementCount());
|
||||
if (auto *VTy = dyn_cast<VectorType>(this))
|
||||
NewType = VectorType::get(NewType, VTy->getElementCount());
|
||||
return NewType;
|
||||
}
|
||||
|
||||
@ -606,6 +594,12 @@ unsigned Type::getPointerAddressSpace() const {
|
||||
return cast<PointerType>(getScalarType())->getAddressSpace();
|
||||
}
|
||||
|
||||
Type *Type::getScalarType() const {
|
||||
if (isVectorTy())
|
||||
return cast<VectorType>(this)->getElementType();
|
||||
return const_cast<Type *>(this);
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_DERIVEDTYPES_H
|
||||
|
@ -300,11 +300,7 @@ public:
|
||||
|
||||
/// If this is a vector type, return the element type, otherwise return
|
||||
/// 'this'.
|
||||
Type *getScalarType() const {
|
||||
if (isVectorTy())
|
||||
return getVectorElementType();
|
||||
return const_cast<Type*>(this);
|
||||
}
|
||||
inline Type *getScalarType() const;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Type Iteration support.
|
||||
@ -339,8 +335,8 @@ public:
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Helper methods corresponding to subclass methods. This forces a cast to
|
||||
// the specified subclass and calls its accessor. "getVectorNumElements" (for
|
||||
// example) is shorthand for cast<VectorType>(Ty)->getNumElements(). This is
|
||||
// the specified subclass and calls its accessor. "getArrayNumElements" (for
|
||||
// example) is shorthand for cast<ArrayType>(Ty)->getNumElements(). This is
|
||||
// only intended to cover the core methods that are frequently used, helper
|
||||
// methods should not be added here.
|
||||
|
||||
@ -361,14 +357,6 @@ public:
|
||||
return ContainedTys[0];
|
||||
}
|
||||
|
||||
inline bool getVectorIsScalable() const;
|
||||
inline unsigned getVectorNumElements() const;
|
||||
inline ElementCount getVectorElementCount() const;
|
||||
Type *getVectorElementType() const {
|
||||
assert(getTypeID() == VectorTyID);
|
||||
return ContainedTys[0];
|
||||
}
|
||||
|
||||
Type *getPointerElementType() const {
|
||||
assert(getTypeID() == PointerTyID);
|
||||
return ContainedTys[0];
|
||||
|
@ -5262,7 +5262,7 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
|
||||
if (!RewriteGEP && Ops.size() == 2)
|
||||
return false;
|
||||
|
||||
unsigned NumElts = Ptr->getType()->getVectorNumElements();
|
||||
unsigned NumElts = cast<VectorType>(Ptr->getType())->getNumElements();
|
||||
|
||||
IRBuilder<> Builder(MemoryInst);
|
||||
|
||||
|
@ -4263,7 +4263,7 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
|
||||
|
||||
Base = SDB->getValue(C);
|
||||
|
||||
unsigned NumElts = Ptr->getType()->getVectorNumElements();
|
||||
unsigned NumElts = cast<VectorType>(Ptr->getType())->getNumElements();
|
||||
EVT VT = EVT::getVectorVT(*DAG.getContext(), TLI.getPointerTy(DL), NumElts);
|
||||
Index = DAG.getConstant(0, SDB->getCurSDLoc(), VT);
|
||||
IndexType = ISD::SIGNED_SCALED;
|
||||
|
@ -107,7 +107,7 @@ TEST_F(VPIntrinsicTest, GetParamPos) {
|
||||
if (MaskParamPos.hasValue()) {
|
||||
Type *MaskParamType = F.getArg(MaskParamPos.getValue())->getType();
|
||||
ASSERT_TRUE(MaskParamType->isVectorTy());
|
||||
ASSERT_TRUE(MaskParamType->getVectorElementType()->isIntegerTy(1));
|
||||
ASSERT_TRUE(cast<VectorType>(MaskParamType)->getElementType()->isIntegerTy(1));
|
||||
}
|
||||
|
||||
Optional<int> VecLenParamPos =
|
||||
|
Loading…
x
Reference in New Issue
Block a user