[llvm] [TTI] Make the rest of TTI::Concept/TTI::Model methods const (NFC) (PR #136668)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 22 01:20:12 PDT 2025


https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/136668

This will simplify future changes.

>From c8fd504e9ccd7e358487e01d51c9b5a0d1d95f28 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Mon, 21 Apr 2025 18:15:26 +0300
Subject: [PATCH] [TTI] Make the rest of TTI::Concept/TTI::Model methods const
 (NFC)

This will simplify future changes.
---
 .../llvm/Analysis/TargetTransformInfo.h       | 591 ++++++++++--------
 1 file changed, 313 insertions(+), 278 deletions(-)

diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index b5d766c34d09d..5a74523d37e81 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1923,7 +1923,7 @@ class TargetTransformInfo {
   /// implementation in a type erased interface.
   template <typename T> class Model;
 
-  std::unique_ptr<Concept> TTIImpl;
+  std::unique_ptr<const Concept> TTIImpl;
 };
 
 class TargetTransformInfo::Concept {
@@ -1933,37 +1933,37 @@ class TargetTransformInfo::Concept {
   virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
                                      ArrayRef<const Value *> Operands,
                                      Type *AccessType,
-                                     TTI::TargetCostKind CostKind) = 0;
+                                     TTI::TargetCostKind CostKind) const = 0;
   virtual InstructionCost
   getPointersChainCost(ArrayRef<const Value *> Ptrs, const Value *Base,
                        const TTI::PointersChainInfo &Info, Type *AccessTy,
-                       TTI::TargetCostKind CostKind) = 0;
+                       TTI::TargetCostKind CostKind) const = 0;
   virtual unsigned getInliningThresholdMultiplier() const = 0;
   virtual unsigned getInliningCostBenefitAnalysisSavingsMultiplier() const = 0;
   virtual unsigned
   getInliningCostBenefitAnalysisProfitableMultiplier() const = 0;
   virtual int getInliningLastCallToStaticBonus() const = 0;
-  virtual unsigned adjustInliningThreshold(const CallBase *CB) = 0;
+  virtual unsigned adjustInliningThreshold(const CallBase *CB) const = 0;
   virtual int getInlinerVectorBonusPercent() const = 0;
   virtual unsigned getCallerAllocaCost(const CallBase *CB,
                                        const AllocaInst *AI) const = 0;
-  virtual InstructionCost getMemcpyCost(const Instruction *I) = 0;
+  virtual InstructionCost getMemcpyCost(const Instruction *I) const = 0;
   virtual uint64_t getMaxMemIntrinsicInlineSizeThreshold() const = 0;
   virtual unsigned
   getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JTSize,
                                    ProfileSummaryInfo *PSI,
-                                   BlockFrequencyInfo *BFI) = 0;
+                                   BlockFrequencyInfo *BFI) const = 0;
   virtual InstructionCost getInstructionCost(const User *U,
                                              ArrayRef<const Value *> Operands,
-                                             TargetCostKind CostKind) = 0;
-  virtual BranchProbability getPredictableBranchThreshold() = 0;
-  virtual InstructionCost getBranchMispredictPenalty() = 0;
-  virtual bool hasBranchDivergence(const Function *F = nullptr) = 0;
-  virtual bool isSourceOfDivergence(const Value *V) = 0;
-  virtual bool isAlwaysUniform(const Value *V) = 0;
+                                             TargetCostKind CostKind) const = 0;
+  virtual BranchProbability getPredictableBranchThreshold() const = 0;
+  virtual InstructionCost getBranchMispredictPenalty() const = 0;
+  virtual bool hasBranchDivergence(const Function *F = nullptr) const = 0;
+  virtual bool isSourceOfDivergence(const Value *V) const = 0;
+  virtual bool isAlwaysUniform(const Value *V) const = 0;
   virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
   virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const = 0;
-  virtual unsigned getFlatAddressSpace() = 0;
+  virtual unsigned getFlatAddressSpace() const = 0;
   virtual bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                           Intrinsic::ID IID) const = 0;
   virtual bool isNoopAddrSpaceCast(unsigned FromAS, unsigned ToAS) const = 0;
@@ -1976,140 +1976,150 @@ class TargetTransformInfo::Concept {
   virtual Value *rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
                                                   Value *OldV,
                                                   Value *NewV) const = 0;
-  virtual bool isLoweredToCall(const Function *F) = 0;
-  virtual void getUnrollingPreferences(Loop *L, ScalarEvolution &,
-                                       UnrollingPreferences &UP,
-                                       OptimizationRemarkEmitter *ORE) = 0;
+  virtual bool isLoweredToCall(const Function *F) const = 0;
+  virtual void
+  getUnrollingPreferences(Loop *L, ScalarEvolution &, UnrollingPreferences &UP,
+                          OptimizationRemarkEmitter *ORE) const = 0;
   virtual void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
-                                     PeelingPreferences &PP) = 0;
+                                     PeelingPreferences &PP) const = 0;
   virtual bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
                                         AssumptionCache &AC,
                                         TargetLibraryInfo *LibInfo,
-                                        HardwareLoopInfo &HWLoopInfo) = 0;
-  virtual unsigned getEpilogueVectorizationMinVF() = 0;
-  virtual bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) = 0;
+                                        HardwareLoopInfo &HWLoopInfo) const = 0;
+  virtual unsigned getEpilogueVectorizationMinVF() const = 0;
+  virtual bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const = 0;
   virtual TailFoldingStyle
-  getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) = 0;
-  virtual std::optional<Instruction *> instCombineIntrinsic(
-      InstCombiner &IC, IntrinsicInst &II) = 0;
-  virtual std::optional<Value *> simplifyDemandedUseBitsIntrinsic(
-      InstCombiner &IC, IntrinsicInst &II, APInt DemandedMask,
-      KnownBits & Known, bool &KnownBitsComputed) = 0;
+  getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) const = 0;
+  virtual std::optional<Instruction *>
+  instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const = 0;
+  virtual std::optional<Value *>
+  simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II,
+                                   APInt DemandedMask, KnownBits &Known,
+                                   bool &KnownBitsComputed) const = 0;
   virtual std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
-      InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts,
-      APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3,
+      InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
+      APInt &UndefElts2, APInt &UndefElts3,
       std::function<void(Instruction *, unsigned, APInt, APInt &)>
-          SimplifyAndSetOp) = 0;
-  virtual bool isLegalAddImmediate(int64_t Imm) = 0;
-  virtual bool isLegalAddScalableImmediate(int64_t Imm) = 0;
-  virtual bool isLegalICmpImmediate(int64_t Imm) = 0;
+          SimplifyAndSetOp) const = 0;
+  virtual bool isLegalAddImmediate(int64_t Imm) const = 0;
+  virtual bool isLegalAddScalableImmediate(int64_t Imm) const = 0;
+  virtual bool isLegalICmpImmediate(int64_t Imm) const = 0;
   virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
                                      int64_t BaseOffset, bool HasBaseReg,
                                      int64_t Scale, unsigned AddrSpace,
                                      Instruction *I,
