@@ -341,7 +341,7 @@ class TargetTransformInfoImplBase {
341341 }
342342
343343 bool isLegalInterleavedAccessType (VectorType *VTy, unsigned Factor,
344- Align Alignment, unsigned AddrSpace) {
344+ Align Alignment, unsigned AddrSpace) const {
345345 return false ;
346346 }
347347
@@ -440,7 +440,7 @@ class TargetTransformInfoImplBase {
440440
441441 bool enableSelectOptimize () const { return true ; }
442442
443- bool shouldTreatInstructionLikeSelect (const Instruction *I) {
443+ bool shouldTreatInstructionLikeSelect (const Instruction *I) const {
444444 // A select with two constant operands will usually be better left as a
445445 // select.
446446 using namespace llvm ::PatternMatch;
@@ -747,7 +747,7 @@ class TargetTransformInfoImplBase {
747747
748748 unsigned getReplicationShuffleCost (Type *EltTy, int ReplicationFactor, int VF,
749749 const APInt &DemandedDstElts,
750- TTI::TargetCostKind CostKind) {
750+ TTI::TargetCostKind CostKind) const {
751751 return 1 ;
752752 }
753753
@@ -1170,7 +1170,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
11701170
11711171 InstructionCost getGEPCost (Type *PointeeType, const Value *Ptr,
11721172 ArrayRef<const Value *> Operands, Type *AccessType,
1173- TTI::TargetCostKind CostKind) {
1173+ TTI::TargetCostKind CostKind) const {
11741174 assert (PointeeType && Ptr && " can't get GEPCost of nullptr" );
11751175 auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts ());
11761176 bool HasBaseReg = (BaseGV == nullptr );
@@ -1234,7 +1234,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
12341234
12351235 // If the final address of the GEP is a legal addressing mode for the given
12361236 // access type, then we can fold it into its users.
1237- if (static_cast <T *>(this )->isLegalAddressingMode (
1237+ if (static_cast <const T *>(this )->isLegalAddressingMode (
12381238 AccessType, const_cast <GlobalValue *>(BaseGV),
12391239 BaseOffset.sextOrTrunc (64 ).getSExtValue (), HasBaseReg, Scale,
12401240 Ptr->getType ()->getPointerAddressSpace ()))
@@ -1250,7 +1250,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
12501250 const Value *Base,
12511251 const TTI::PointersChainInfo &Info,
12521252 Type *AccessTy,
1253- TTI::TargetCostKind CostKind) {
1253+ TTI::TargetCostKind CostKind) const {
12541254 InstructionCost Cost = TTI::TCC_Free;
12551255 // In the basic model we take into account GEP instructions only
12561256 // (although here can come alloca instruction, a value, constants and/or
@@ -1269,26 +1269,26 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
12691269 if (Info.isSameBase () && V != Base) {
12701270 if (GEP->hasAllConstantIndices ())
12711271 continue ;
1272- Cost += static_cast <T *>(this )->getArithmeticInstrCost (
1272+ Cost += static_cast <const T *>(this )->getArithmeticInstrCost (
12731273 Instruction::Add, GEP->getType (), CostKind,
12741274 {TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None},
12751275 {});
12761276 } else {
12771277 SmallVector<const Value *> Indices (GEP->indices ());
1278- Cost += static_cast <T *>(this )->getGEPCost (GEP-> getSourceElementType (),
1279- GEP->getPointerOperand (),
1280- Indices, AccessTy, CostKind);
1278+ Cost += static_cast <const T *>(this )->getGEPCost (
1279+ GEP-> getSourceElementType (), GEP->getPointerOperand (), Indices ,
1280+ AccessTy, CostKind);
12811281 }
12821282 }
12831283 return Cost;
12841284 }
12851285
12861286 InstructionCost getInstructionCost (const User *U,
12871287 ArrayRef<const Value *> Operands,
1288- TTI::TargetCostKind CostKind) {
1288+ TTI::TargetCostKind CostKind) const {
12891289 using namespace llvm ::PatternMatch;
12901290
1291- auto *TargetTTI = static_cast <T *>(this );
1291+ auto *TargetTTI = static_cast <const T *>(this );
12921292 // Handle non-intrinsic calls, invokes, and callbr.
12931293 // FIXME: Unlikely to be true for anything but CodeSize.
12941294 auto *CB = dyn_cast<CallBase>(U);
@@ -1585,8 +1585,8 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
15851585 return CostKind == TTI::TCK_RecipThroughput ? -1 : TTI::TCC_Basic;
15861586 }
15871587
1588- bool isExpensiveToSpeculativelyExecute (const Instruction *I) {
1589- auto *TargetTTI = static_cast <T *>(this );
1588+ bool isExpensiveToSpeculativelyExecute (const Instruction *I) const {
1589+ auto *TargetTTI = static_cast <const T *>(this );
15901590 SmallVector<const Value *, 4 > Ops (I->operand_values ());
15911591 InstructionCost Cost = TargetTTI->getInstructionCost (
15921592 I, Ops, TargetTransformInfo::TCK_SizeAndLatency);
0 commit comments