@@ -379,11 +379,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
379379 return (CallerBits & CalleeBits) == CalleeBits;
380380 }
381381
382- bool hasBranchDivergence (const Function *F = nullptr ) { return false ; }
382+ bool hasBranchDivergence (const Function *F = nullptr ) const { return false ; }
383383
384- bool isSourceOfDivergence (const Value *V) { return false ; }
384+ bool isSourceOfDivergence (const Value *V) const { return false ; }
385385
386- bool isAlwaysUniform (const Value *V) { return false ; }
386+ bool isAlwaysUniform (const Value *V) const { return false ; }
387387
388388 bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const {
389389 return false ;
@@ -393,7 +393,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
393393 return true ;
394394 }
395395
396- unsigned getFlatAddressSpace () {
396+ unsigned getFlatAddressSpace () const {
397397 // Return an invalid address space.
398398 return -1 ;
399399 }
@@ -426,22 +426,22 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
426426 return nullptr ;
427427 }
428428
429- bool isLegalAddImmediate (int64_t imm) {
429+ bool isLegalAddImmediate (int64_t imm) const {
430430 return getTLI ()->isLegalAddImmediate (imm);
431431 }
432432
433- bool isLegalAddScalableImmediate (int64_t Imm) {
433+ bool isLegalAddScalableImmediate (int64_t Imm) const {
434434 return getTLI ()->isLegalAddScalableImmediate (Imm);
435435 }
436436
437- bool isLegalICmpImmediate (int64_t imm) {
437+ bool isLegalICmpImmediate (int64_t imm) const {
438438 return getTLI ()->isLegalICmpImmediate (imm);
439439 }
440440
441441 bool isLegalAddressingMode (Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
442442 bool HasBaseReg, int64_t Scale, unsigned AddrSpace,
443443 Instruction *I = nullptr ,
444- int64_t ScalableOffset = 0 ) {
444+ int64_t ScalableOffset = 0 ) const {
445445 TargetLoweringBase::AddrMode AM;
446446 AM.BaseGV = BaseGV;
447447 AM.BaseOffs = BaseOffset;
@@ -487,25 +487,26 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
487487 return getTLI ()->isIndexedStoreLegal (getISDIndexedMode (M), VT);
488488 }
489489
490- bool isLSRCostLess (TTI::LSRCost C1, TTI::LSRCost C2) {
490+ bool isLSRCostLess (TTI::LSRCost C1, TTI::LSRCost C2) const {
491491 return TargetTransformInfoImplBase::isLSRCostLess (C1, C2);
492492 }
493493
494- bool isNumRegsMajorCostOfLSR () {
494+ bool isNumRegsMajorCostOfLSR () const {
495495 return TargetTransformInfoImplBase::isNumRegsMajorCostOfLSR ();
496496 }
497497
498498 bool shouldDropLSRSolutionIfLessProfitable () const {
499499 return TargetTransformInfoImplBase::shouldDropLSRSolutionIfLessProfitable ();
500500 }
501501
502- bool isProfitableLSRChainElement (Instruction *I) {
502+ bool isProfitableLSRChainElement (Instruction *I) const {
503503 return TargetTransformInfoImplBase::isProfitableLSRChainElement (I);
504504 }
505505
506506 InstructionCost getScalingFactorCost (Type *Ty, GlobalValue *BaseGV,
507507 StackOffset BaseOffset, bool HasBaseReg,
508- int64_t Scale, unsigned AddrSpace) {
508+ int64_t Scale,
509+ unsigned AddrSpace) const {
509510 TargetLoweringBase::AddrMode AM;
510511 AM.BaseGV = BaseGV;
511512 AM.BaseOffs = BaseOffset.getFixed ();
@@ -517,11 +518,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
517518 return InstructionCost::getInvalid ();
518519 }
519520
520- bool isTruncateFree (Type *Ty1, Type *Ty2) {
521+ bool isTruncateFree (Type *Ty1, Type *Ty2) const {
521522 return getTLI ()->isTruncateFree (Ty1, Ty2);
522523 }
523524
524- bool isProfitableToHoist (Instruction *I) {
525+ bool isProfitableToHoist (Instruction *I) const {
525526 return getTLI ()->isProfitableToHoist (I);
526527 }
527528
@@ -539,14 +540,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
539540
540541 InstructionCost getGEPCost (Type *PointeeType, const Value *Ptr,
541542 ArrayRef<const Value *> Operands, Type *AccessType,
542- TTI::TargetCostKind CostKind) {
543+ TTI::TargetCostKind CostKind) const {
543544 return BaseT::getGEPCost (PointeeType, Ptr, Operands, AccessType, CostKind);
544545 }
545546
546547 unsigned getEstimatedNumberOfCaseClusters (const SwitchInst &SI,
547548 unsigned &JumpTableSize,
548549 ProfileSummaryInfo *PSI,
549- BlockFrequencyInfo *BFI) {
550+ BlockFrequencyInfo *BFI) const {
550551 // / Try to find the estimated number of clusters. Note that the number of
551552 // / clusters identified in this function could be different from the actual
552553 // / numbers found in lowering. This function ignore switches that are
@@ -602,7 +603,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
602603 return N;
603604 }
604605
605- bool shouldBuildLookupTables () {
606+ bool shouldBuildLookupTables () const {
606607 const TargetLoweringBase *TLI = getTLI ();
607608 return TLI->isOperationLegalOrCustom (ISD::BR_JT, MVT::Other) ||
608609 TLI->isOperationLegalOrCustom (ISD::BRIND, MVT::Other);
@@ -633,18 +634,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
633634 return true ;
634635 }
635636
636- bool haveFastSqrt (Type *Ty) {
637+ bool haveFastSqrt (Type *Ty) const {
637638 const TargetLoweringBase *TLI = getTLI ();
638639 EVT VT = TLI->getValueType (DL, Ty);
639640 return TLI->isTypeLegal (VT) &&
640641 TLI->isOperationLegalOrCustom (ISD::FSQRT, VT);
641642 }
642643
643- bool isFCmpOrdCheaperThanFCmpZero (Type *Ty) {
644- return true ;
645- }
644+ bool isFCmpOrdCheaperThanFCmpZero (Type *Ty) const { return true ; }
646645
647- InstructionCost getFPOpCost (Type *Ty) {
646+ InstructionCost getFPOpCost (Type *Ty) const {
648647 // Check whether FADD is available, as a proxy for floating-point in
649648 // general.
650649 const TargetLoweringBase *TLI = getTLI ();
@@ -674,7 +673,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
674673 }
675674
676675 unsigned getInliningThresholdMultiplier () const { return 1 ; }
677- unsigned adjustInliningThreshold (const CallBase *CB) { return 0 ; }
676+ unsigned adjustInliningThreshold (const CallBase *CB) const { return 0 ; }
678677 unsigned getCallerAllocaCost (const CallBase *CB, const AllocaInst *AI) const {
679678 return 0 ;
680679 }
@@ -683,7 +682,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
683682
684683 void getUnrollingPreferences (Loop *L, ScalarEvolution &SE,
685684 TTI::UnrollingPreferences &UP,
686- OptimizationRemarkEmitter *ORE) {
685+ OptimizationRemarkEmitter *ORE) const {
687686 // This unrolling functionality is target independent, but to provide some
688687 // motivation for its intended use, for x86:
689688
@@ -754,42 +753,41 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
754753 }
755754
756755 void getPeelingPreferences (Loop *L, ScalarEvolution &SE,
757- TTI::PeelingPreferences &PP) {
756+ TTI::PeelingPreferences &PP) const {
758757 PP.PeelCount = 0 ;
759758 PP.AllowPeeling = true ;
760759 PP.AllowLoopNestsPeeling = false ;
761760 PP.PeelProfiledIterations = true ;
762761 }
763762
764763 bool isHardwareLoopProfitable (Loop *L, ScalarEvolution &SE,
765- AssumptionCache &AC,
766- TargetLibraryInfo *LibInfo,
767- HardwareLoopInfo &HWLoopInfo) {
764+ AssumptionCache &AC, TargetLibraryInfo *LibInfo,
765+ HardwareLoopInfo &HWLoopInfo) const {
768766 return BaseT::isHardwareLoopProfitable (L, SE, AC, LibInfo, HWLoopInfo);
769767 }
770768
771- unsigned getEpilogueVectorizationMinVF () {
769+ unsigned getEpilogueVectorizationMinVF () const {
772770 return BaseT::getEpilogueVectorizationMinVF ();
773771 }
774772
775- bool preferPredicateOverEpilogue (TailFoldingInfo *TFI) {
773+ bool preferPredicateOverEpilogue (TailFoldingInfo *TFI) const {
776774 return BaseT::preferPredicateOverEpilogue (TFI);
777775 }
778776
779777 TailFoldingStyle
780- getPreferredTailFoldingStyle (bool IVUpdateMayOverflow = true ) {
778+ getPreferredTailFoldingStyle (bool IVUpdateMayOverflow = true ) const {
781779 return BaseT::getPreferredTailFoldingStyle (IVUpdateMayOverflow);
782780 }
783781
784782 std::optional<Instruction *> instCombineIntrinsic (InstCombiner &IC,
785- IntrinsicInst &II) {
783+ IntrinsicInst &II) const {
786784 return BaseT::instCombineIntrinsic (IC, II);
787785 }
788786
789787 std::optional<Value *>
790788 simplifyDemandedUseBitsIntrinsic (InstCombiner &IC, IntrinsicInst &II,
791789 APInt DemandedMask, KnownBits &Known,
792- bool &KnownBitsComputed) {
790+ bool &KnownBitsComputed) const {
793791 return BaseT::simplifyDemandedUseBitsIntrinsic (IC, II, DemandedMask, Known,
794792 KnownBitsComputed);
795793 }
@@ -798,7 +796,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
798796 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
799797 APInt &UndefElts2, APInt &UndefElts3,
800798 std::function<void (Instruction *, unsigned , APInt, APInt &)>
801- SimplifyAndSetOp) {
799+ SimplifyAndSetOp) const {
802800 return BaseT::simplifyDemandedVectorEltsIntrinsic (
803801 IC, II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
804802 SimplifyAndSetOp);
@@ -1015,7 +1013,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
10151013 }
10161014 }
10171015
1018- unsigned getMaxInterleaveFactor (ElementCount VF) { return 1 ; }
1016+ unsigned getMaxInterleaveFactor (ElementCount VF) const { return 1 ; }
10191017
10201018 InstructionCost getArithmeticInstrCost (
10211019 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
@@ -1337,7 +1335,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
13371335 }
13381336
13391337 InstructionCost getExtractWithExtendCost (unsigned Opcode, Type *Dst,
1340- VectorType *VecTy, unsigned Index) {
1338+ VectorType *VecTy,
1339+ unsigned Index) const {
13411340 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
13421341 return thisT ()->getVectorInstrCost (Instruction::ExtractElement, VecTy,
13431342 CostKind, Index, nullptr , nullptr ) +
@@ -1417,14 +1416,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14171416 InstructionCost getVectorInstrCost (
14181417 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
14191418 Value *Scalar,
1420- ArrayRef<std::tuple<Value *, User *, int >> ScalarUserAndIdx) {
1419+ ArrayRef<std::tuple<Value *, User *, int >> ScalarUserAndIdx) const {
14211420 return thisT ()->getVectorInstrCost (Opcode, Val, CostKind, Index, nullptr ,
14221421 nullptr );
14231422 }
14241423
14251424 InstructionCost getVectorInstrCost (const Instruction &I, Type *Val,
14261425 TTI::TargetCostKind CostKind,
1427- unsigned Index) {
1426+ unsigned Index) const {
14281427 Value *Op0 = nullptr ;
14291428 Value *Op1 = nullptr ;
14301429 if (auto *IE = dyn_cast<InsertElementInst>(&I)) {
@@ -1554,7 +1553,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15541553 InstructionCost getInterleavedMemoryOpCost (
15551554 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned > Indices,
15561555 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
1557- bool UseMaskForCond = false , bool UseMaskForGaps = false ) {
1556+ bool UseMaskForCond = false , bool UseMaskForGaps = false ) const {
15581557
15591558 // We cannot scalarize scalable vectors, so return Invalid.
15601559 if (isa<ScalableVectorType>(VecTy))
@@ -2886,7 +2885,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
28862885 }
28872886
28882887 InstructionCost getAddressComputationCost (Type *Ty, ScalarEvolution *,
2889- const SCEV *) {
2888+ const SCEV *) const {
28902889 return 0 ;
28912890 }
28922891
@@ -3067,7 +3066,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
30673066 InstructionCost getExtendedReductionCost (unsigned Opcode, bool IsUnsigned,
30683067 Type *ResTy, VectorType *Ty,
30693068 std::optional<FastMathFlags> FMF,
3070- TTI::TargetCostKind CostKind) {
3069+ TTI::TargetCostKind CostKind) const {
30713070 if (auto *FTy = dyn_cast<FixedVectorType>(Ty);
30723071 FTy && IsUnsigned && Opcode == Instruction::Add &&
30733072 FTy->getElementType () == IntegerType::getInt1Ty (Ty->getContext ())) {
@@ -3095,7 +3094,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
30953094
30963095 InstructionCost getMulAccReductionCost (bool IsUnsigned, Type *ResTy,
30973096 VectorType *Ty,
3098- TTI::TargetCostKind CostKind) {
3097+ TTI::TargetCostKind CostKind) const {
30993098 // Without any native support, this is equivalent to the cost of
31003099 // vecreduce.add(mul(ext(Ty A), ext(Ty B))) or
31013100 // vecreduce.add(mul(A, B)).
0 commit comments