-                                     int64_t ScalableOffset) = 0;
+                                     int64_t ScalableOffset) const = 0;
   virtual bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
-                             const TargetTransformInfo::LSRCost &C2) = 0;
-  virtual bool isNumRegsMajorCostOfLSR() = 0;
+                             const TargetTransformInfo::LSRCost &C2) const = 0;
+  virtual bool isNumRegsMajorCostOfLSR() const = 0;
   virtual bool shouldDropLSRSolutionIfLessProfitable() const = 0;
-  virtual bool isProfitableLSRChainElement(Instruction *I) = 0;
-  virtual bool canMacroFuseCmp() = 0;
+  virtual bool isProfitableLSRChainElement(Instruction *I) const = 0;
+  virtual bool canMacroFuseCmp() const = 0;
   virtual bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE,
                           LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC,
-                          TargetLibraryInfo *LibInfo) = 0;
+                          TargetLibraryInfo *LibInfo) const = 0;
   virtual AddressingModeKind
     getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const = 0;
   virtual bool isLegalMaskedStore(Type *DataType, Align Alignment,
-                                  unsigned AddressSpace) = 0;
+                                  unsigned AddressSpace) const = 0;
   virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment,
-                                 unsigned AddressSpace) = 0;
-  virtual bool isLegalNTStore(Type *DataType, Align Alignment) = 0;
-  virtual bool isLegalNTLoad(Type *DataType, Align Alignment) = 0;
+                                 unsigned AddressSpace) const = 0;
+  virtual bool isLegalNTStore(Type *DataType, Align Alignment) const = 0;
+  virtual bool isLegalNTLoad(Type *DataType, Align Alignment) const = 0;
   virtual bool isLegalBroadcastLoad(Type *ElementTy,
                                     ElementCount NumElements) const = 0;
-  virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) = 0;
-  virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) = 0;
+  virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) const = 0;
+  virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) const = 0;
   virtual bool forceScalarizeMaskedGather(VectorType *DataType,
-                                          Align Alignment) = 0;
+                                          Align Alignment) const = 0;
   virtual bool forceScalarizeMaskedScatter(VectorType *DataType,
-                                           Align Alignment) = 0;
-  virtual bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) = 0;
-  virtual bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) = 0;
-  virtual bool isLegalStridedLoadStore(Type *DataType, Align Alignment) = 0;
+                                           Align Alignment) const = 0;
+  virtual bool isLegalMaskedCompressStore(Type *DataType,
+                                          Align Alignment) const = 0;
+  virtual bool isLegalMaskedExpandLoad(Type *DataType,
+                                       Align Alignment) const = 0;
+  virtual bool isLegalStridedLoadStore(Type *DataType,
+                                       Align Alignment) const = 0;
   virtual bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
                                             Align Alignment,
-                                            unsigned AddrSpace) = 0;
+                                            unsigned AddrSpace) const = 0;
 
-  virtual bool isLegalMaskedVectorHistogram(Type *AddrType, Type *DataType) = 0;
+  virtual bool isLegalMaskedVectorHistogram(Type *AddrType,
+                                            Type *DataType) const = 0;
   virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0,
                                unsigned Opcode1,
                                const SmallBitVector &OpcodeMask) const = 0;
-  virtual bool enableOrderedReductions() = 0;
-  virtual bool hasDivRemOp(Type *DataType, bool IsSigned) = 0;
-  virtual bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) = 0;
-  virtual bool prefersVectorizedAddressing() = 0;
+  virtual bool enableOrderedReductions() const = 0;
+  virtual bool hasDivRemOp(Type *DataType, bool IsSigned) const = 0;
+  virtual bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) const = 0;
+  virtual bool prefersVectorizedAddressing() const = 0;
   virtual InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
                                                StackOffset BaseOffset,
                                                bool HasBaseReg, int64_t Scale,
-                                               unsigned AddrSpace) = 0;
-  virtual bool LSRWithInstrQueries() = 0;
-  virtual bool isTruncateFree(Type *Ty1, Type *Ty2) = 0;
-  virtual bool isProfitableToHoist(Instruction *I) = 0;
-  virtual bool useAA() = 0;
+                                               unsigned AddrSpace) const = 0;
+  virtual bool LSRWithInstrQueries() const = 0;
+  virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const = 0;
+  virtual bool isProfitableToHoist(Instruction *I) const = 0;
+  virtual bool useAA() const = 0;
   virtual bool isTypeLegal(Type *Ty) const = 0;
   virtual unsigned getRegUsageForType(Type *Ty) const = 0;
-  virtual bool shouldBuildLookupTables() = 0;
-  virtual bool shouldBuildLookupTablesForConstant(Constant *C) = 0;
-  virtual bool shouldBuildRelLookupTables() = 0;
-  virtual bool useColdCCForColdCall(Function &F) = 0;
-  virtual bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) = 0;
-  virtual bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
-                                                  unsigned ScalarOpdIdx) = 0;
+  virtual bool shouldBuildLookupTables() const = 0;
+  virtual bool shouldBuildLookupTablesForConstant(Constant *C) const = 0;
+  virtual bool shouldBuildRelLookupTables() const = 0;
+  virtual bool useColdCCForColdCall(Function &F) const = 0;
+  virtual bool
+  isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) const = 0;
+  virtual bool
+  isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
+                                     unsigned ScalarOpdIdx) const = 0;
   virtual bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
-                                                      int OpdIdx) = 0;
+                                                      int OpdIdx) const = 0;
   virtual bool
   isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID,
-                                                   int RetIdx) = 0;
+                                                   int RetIdx) const = 0;
   virtual InstructionCost
   getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
                            bool Insert, bool Extract, TargetCostKind CostKind,
-                           ArrayRef<Value *> VL = {}) = 0;
+                           ArrayRef<Value *> VL = {}) const = 0;
   virtual InstructionCost
   getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
                                    ArrayRef<Type *> Tys,
-                                   TargetCostKind CostKind) = 0;
-  virtual bool supportsEfficientVectorElementLoadStore() = 0;
-  virtual bool supportsTailCalls() = 0;
-  virtual bool supportsTailCallFor(const CallBase *CB) = 0;
-  virtual bool enableAggressiveInterleaving(bool LoopHasReductions) = 0;
+                                   TargetCostKind CostKind) const = 0;
+  virtual bool supportsEfficientVectorElementLoadStore() const = 0;
+  virtual bool supportsTailCalls() const = 0;
+  virtual bool supportsTailCallFor(const CallBase *CB) const = 0;
+  virtual bool enableAggressiveInterleaving(bool LoopHasReductions) const = 0;
   virtual MemCmpExpansionOptions
   enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const = 0;
