forked from OSchip/llvm-project
NFC: Change getIntrinsicInstrCost to return InstructionCost
This patch migrates the TTI cost interfaces to return an InstructionCost. See this patch for the introduction of the type: https://reviews.llvm.org/D91174 See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html Depends on D97468 Reviewed By: dmgreen Differential Revision: https://reviews.llvm.org/D97469
This commit is contained in:
parent
2f56e1c6b1
commit
2f6f249a49
|
@ -1197,8 +1197,8 @@ public:
|
|||
/// \returns The cost of Intrinsic instructions. Analyses the real arguments.
|
||||
/// Three cases are handled: 1. scalar instruction 2. vector instruction
|
||||
/// 3. scalar instruction which is to be vectorized.
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) const;
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) const;
|
||||
|
||||
/// \returns The cost of Call instructions.
|
||||
int getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys,
|
||||
|
@ -1607,8 +1607,9 @@ public:
|
|||
virtual InstructionCost getExtendedAddReductionCost(
|
||||
bool IsMLA, bool IsUnsigned, Type *ResTy, VectorType *Ty,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) = 0;
|
||||
virtual int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) = 0;
|
||||
virtual InstructionCost
|
||||
getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) = 0;
|
||||
virtual int getCallInstrCost(Function *F, Type *RetTy,
|
||||
ArrayRef<Type *> Tys,
|
||||
TTI::TargetCostKind CostKind) = 0;
|
||||
|
@ -2098,8 +2099,8 @@ public:
|
|||
return Impl.getExtendedAddReductionCost(IsMLA, IsUnsigned, ResTy, Ty,
|
||||
CostKind);
|
||||
}
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) override {
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) override {
|
||||
return Impl.getIntrinsicInstrCost(ICA, CostKind);
|
||||
}
|
||||
int getCallInstrCost(Function *F, Type *RetTy,
|
||||
|
|
|
@ -558,8 +558,8 @@ public:
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) const {
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) const {
|
||||
switch (ICA.getID()) {
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -1195,8 +1195,8 @@ public:
|
|||
}
|
||||
|
||||
/// Get intrinsic cost based on arguments.
|
||||
unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
// Check for generically free intrinsics.
|
||||
if (BaseT::getIntrinsicInstrCost(ICA, CostKind) == 0)
|
||||
return 0;
|
||||
|
@ -1207,7 +1207,7 @@ public:
|
|||
return TargetTransformInfo::TCC_Basic;
|
||||
|
||||
if (ICA.isTypeBasedOnly())
|
||||
return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue();
|
||||
return getTypeBasedIntrinsicInstrCost(ICA, CostKind);
|
||||
|
||||
Type *RetTy = ICA.getReturnType();
|
||||
|
||||
|
@ -1294,13 +1294,13 @@ public:
|
|||
case Intrinsic::vector_reduce_umax:
|
||||
case Intrinsic::vector_reduce_umin: {
|
||||
IntrinsicCostAttributes Attrs(IID, RetTy, Args[0]->getType(), FMF, I, 1);
|
||||
return *getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue();
|
||||
return getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
|
||||
}
|
||||
case Intrinsic::vector_reduce_fadd:
|
||||
case Intrinsic::vector_reduce_fmul: {
|
||||
IntrinsicCostAttributes Attrs(
|
||||
IID, RetTy, {Args[0]->getType(), Args[1]->getType()}, FMF, I, 1);
|
||||
return *getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue();
|
||||
return getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
|
||||
}
|
||||
case Intrinsic::fshl:
|
||||
case Intrinsic::fshr: {
|
||||
|
@ -1365,7 +1365,7 @@ public:
|
|||
|
||||
IntrinsicCostAttributes Attrs(IID, RetTy, ICA.getArgTypes(), FMF, I,
|
||||
ScalarizationCost);
|
||||
return *thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind).getValue();
|
||||
return thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
|
||||
}
|
||||
|
||||
/// Get intrinsic cost based on argument types.
|
||||
|
|
|
@ -851,10 +851,10 @@ int TargetTransformInfo::getInterleavedMemoryOpCost(
|
|||
return Cost;
|
||||
}
|
||||
|
||||
int
|
||||
InstructionCost
|
||||
TargetTransformInfo::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) const {
|
||||
int Cost = TTIImpl->getIntrinsicInstrCost(ICA, CostKind);
|
||||
InstructionCost Cost = TTIImpl->getIntrinsicInstrCost(ICA, CostKind);
|
||||
assert(Cost >= 0 && "TTI should not produce negative costs!");
|
||||
return Cost;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ AArch64TTIImpl::getPopcntSupport(unsigned TyWidth) {
|
|||
return TTI::PSK_Software;
|
||||
}
|
||||
|
||||
unsigned
|
||||
InstructionCost
|
||||
AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
auto *RetTy = ICA.getReturnType();
|
||||
|
|
|
@ -97,8 +97,8 @@ public:
|
|||
return 31;
|
||||
}
|
||||
|
||||
unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const {
|
||||
switch (K) {
|
||||
|
|
|
@ -727,8 +727,9 @@ static bool intrinsicHasPackedVectorBenefit(Intrinsic::ID ID) {
|
|||
}
|
||||
}
|
||||
|
||||
int GCNTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost
|
||||
GCNTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
if (ICA.getID() == Intrinsic::fabs)
|
||||
return 0;
|
||||
|
||||
|
@ -743,7 +744,7 @@ int GCNTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
|||
|
||||
// TODO: Combine these two logic paths.
|
||||
if (ICA.isTypeBasedOnly())
|
||||
return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue();
|
||||
return getTypeBasedIntrinsicInstrCost(ICA, CostKind);
|
||||
|
||||
unsigned RetVF =
|
||||
(RetTy->isVectorTy() ? cast<FixedVectorType>(RetTy)->getNumElements()
|
||||
|
|
|
@ -214,8 +214,8 @@ public:
|
|||
bool IsPairwise,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput);
|
||||
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
int getMinMaxReductionCost(
|
||||
VectorType *Ty, VectorType *CondTy, bool IsPairwiseForm, bool IsUnsigned,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput);
|
||||
|
|
|
@ -900,7 +900,7 @@ int ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
|
|||
if (Sel != I)
|
||||
return 0;
|
||||
IntrinsicCostAttributes CostAttrs(IID, ValTy, {ValTy, ValTy});
|
||||
return getIntrinsicInstrCost(CostAttrs, CostKind);
|
||||
return *getIntrinsicInstrCost(CostAttrs, CostKind).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1626,8 +1626,9 @@ ARMTTIImpl::getExtendedAddReductionCost(bool IsMLA, bool IsUnsigned,
|
|||
CostKind);
|
||||
}
|
||||
|
||||
int ARMTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost
|
||||
ARMTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
switch (ICA.getID()) {
|
||||
case Intrinsic::get_active_lane_mask:
|
||||
// Currently we make a somewhat optimistic assumption that
|
||||
|
|
|
@ -252,8 +252,8 @@ public:
|
|||
Type *ResTy, VectorType *ValTy,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
bool maybeLoweredToCall(Instruction &I);
|
||||
bool isLoweredToCall(const Function *F);
|
||||
|
|
|
@ -139,7 +139,7 @@ unsigned HexagonTTIImpl::getCallInstrCost(Function *F, Type *RetTy,
|
|||
return BaseT::getCallInstrCost(F, RetTy, Tys, CostKind);
|
||||
}
|
||||
|
||||
unsigned
|
||||
InstructionCost
|
||||
HexagonTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
if (ICA.getID() == Intrinsic::bswap) {
|
||||
|
|
|
@ -110,8 +110,8 @@ public:
|
|||
ArrayRef<Type *> Tys);
|
||||
unsigned getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type*> Tys,
|
||||
TTI::TargetCostKind CostKind);
|
||||
unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *SE,
|
||||
const SCEV *S);
|
||||
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
|
||||
|
|
|
@ -1209,8 +1209,9 @@ int PPCTTIImpl::getInterleavedMemoryOpCost(
|
|||
return Cost;
|
||||
}
|
||||
|
||||
unsigned PPCTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost
|
||||
PPCTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ public:
|
|||
Align Alignment, unsigned AddressSpace,
|
||||
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
|
||||
bool UseMaskForCond = false, bool UseMaskForGaps = false);
|
||||
unsigned getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
/// @}
|
||||
};
|
||||
|
|
|
@ -1191,9 +1191,11 @@ static int getVectorIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int SystemZTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
int Cost = getVectorIntrinsicInstrCost(ICA.getID(), ICA.getReturnType());
|
||||
InstructionCost
|
||||
SystemZTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost Cost =
|
||||
getVectorIntrinsicInstrCost(ICA.getID(), ICA.getReturnType());
|
||||
if (Cost != -1)
|
||||
return Cost;
|
||||
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
|
||||
|
|
|
@ -112,8 +112,8 @@ public:
|
|||
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
|
||||
bool UseMaskForCond = false, bool UseMaskForGaps = false);
|
||||
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
|
|
@ -2912,10 +2912,11 @@ X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
|||
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
|
||||
}
|
||||
|
||||
int X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
InstructionCost
|
||||
X86TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind) {
|
||||
if (ICA.isTypeBasedOnly())
|
||||
return *getTypeBasedIntrinsicInstrCost(ICA, CostKind).getValue();
|
||||
return getTypeBasedIntrinsicInstrCost(ICA, CostKind);
|
||||
|
||||
static const CostTblEntry AVX512CostTbl[] = {
|
||||
{ ISD::ROTL, MVT::v8i64, 1 },
|
||||
|
|
|
@ -170,8 +170,8 @@ public:
|
|||
InstructionCost
|
||||
getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
||||
TTI::TargetCostKind CostKind);
|
||||
|
||||
int getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
|
||||
bool IsPairwiseForm,
|
||||
|
|
Loading…
Reference in New Issue