-  virtual bool enableSelectOptimize() = 0;
-  virtual bool shouldTreatInstructionLikeSelect(const Instruction *I) = 0;
-  virtual bool enableInterleavedAccessVectorization() = 0;
-  virtual bool enableMaskedInterleavedAccessVectorization() = 0;
-  virtual bool isFPVectorizationPotentiallyUnsafe() = 0;
+  virtual bool enableSelectOptimize() const = 0;
+  virtual bool shouldTreatInstructionLikeSelect(const Instruction *I) const = 0;
+  virtual bool enableInterleavedAccessVectorization() const = 0;
+  virtual bool enableMaskedInterleavedAccessVectorization() const = 0;
+  virtual bool isFPVectorizationPotentiallyUnsafe() const = 0;
   virtual bool allowsMisalignedMemoryAccesses(LLVMContext &Context,
                                               unsigned BitWidth,
                                               unsigned AddressSpace,
                                               Align Alignment,
-                                              unsigned *Fast) = 0;
-  virtual PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) = 0;
-  virtual bool haveFastSqrt(Type *Ty) = 0;
-  virtual bool isExpensiveToSpeculativelyExecute(const Instruction *I) = 0;
-  virtual bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) = 0;
-  virtual InstructionCost getFPOpCost(Type *Ty) = 0;
+                                              unsigned *Fast) const = 0;
+  virtual PopcntSupportKind
+  getPopcntSupport(unsigned IntTyWidthInBit) const = 0;
+  virtual bool haveFastSqrt(Type *Ty) const = 0;
+  virtual bool
+  isExpensiveToSpeculativelyExecute(const Instruction *I) const = 0;
+  virtual bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const = 0;
+  virtual InstructionCost getFPOpCost(Type *Ty) const = 0;
   virtual InstructionCost getIntImmCodeSizeCost(unsigned Opc, unsigned Idx,
-                                                const APInt &Imm, Type *Ty) = 0;
+                                                const APInt &Imm,
+                                                Type *Ty) const = 0;
   virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
-                                        TargetCostKind CostKind) = 0;
-  virtual InstructionCost getIntImmCostInst(unsigned Opc, unsigned Idx,
-                                            const APInt &Imm, Type *Ty,
-                                            TargetCostKind CostKind,
-                                            Instruction *Inst = nullptr) = 0;
-  virtual InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx,
-                                              const APInt &Imm, Type *Ty,
-                                              TargetCostKind CostKind) = 0;
+                                        TargetCostKind CostKind) const = 0;
+  virtual InstructionCost
+  getIntImmCostInst(unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty,
+                    TargetCostKind CostKind,
+                    Instruction *Inst = nullptr) const = 0;
+  virtual InstructionCost
+  getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
+                      Type *Ty, TargetCostKind CostKind) const = 0;
   virtual bool preferToKeepConstantsAttached(const Instruction &Inst,
                                              const Function &Fn) const = 0;
   virtual unsigned getNumberOfRegisters(unsigned ClassID) const = 0;
@@ -2130,7 +2140,7 @@ class TargetTransformInfo::Concept {
   virtual unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy,
                                      Type *ScalarValTy) const = 0;
   virtual bool shouldConsiderAddressTypePromotion(
-      const Instruction &I, bool &AllowPromotionWithoutCommonHeader) = 0;
+      const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const = 0;
   virtual unsigned getCacheLineSize() const = 0;
   virtual std::optional<unsigned> getCacheSize(CacheLevel Level) const = 0;
   virtual std::optional<unsigned> getCacheAssociativity(CacheLevel Level)
@@ -2178,39 +2188,43 @@ class TargetTransformInfo::Concept {
                           PartialReductionExtendKind OpBExtend,
                           std::optional<unsigned> BinOp) const = 0;
 
-  virtual unsigned getMaxInterleaveFactor(ElementCount VF) = 0;
-  virtual InstructionCost getArithmeticInstrCost(
-      unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
-      OperandValueInfo Opd1Info, OperandValueInfo Opd2Info,
-      ArrayRef<const Value *> Args, const Instruction *CxtI = nullptr) = 0;
+  virtual unsigned getMaxInterleaveFactor(ElementCount VF) const = 0;
+  virtual InstructionCost
+  getArithmeticInstrCost(unsigned Opcode, Type *Ty,
+                         TTI::TargetCostKind CostKind,
+                         OperandValueInfo Opd1Info, OperandValueInfo Opd2Info,
+                         ArrayRef<const Value *> Args,
+                         const Instruction *CxtI = nullptr) const = 0;
   virtual InstructionCost getAltInstrCost(
       VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
       const SmallBitVector &OpcodeMask,
       TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const = 0;
 
-  virtual InstructionCost
-  getShuffleCost(ShuffleKind Kind, VectorType *Tp, ArrayRef<int> Mask,
-                 TTI::TargetCostKind CostKind, int Index, VectorType *SubTp,
-                 ArrayRef<const Value *> Args, const Instruction *CxtI) = 0;
+  virtual InstructionCost getShuffleCost(ShuffleKind Kind, VectorType *Tp,
+                                         ArrayRef<int> Mask,
+                                         TTI::TargetCostKind CostKind,
+                                         int Index, VectorType *SubTp,
+                                         ArrayRef<const Value *> Args,
+                                         const Instruction *CxtI) const = 0;
   virtual InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst,
                                            Type *Src, CastContextHint CCH,
                                            TTI::TargetCostKind CostKind,
-                                           const Instruction *I) = 0;
+                                           const Instruction *I) const = 0;
   virtual InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst,
                                                    VectorType *VecTy,
-                                                   unsigned Index) = 0;
-  virtual InstructionCost getCFInstrCost(unsigned Opcode,
-                                         TTI::TargetCostKind CostKind,
-                                         const Instruction *I = nullptr) = 0;
+                                                   unsigned Index) const = 0;
+  virtual InstructionCost
+  getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
+                 const Instruction *I = nullptr) const = 0;
   virtual InstructionCost
   getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
                      CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind,
                      OperandValueInfo Op1Info, OperandValueInfo Op2Info,
-                     const Instruction *I) = 0;
+                     const Instruction *I) const = 0;
   virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
                                              TTI::TargetCostKind CostKind,
                                              unsigned Index, Value *Op0,
-                                             Value *Op1) = 0;
+                                             Value *Op1) const = 0;
 
   /// \param ScalarUserAndIdx encodes the information about extracts from a
   /// vector with 'Scalar' being the value being extracted,'User' being the user
@@ -2219,81 +2233,84 @@ class TargetTransformInfo::Concept {
   virtual InstructionCost getVectorInstrCost(
       unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
       Value *Scalar,
-      ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) = 0;
+      ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) const = 0;
 
   virtual InstructionCost getVectorInstrCost(const Instruction &I, Type *Val,
                                              TTI::TargetCostKind CostKind,
-                                             unsigned Index) = 0;
+                                             unsigned Index) const = 0;
 
   virtual InstructionCost
   getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
                             const APInt &DemandedDstElts,
-                            TTI::TargetCostKind CostKind) = 0;
+                            TTI::TargetCostKind CostKind) const = 0;
 
   virtual InstructionCost
-  getInsertExtractValueCost(unsigned Opcode, TTI::TargetCostKind CostKind) = 0;
+  getInsertExtractValueCost(unsigned Opcode,
+                            TTI::TargetCostKind CostKind) const = 0;
 
   virtual InstructionCost
   getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
                   unsigned AddressSpace, TTI::TargetCostKind CostKind,
-                  OperandValueInfo OpInfo, const Instruction *I) = 0;
+                  OperandValueInfo OpInfo, const Instruction *I) const = 0;
   virtual InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src,
                                             Align Alignment,
                                             unsigned AddressSpace,
                                             TTI::TargetCostKind CostKind,
-                                            const Instruction *I) = 0;
+                                            const Instruction *I) const = 0;
   virtual InstructionCost
   getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
                         unsigned AddressSpace,
-                        TTI::TargetCostKind CostKind) = 0;
+                        TTI::TargetCostKind CostKind) const = 0;
   virtual InstructionCost
   getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
                          bool VariableMask, Align Alignment,
                          TTI::TargetCostKind CostKind,
-                         const Instruction *I = nullptr) = 0;
+                         const Instruction *I = nullptr) const = 0;
   virtual InstructionCost getExpandCompressMemoryOpCost(
       unsigned Opcode, Type *DataTy, bool VariableMask, Align Alignment,
-      TTI::TargetCostKind CostKind, const Instruction *I = nullptr) = 0;
+      TTI::TargetCostKind CostKind, const Instruction *I = nullptr) const = 0;
   virtual InstructionCost
   getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
                          bool VariableMask, Align Alignment,
                          TTI::TargetCostKind CostKind,
-                         const Instruction *I = nullptr) = 0;
+                         const Instruction *I = nullptr) const = 0;
 
   virtual InstructionCost getInterleavedMemoryOpCost(
       unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
       Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
-      bool UseMaskForCond = false, bool UseMaskForGaps = false) = 0;
+      bool UseMaskForCond = false, bool UseMaskForGaps = false) const = 0;
   virtual InstructionCost
   getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
                              std::optional<FastMathFlags> FMF,
-                             TTI::TargetCostKind CostKind) = 0;
+                             TTI::TargetCostKind CostKind) const = 0;
   virtual InstructionCost
   getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
-                         TTI::TargetCostKind CostKind) = 0;
+                         TTI::TargetCostKind CostKind) const = 0;
   virtual InstructionCost getExtendedReductionCost(
       unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty,
       std::optional<FastMathFlags> FMF,
-      TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) = 0;
+      TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const = 0;
   virtual InstructionCost getMulAccReductionCost(
       bool IsUnsigned, Type *ResTy, VectorType *Ty,
-      TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) = 0;
+      TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) const = 0;
   virtual InstructionCost
   getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
-                        TTI::TargetCostKind CostKind) = 0;
-  virtual InstructionCost getCallInstrCost(Function *F, Type *RetTy,
-                                           ArrayRef<Type *> Tys,
-                                           TTI::TargetCostKind CostKind) = 0;
-  virtual unsigned getNumberOfParts(Type *Tp) = 0;
+                        TTI::TargetCostKind CostKind) const = 0;
   virtual InstructionCost
-  getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr) = 0;
+  getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys,
+                   TTI::TargetCostKind CostKind) const = 0;
+  virtual unsigned getNumberOfParts(Type *Tp) const = 0;
+  virtual InstructionCost getAddressComputationCost(Type *Ty,
+                                                    ScalarEvolution *SE,
+                                                    const SCEV *Ptr) const = 0;
   virtual InstructionCost
-  getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) = 0;
+  getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const = 0;
   virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst,
-                                  MemIntrinsicInfo &Info) = 0;
+                                  MemIntrinsicInfo &Info) const = 0;
   virtual unsigned getAtomicMemIntrinsicMaxElementSize() const = 0;
-  virtual Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
-                                                   Type *ExpectedType) = 0;
+  virtual Value *
+  getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
+                                    Type *ExpectedType) const = 0;
   virtual Type *getMemcpyLoopLoweringType(
       LLVMContext &Context, Value *Length, unsigned SrcAddrSpace,
       unsigned DestAddrSpace, Align SrcAlign, Align DestAlign,
@@ -2380,20 +2397,20 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
   InstructionCost
   getGEPCost(Type *PointeeType, const Value *Ptr,
              ArrayRef<const Value *> Operands, Type *AccessType,
-             TargetTransformInfo::TargetCostKind CostKind) override {
+             TargetTransformInfo::TargetCostKind CostKind) const override {
     return Impl.getGEPCost(PointeeType, Ptr, Operands, AccessType, CostKind);
   }
   InstructionCost getPointersChainCost(ArrayRef<const Value *> Ptrs,
                                        const Value *Base,
                                        const PointersChainInfo &Info,
                                        Type *AccessTy,
-                                       TargetCostKind CostKind) override {
+                                       TargetCostKind CostKind) const override {
     return Impl.getPointersChainCost(Ptrs, Base, Info, AccessTy, CostKind);
   }
   unsigned getInliningThresholdMultiplier() const override {
     return Impl.getInliningThresholdMultiplier();
   }
-  unsigned adjustInliningThreshold(const CallBase *CB) override {
+  unsigned adjustInliningThreshold(const CallBase *CB) const override {
     return Impl.adjustInliningThreshold(CB);
   }
   unsigned getInliningCostBenefitAnalysisSavingsMultiplier() const override {
@@ -2412,7 +2429,7 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
                                const AllocaInst *AI) const override {
     return Impl.getCallerAllocaCost(CB, AI);
   }
-  InstructionCost getMemcpyCost(const Instruction *I) override {
+  InstructionCost getMemcpyCost(const Instruction *I) const override {
     return Impl.getMemcpyCost(I);
   }
 
@@ -2422,23 +2439,23 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
 
   InstructionCost getInstructionCost(const User *U,
                                      ArrayRef<const Value *> Operands,
-                                     TargetCostKind CostKind) override {
+                                     TargetCostKind CostKind) const override {
     return Impl.getInstructionCost(U, Operands, CostKind);
   }
-  BranchProbability getPredictableBranchThreshold() override {
+  BranchProbability getPredictableBranchThreshold() const override {
     return Impl.getPredictableBranchThreshold();
   }
-  InstructionCost getBranchMispredictPenalty() override {
+  InstructionCost getBranchMispredictPenalty() const override {
     return Impl.getBranchMispredictPenalty();
   }
-  bool hasBranchDivergence(const Function *F = nullptr) override {
+  bool hasBranchDivergence(const Function *F = nullptr) const override {
     return Impl.hasBranchDivergence(F);
   }
-  bool isSourceOfDivergence(const Value *V) override {
+  bool isSourceOfDivergence(const Value *V) const override {
     return Impl.isSourceOfDivergence(V);
   }
 
-  bool isAlwaysUniform(const Value *V) override {
+  bool isAlwaysUniform(const Value *V) const override {
     return Impl.isAlwaysUniform(V);
   }
 
@@ -2450,7 +2467,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
     return Impl.addrspacesMayAlias(AS0, AS1);
   }
 
-  unsigned getFlatAddressSpace() override { return Impl.getFlatAddressSpace(); }
+  unsigned getFlatAddressSpace() const override {
+    return Impl.getFlatAddressSpace();
+  }
 
   bool collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes,
                                   Intrinsic::ID IID) const override {
@@ -2482,41 +2501,41 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
     return Impl.rewriteIntrinsicWithAddressSpace(II, OldV, NewV);
   }
 
-  bool isLoweredToCall(const Function *F) override {
+  bool isLoweredToCall(const Function *F) const override {
     return Impl.isLoweredToCall(F);
   }
   void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
                                UnrollingPreferences &UP,
-                               OptimizationRemarkEmitter *ORE) override {
+                               OptimizationRemarkEmitter *ORE) const override {
     return Impl.getUnrollingPreferences(L, SE, UP, ORE);
   }
   void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
-                             PeelingPreferences &PP) override {
+                             PeelingPreferences &PP) const override {
     return Impl.getPeelingPreferences(L, SE, PP);
   }
   bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE,
                                 AssumptionCache &AC, TargetLibraryInfo *LibInfo,
-                                HardwareLoopInfo &HWLoopInfo) override {
+                                HardwareLoopInfo &HWLoopInfo) const override {
     return Impl.isHardwareLoopProfitable(L, SE, AC, LibInfo, HWLoopInfo);
   }
-  unsigned getEpilogueVectorizationMinVF() override {
+  unsigned getEpilogueVectorizationMinVF() const override {
     return Impl.getEpilogueVectorizationMinVF();
   }
-  bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) override {
+  bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const override {
     return Impl.preferPredicateOverEpilogue(TFI);
   }
   TailFoldingStyle
-  getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) override {
+  getPreferredTailFoldingStyle(bool IVUpdateMayOverflow = true) const override {
     return Impl.getPreferredTailFoldingStyle(IVUpdateMayOverflow);
   }
   std::optional<Instruction *>
-  instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) override {
+  instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const override {
     return Impl.instCombineIntrinsic(IC, II);
   }
   std::optional<Value *>
   simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II,
                                    APInt DemandedMask, KnownBits &Known,
-                                   bool &KnownBitsComputed) override {
+                                   bool &KnownBitsComputed) const override {
     return Impl.simplifyDemandedUseBitsIntrinsic(IC, II, DemandedMask, Known,
                                                  KnownBitsComputed);
   }
@@ -2524,43 +2543,44 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
       InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
       APInt &UndefElts2, APInt &UndefElts3,
       std::function<void(Instruction *, unsigned, APInt, APInt &)>
-          SimplifyAndSetOp) override {
+          SimplifyAndSetOp) const override {
     return Impl.simplifyDemandedVectorEltsIntrinsic(
         IC, II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
         SimplifyAndSetOp);
   }
-  bool isLegalAddImmediate(int64_t Imm) override {
+  bool isLegalAddImmediate(int64_t Imm) const override {
     return Impl.isLegalAddImmediate(Imm);
   }
-  bool isLegalAddScalableImmediate(int64_t Imm) override {
+  bool isLegalAddScalableImmediate(int64_t Imm) const override {
     return Impl.isLegalAddScalableImmediate(Imm);
   }
-  bool isLegalICmpImmediate(int64_t Imm) override {
+  bool isLegalICmpImmediate(int64_t Imm) const override {
     return Impl.isLegalICmpImmediate(Imm);
   }
   bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
                              bool HasBaseReg, int64_t Scale, unsigned AddrSpace,
-                             Instruction *I, int64_t ScalableOffset) override {
+                             Instruction *I,
+                             int64_t ScalableOffset) const override {
     return Impl.isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg, Scale,
                                       AddrSpace, I, ScalableOffset);
   }
   bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
-                     const TargetTransformInfo::LSRCost &C2) override {
+                     const TargetTransformInfo::LSRCost &C2) const override {
     return Impl.isLSRCostLess(C1, C2);
   }
-  bool isNumRegsMajorCostOfLSR() override {
+  bool isNumRegsMajorCostOfLSR() const override {
     return Impl.isNumRegsMajorCostOfLSR();
   }
   bool shouldDropLSRSolutionIfLessProfitable() const override {
     return Impl.shouldDropLSRSolutionIfLessProfitable();
   }
-  bool isProfitableLSRChainElement(Instruction *I) override {
+  bool isProfitableLSRChainElement(Instruction *I) const override {
     return Impl.isProfitableLSRChainElement(I);
   }
-  bool canMacroFuseCmp() override { return Impl.canMacroFuseCmp(); }
+  bool canMacroFuseCmp() const override { return Impl.canMacroFuseCmp(); }
   bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI,
                   DominatorTree *DT, AssumptionCache *AC,
-                  TargetLibraryInfo *LibInfo) override {
+                  TargetLibraryInfo *LibInfo) const override {
     return Impl.canSaveCmp(L, BI, SE, LI, DT, AC, LibInfo);
   }
   AddressingModeKind
@@ -2569,206 +2589,212 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
     return Impl.getPreferredAddressingMode(L, SE);
   }
   bool isLegalMaskedStore(Type *DataType, Align Alignment,
-                          unsigned AddressSpace) override {
+                          unsigned AddressSpace) const override {
     return Impl.isLegalMaskedStore(DataType, Alignment, AddressSpace);
   }
   bool isLegalMaskedLoad(Type *DataType, Align Alignment,
-                         unsigned AddressSpace) override {
+                         unsigned AddressSpace) const override {
     return Impl.isLegalMaskedLoad(DataType, Alignment, AddressSpace);
   }
-  bool isLegalNTStore(Type *DataType, Align Alignment) override {
+  bool isLegalNTStore(Type *DataType, Align Alignment) const override {
     return Impl.isLegalNTStore(DataType, Alignment);
   }
-  bool isLegalNTLoad(Type *DataType, Align Alignment) override {
+  bool isLegalNTLoad(Type *DataType, Align Alignment) const override {
     return Impl.isLegalNTLoad(DataType, Alignment);
   }
   bool isLegalBroadcastLoad(Type *ElementTy,
                             ElementCount NumElements) const override {
     return Impl.isLegalBroadcastLoad(ElementTy, NumElements);
   }
-  bool isLegalMaskedScatter(Type *DataType, Align Alignment) override {
+  bool isLegalMaskedScatter(Type *DataType, Align Alignment) const override {
     return Impl.isLegalMaskedScatter(DataType, Alignment);
   }
-  bool isLegalMaskedGather(Type *DataType, Align Alignment) override {
+  bool isLegalMaskedGather(Type *DataType, Align Alignment) const override {
     return Impl.isLegalMaskedGather(DataType, Alignment);
   }
   bool forceScalarizeMaskedGather(VectorType *DataType,
-                                  Align Alignment) override {
+                                  Align Alignment) const override {
     return Impl.forceScalarizeMaskedGather(DataType, Alignment);
   }
   bool forceScalarizeMaskedScatter(VectorType *DataType,
-                                   Align Alignment) override {
+                                   Align Alignment) const override {
     return Impl.forceScalarizeMaskedScatter(DataType, Alignment);
   }
-  bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) override {
+  bool isLegalMaskedCompressStore(Type *DataType,
+                                  Align Alignment) const override {
     return Impl.isLegalMaskedCompressStore(DataType, Alignment);
   }
-  bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) override {
+  bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const override {
     return Impl.isLegalMaskedExpandLoad(DataType, Alignment);
   }
-  bool isLegalStridedLoadStore(Type *DataType, Align Alignment) override {
+  bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const override {
     return Impl.isLegalStridedLoadStore(DataType, Alignment);
   }
   bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
                                     Align Alignment,
-                                    unsigned AddrSpace) override {
+                                    unsigned AddrSpace) const override {
     return Impl.isLegalInterleavedAccessType(VTy, Factor, Alignment, AddrSpace);
   }
-  bool isLegalMaskedVectorHistogram(Type *AddrType, Type *DataType) override {
+  bool isLegalMaskedVectorHistogram(Type *AddrType,
+                                    Type *DataType) const override {
     return Impl.isLegalMaskedVectorHistogram(AddrType, DataType);
   }
   bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
                        const SmallBitVector &OpcodeMask) const override {
     return Impl.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask);
   }
-  bool enableOrderedReductions() override {
+  bool enableOrderedReductions() const override {
     return Impl.enableOrderedReductions();
   }
-  bool hasDivRemOp(Type *DataType, bool IsSigned) override {
+  bool hasDivRemOp(Type *DataType, bool IsSigned) const override {
     return Impl.hasDivRemOp(DataType, IsSigned);
   }
-  bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) override {
+  bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) const override {
     return Impl.hasVolatileVariant(I, AddrSpace);
   }
-  bool prefersVectorizedAddressing() override {
+  bool prefersVectorizedAddressing() const override {
     return Impl.prefersVectorizedAddressing();
   }
   InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV,
                                        StackOffset BaseOffset, bool HasBaseReg,
                                        int64_t Scale,
-                                       unsigned AddrSpace) override {
+                                       unsigned AddrSpace) const override {
     return Impl.getScalingFactorCost(Ty, BaseGV, BaseOffset, HasBaseReg, Scale,
                                      AddrSpace);
   }
-  bool LSRWithInstrQueries() override { return Impl.LSRWithInstrQueries(); }
-  bool isTruncateFree(Type *Ty1, Type *Ty2) override {
+  bool LSRWithInstrQueries() const override {
+    return Impl.LSRWithInstrQueries();
+  }
+  bool isTruncateFree(Type *Ty1, Type *Ty2) const override {
     return Impl.isTruncateFree(Ty1, Ty2);
   }
-  bool isProfitableToHoist(Instruction *I) override {
+  bool isProfitableToHoist(Instruction *I) const override {
     return Impl.isProfitableToHoist(I);
   }
-  bool useAA() override { return Impl.useAA(); }
+  bool useAA() const override { return Impl.useAA(); }
   bool isTypeLegal(Type *Ty) const override { return Impl.isTypeLegal(Ty); }
   unsigned getRegUsageForType(Type *Ty) const override {
     return Impl.getRegUsageForType(Ty);
   }
-  bool shouldBuildLookupTables() override {
+  bool shouldBuildLookupTables() const override {
     return Impl.shouldBuildLookupTables();
   }
-  bool shouldBuildLookupTablesForConstant(Constant *C) override {
+  bool shouldBuildLookupTablesForConstant(Constant *C) const override {
     return Impl.shouldBuildLookupTablesForConstant(C);
   }
-  bool shouldBuildRelLookupTables() override {
+  bool shouldBuildRelLookupTables() const override {
     return Impl.shouldBuildRelLookupTables();
   }
-  bool useColdCCForColdCall(Function &F) override {
+  bool useColdCCForColdCall(Function &F) const override {
     return Impl.useColdCCForColdCall(F);
   }
-  bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) override {
+  bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) const override {
     return Impl.isTargetIntrinsicTriviallyScalarizable(ID);
   }
 
-  bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
-                                          unsigned ScalarOpdIdx) override {
+  bool
+  isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
+                                     unsigned ScalarOpdIdx) const override {
     return Impl.isTargetIntrinsicWithScalarOpAtArg(ID, ScalarOpdIdx);
   }
 
   bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID,
-                                              int OpdIdx) override {
+                                              int OpdIdx) const override {
     return Impl.isTargetIntrinsicWithOverloadTypeAtArg(ID, OpdIdx);
   }
 
-  bool isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID,
-                                                        int RetIdx) override {
+  bool
+  isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID,
+                                                   int RetIdx) const override {
     return Impl.isTargetIntrinsicWithStructReturnOverloadAtField(ID, RetIdx);
   }
 
-  InstructionCost getScalarizationOverhead(VectorType *Ty,
-                                           const APInt &DemandedElts,
-                                           bool Insert, bool Extract,
-                                           TargetCostKind CostKind,
-                                           ArrayRef<Value *> VL = {}) override {
+  InstructionCost
+  getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
+                           bool Insert, bool Extract, TargetCostKind CostKind,
+                           ArrayRef<Value *> VL = {}) const override {
     return Impl.getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
                                          CostKind, VL);
   }
   InstructionCost
   getOperandsScalarizationOverhead(ArrayRef<const Value *> Args,
                                    ArrayRef<Type *> Tys,
-                                   TargetCostKind CostKind) override {
+                                   TargetCostKind CostKind) const override {
     return Impl.getOperandsScalarizationOverhead(Args, Tys, CostKind);
   }
 
-  bool supportsEfficientVectorElementLoadStore() override {
+  bool supportsEfficientVectorElementLoadStore() const override {
     return Impl.supportsEfficientVectorElementLoadStore();
   }
 
-  bool supportsTailCalls() override { return Impl.supportsTailCalls(); }
-  bool supportsTailCallFor(const CallBase *CB) override {
+  bool supportsTailCalls() const override { return Impl.supportsTailCalls(); }
+  bool supportsTailCallFor(const CallBase *CB) const override {
     return Impl.supportsTailCallFor(CB);
   }
 
-  bool enableAggressiveInterleaving(bool LoopHasReductions) override {
+  bool enableAggressiveInterleaving(bool LoopHasReductions) const override {
     return Impl.enableAggressiveInterleaving(LoopHasReductions);
   }
   MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize,
                                                bool IsZeroCmp) const override {
     return Impl.enableMemCmpExpansion(OptSize, IsZeroCmp);
   }
-  bool enableSelectOptimize() override {
+  bool enableSelectOptimize() const override {
     return Impl.enableSelectOptimize();
   }
-  bool shouldTreatInstructionLikeSelect(const Instruction *I) override {
+  bool shouldTreatInstructionLikeSelect(const Instruction *I) const override {
     return Impl.shouldTreatInstructionLikeSelect(I);
   }
-  bool enableInterleavedAccessVectorization() override {
+  bool enableInterleavedAccessVectorization() const override {
     return Impl.enableInterleavedAccessVectorization();
   }
-  bool enableMaskedInterleavedAccessVectorization() override {
+  bool enableMaskedInterleavedAccessVectorization() const override {
     return Impl.enableMaskedInterleavedAccessVectorization();
   }
-  bool isFPVectorizationPotentiallyUnsafe() override {
+  bool isFPVectorizationPotentiallyUnsafe() const override {
     return Impl.isFPVectorizationPotentiallyUnsafe();
   }
   bool allowsMisalignedMemoryAccesses(LLVMContext &Context, unsigned BitWidth,
                                       unsigned AddressSpace, Align Alignment,
-                                      unsigned *Fast) override {
+                                      unsigned *Fast) const override {
     return Impl.allowsMisalignedMemoryAccesses(Context, BitWidth, AddressSpace,
                                                Alignment, Fast);
   }
-  PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) override {
+  PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const override {
     return Impl.getPopcntSupport(IntTyWidthInBit);
   }
-  bool haveFastSqrt(Type *Ty) override { return Impl.haveFastSqrt(Ty); }
+  bool haveFastSqrt(Type *Ty) const override { return Impl.haveFastSqrt(Ty); }
 
-  bool isExpensiveToSpeculativelyExecute(const Instruction* I) override {
+  bool isExpensiveToSpeculativelyExecute(const Instruction *I) const override {
     return Impl.isExpensiveToSpeculativelyExecute(I);
   }
 
-  bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) override {
+  bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const override {
     return Impl.isFCmpOrdCheaperThanFCmpZero(Ty);
   }
 
-  InstructionCost getFPOpCost(Type *Ty) override {
+  InstructionCost getFPOpCost(Type *Ty) const override {
     return Impl.getFPOpCost(Ty);
   }
 
   InstructionCost getIntImmCodeSizeCost(unsigned Opc, unsigned Idx,
-                                        const APInt &Imm, Type *Ty) override {
+                                        const APInt &Imm,
+                                        Type *Ty) const override {
     return Impl.getIntImmCodeSizeCost(Opc, Idx, Imm, Ty);
   }
   InstructionCost getIntImmCost(const APInt &Imm, Type *Ty,
-                                TargetCostKind CostKind) override {
+                                TargetCostKind CostKind) const override {
     return Impl.getIntImmCost(Imm, Ty, CostKind);
   }
-  InstructionCost getIntImmCostInst(unsigned Opc, unsigned Idx,
-                                    const APInt &Imm, Type *Ty,
-                                    TargetCostKind CostKind,
-                                    Instruction *Inst = nullptr) override {
+  InstructionCost
+  getIntImmCostInst(unsigned Opc, unsigned Idx, const APInt &Imm, Type *Ty,
+                    TargetCostKind CostKind,
+                    Instruction *Inst = nullptr) const override {
     return Impl.getIntImmCostInst(Opc, Idx, Imm, Ty, CostKind, Inst);
   }
   InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx,
                                       const APInt &Imm, Type *Ty,
-                                      TargetCostKind CostKind) override {
+                                      TargetCostKind CostKind) const override {
     return Impl.getIntImmCostIntrin(IID, Idx, Imm, Ty, CostKind);
   }
   bool preferToKeepConstantsAttached(const Instruction &Inst,
@@ -2819,7 +2845,8 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
     return Impl.getStoreMinimumVF(VF, ScalarMemTy, ScalarValTy);
   }
   bool shouldConsiderAddressTypePromotion(
-      const Instruction &I, bool &AllowPromotionWithoutCommonHeader) override {
+      const Instruction &I,
+      bool &AllowPromotionWithoutCommonHeader) const override {
     return Impl.shouldConsiderAddressTypePromotion(
         I, AllowPromotionWithoutCommonHeader);
   }
@@ -2880,20 +2907,21 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
                                         BinOp);
   }
 
-  unsigned getMaxInterleaveFactor(ElementCount VF) override {
+  unsigned getMaxInterleaveFactor(ElementCount VF) const override {
     return Impl.getMaxInterleaveFactor(VF);
   }
-  unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI,
-                                            unsigned &JTSize,
-                                            ProfileSummaryInfo *PSI,
-                                            BlockFrequencyInfo *BFI) override {
+  unsigned
+  getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JTSize,
+                                   ProfileSummaryInfo *PSI,
+                                   BlockFrequencyInfo *BFI) const override {
     return Impl.getEstimatedNumberOfCaseClusters(SI, JTSize, PSI, BFI);
   }
-  InstructionCost getArithmeticInstrCost(
-      unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
-      OperandValueInfo Opd1Info, OperandValueInfo Opd2Info,
-      ArrayRef<const Value *> Args,
-      const Instruction *CxtI = nullptr) override {
+  InstructionCost
+  getArithmeticInstrCost(unsigned Opcode, Type *Ty,
+                         TTI::TargetCostKind CostKind,
+                         OperandValueInfo Opd1Info, OperandValueInfo Opd2Info,
+                         ArrayRef<const Value *> Args,
+                         const Instruction *CxtI = nullptr) const override {
     return Impl.getArithmeticInstrCost(Opcode, Ty, CostKind, Opd1Info, Opd2Info,
                                        Args, CxtI);
   }
@@ -2909,23 +2937,24 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
                                  TTI::TargetCostKind CostKind, int Index,
                                  VectorType *SubTp,
                                  ArrayRef<const Value *> Args,
-                                 const Instruction *CxtI) override {
+                                 const Instruction *CxtI) const override {
     return Impl.getShuffleCost(Kind, Tp, Mask, CostKind, Index, SubTp, Args,
                                CxtI);
   }
   InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
                                    CastContextHint CCH,
                                    TTI::TargetCostKind CostKind,
-                                   const Instruction *I) override {
+                                   const Instruction *I) const override {
     return Impl.getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
   }
   InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst,
                                            VectorType *VecTy,
-                                           unsigned Index) override {
+                                           unsigned Index) const override {
     return Impl.getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
   }
-  InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
-                                 const Instruction *I = nullptr) override {
+  InstructionCost
+  getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind,
+                 const Instruction *I = nullptr) const override {
     return Impl.getCFInstrCost(Opcode, CostKind, I);
   }
   InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
@@ -2933,58 +2962,60 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
                                      TTI::TargetCostKind CostKind,
                                      OperandValueInfo Op1Info,
                                      OperandValueInfo Op2Info,
-                                     const Instruction *I) override {
+                                     const Instruction *I) const override {
     return Impl.getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
                                    Op1Info, Op2Info, I);
   }
   InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
                                      TTI::TargetCostKind CostKind,
                                      unsigned Index, Value *Op0,
-                                     Value *Op1) override {
+                                     Value *Op1) const override {
     return Impl.getVectorInstrCost(Opcode, Val, CostKind, Index, Op0, Op1);
   }
-  InstructionCost getVectorInstrCost(
-      unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
-      Value *Scalar,
-      ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) override {
+  InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
+                                     TTI::TargetCostKind CostKind,
+                                     unsigned Index, Value *Scalar,
+                                     ArrayRef<std::tuple<Value *, User *, int>>
+                                         ScalarUserAndIdx) const override {
     return Impl.getVectorInstrCost(Opcode, Val, CostKind, Index, Scalar,
                                    ScalarUserAndIdx);
   }
   InstructionCost getVectorInstrCost(const Instruction &I, Type *Val,
                                      TTI::TargetCostKind CostKind,
-                                     unsigned Index) override {
+                                     unsigned Index) const override {
     return Impl.getVectorInstrCost(I, Val, CostKind, Index);
   }
   InstructionCost
   getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
                             const APInt &DemandedDstElts,
-                            TTI::TargetCostKind CostKind) override {
+                            TTI::TargetCostKind CostKind) const override {
     return Impl.getReplicationShuffleCost(EltTy, ReplicationFactor, VF,
                                           DemandedDstElts, CostKind);
   }
   InstructionCost
   getInsertExtractValueCost(unsigned Opcode,
-                            TTI::TargetCostKind CostKind) override {
+                            TTI::TargetCostKind CostKind) const override {
     return Impl.getInsertExtractValueCost(Opcode, CostKind);
   }
   InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
                                   unsigned AddressSpace,
                                   TTI::TargetCostKind CostKind,
                                   OperandValueInfo OpInfo,
-                                  const Instruction *I) override {
+                                  const Instruction *I) const override {
     return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, CostKind,
                                 OpInfo, I);
   }
   InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
                                     unsigned AddressSpace,
                                     TTI::TargetCostKind CostKind,
-                                    const Instruction *I) override {
+                                    const Instruction *I) const override {
     return Impl.getVPMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
                                   CostKind, I);
   }
-  InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
-                                        Align Alignment, unsigned AddressSpace,
-                                        TTI::TargetCostKind CostKind) override {
+  InstructionCost
+  getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
+                        unsigned AddressSpace,
+                        TTI::TargetCostKind CostKind) const override {
     return Impl.getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
                                       CostKind);
   }
@@ -2992,13 +3023,15 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
   getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
                          bool VariableMask, Align Alignment,
                          TTI::TargetCostKind CostKind,
-                         const Instruction *I = nullptr) override {
+                         const Instruction *I = nullptr) const override {
     return Impl.getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask,
                                        Alignment, CostKind, I);
   }
-  InstructionCost getExpandCompressMemoryOpCost(
-      unsigned Opcode, Type *DataTy, bool VariableMask, Align Alignment,
-      TTI::TargetCostKind CostKind, const Instruction *I = nullptr) override {
+  InstructionCost
+  getExpandCompressMemoryOpCost(unsigned Opcode, Type *DataTy,
+                                bool VariableMask, Align Alignment,
+                                TTI::TargetCostKind CostKind,
+                                const Instruction *I = nullptr) const override {
     return Impl.getExpandCompressMemoryOpCost(Opcode, DataTy, VariableMask,
                                               Alignment, CostKind, I);
   }
@@ -3006,14 +3039,14 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
   getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr,
                          bool VariableMask, Align Alignment,
                          TTI::TargetCostKind CostKind,
-                         const Instruction *I = nullptr) override {
+                         const Instruction *I = nullptr) const override {
     return Impl.getStridedMemoryOpCost(Opcode, DataTy, Ptr, VariableMask,
                                        Alignment, CostKind, I);
   }
   InstructionCost getInterleavedMemoryOpCost(
       unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
       Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
-      bool UseMaskForCond, bool UseMaskForGaps) override {
+      bool UseMaskForCond, bool UseMaskForGaps) const override {
     return Impl.getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
                                            Alignment, AddressSpace, CostKind,
                                            UseMaskForCond, UseMaskForGaps);
@@ -3021,54 +3054,56 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
   InstructionCost
   getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
                              std::optional<FastMathFlags> FMF,
-                             TTI::TargetCostKind CostKind) override {
+                             TTI::TargetCostKind CostKind) const override {
     return Impl.getArithmeticReductionCost(Opcode, Ty, FMF, CostKind);
   }
   InstructionCost
   getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
-                         TTI::TargetCostKind CostKind) override {
+                         TTI::TargetCostKind CostKind) const override {
     return Impl.getMinMaxReductionCost(IID, Ty, FMF, CostKind);
   }
   InstructionCost
   getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
                            VectorType *Ty, std::optional<FastMathFlags> FMF,
-                           TTI::TargetCostKind CostKind) override {
+                           TTI::TargetCostKind CostKind) const override {
     return Impl.getExtendedReductionCost(Opcode, IsUnsigned, ResTy, Ty, FMF,
                                          CostKind);
   }
   InstructionCost
   getMulAccReductionCost(bool IsUnsigned, Type *ResTy, VectorType *Ty,
-                         TTI::TargetCostKind CostKind) override {
+                         TTI::TargetCostKind CostKind) const override {
     return Impl.getMulAccReductionCost(IsUnsigned, ResTy, Ty, CostKind);
   }
-  InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
-                                        TTI::TargetCostKind CostKind) override {
+  InstructionCost
+  getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
+                        TTI::TargetCostKind CostKind) const override {
     return Impl.getIntrinsicInstrCost(ICA, CostKind);
   }
-  InstructionCost getCallInstrCost(Function *F, Type *RetTy,
-                                   ArrayRef<Type *> Tys,
-                                   TTI::TargetCostKind CostKind) override {
+  InstructionCost
+  getCallInstrCost(Function *F, Type *RetTy, ArrayRef<Type *> Tys,
+                   TTI::TargetCostKind CostKind) const override {
     return Impl.getCallInstrCost(F, RetTy, Tys, CostKind);
   }
-  unsigned getNumberOfParts(Type *Tp) override {
+  unsigned getNumberOfParts(Type *Tp) const override {
     return Impl.getNumberOfParts(Tp);
   }
   InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
-                                            const SCEV *Ptr) override {
+                                            const SCEV *Ptr) const override {
     return Impl.getAddressComputationCost(Ty, SE, Ptr);
   }
-  InstructionCost getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) override {
+  InstructionCost
+  getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const override {
     return Impl.getCostOfKeepingLiveOverCall(Tys);
   }
   bool getTgtMemIntrinsic(IntrinsicInst *Inst,
-                          MemIntrinsicInfo &Info) override {
+                          MemIntrinsicInfo &Info) const override {
     return Impl.getTgtMemIntrinsic(Inst, Info);
   }
   unsigned getAtomicMemIntrinsicMaxElementSize() const override {
     return Impl.getAtomicMemIntrinsicMaxElementSize();
   }
   Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
-                                           Type *ExpectedType) override {
+                                           Type *ExpectedType) const override {
     return Impl.getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
   }
   Type *getMemcpyLoopLoweringType(



More information about the llvm-commits mailing list