77// ===----------------------------------------------------------------------===//
88//
99// / \file
10- // / This file a TargetTransformInfo::Concept conforming object specific to the
10+ // / This file a TargetTransformInfoImplBase conforming object specific to the
1111// / AMDGPU target machine. It uses the target's detailed information to
1212// / provide more precise answers to certain TTI queries, while letting the
1313// / target independent and default TTI implementations handle the rest.
@@ -52,12 +52,12 @@ class AMDGPUTTIImpl final : public BasicTTIImplBase<AMDGPUTTIImpl> {
5252
5353 void getUnrollingPreferences (Loop *L, ScalarEvolution &SE,
5454 TTI::UnrollingPreferences &UP,
55- OptimizationRemarkEmitter *ORE) const ;
55+ OptimizationRemarkEmitter *ORE) const override ;
5656
5757 void getPeelingPreferences (Loop *L, ScalarEvolution &SE,
58- TTI::PeelingPreferences &PP) const ;
58+ TTI::PeelingPreferences &PP) const override ;
5959
60- uint64_t getMaxMemIntrinsicInlineSizeThreshold () const ;
60+ uint64_t getMaxMemIntrinsicInlineSizeThreshold () const override ;
6161};
6262
6363class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
@@ -104,64 +104,65 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
104104public:
105105 explicit GCNTTIImpl (const AMDGPUTargetMachine *TM, const Function &F);
106106
107- bool hasBranchDivergence (const Function *F = nullptr ) const ;
107+ bool hasBranchDivergence (const Function *F = nullptr ) const override ;
108108
109109 void getUnrollingPreferences (Loop *L, ScalarEvolution &SE,
110110 TTI::UnrollingPreferences &UP,
111- OptimizationRemarkEmitter *ORE) const ;
111+ OptimizationRemarkEmitter *ORE) const override ;
112112
113113 void getPeelingPreferences (Loop *L, ScalarEvolution &SE,
114- TTI::PeelingPreferences &PP) const ;
114+ TTI::PeelingPreferences &PP) const override ;
115115
116- TTI::PopcntSupportKind getPopcntSupport (unsigned TyWidth) const {
116+ TTI::PopcntSupportKind getPopcntSupport (unsigned TyWidth) const override {
117117 assert (isPowerOf2_32 (TyWidth) && " Ty width must be power of 2" );
118118 return TTI::PSK_FastHardware;
119119 }
120120
121- unsigned getNumberOfRegisters (unsigned RCID) const ;
122- TypeSize getRegisterBitWidth (TargetTransformInfo::RegisterKind Vector) const ;
123- unsigned getMinVectorRegisterBitWidth () const ;
124- unsigned getMaximumVF (unsigned ElemWidth, unsigned Opcode) const ;
121+ unsigned getNumberOfRegisters (unsigned RCID) const override ;
122+ TypeSize
123+ getRegisterBitWidth (TargetTransformInfo::RegisterKind Vector) const override ;
124+ unsigned getMinVectorRegisterBitWidth () const override ;
125+ unsigned getMaximumVF (unsigned ElemWidth, unsigned Opcode) const override ;
125126 unsigned getLoadVectorFactor (unsigned VF, unsigned LoadSize,
126127 unsigned ChainSizeInBytes,
127- VectorType *VecTy) const ;
128+ VectorType *VecTy) const override ;
128129 unsigned getStoreVectorFactor (unsigned VF, unsigned StoreSize,
129130 unsigned ChainSizeInBytes,
130- VectorType *VecTy) const ;
131- unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const ;
131+ VectorType *VecTy) const override ;
132+ unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const override ;
132133
133134 bool isLegalToVectorizeMemChain (unsigned ChainSizeInBytes, Align Alignment,
134135 unsigned AddrSpace) const ;
135136 bool isLegalToVectorizeLoadChain (unsigned ChainSizeInBytes, Align Alignment,
136- unsigned AddrSpace) const ;
137+ unsigned AddrSpace) const override ;
137138 bool isLegalToVectorizeStoreChain (unsigned ChainSizeInBytes, Align Alignment,
138- unsigned AddrSpace) const ;
139+ unsigned AddrSpace) const override ;
139140
140- uint64_t getMaxMemIntrinsicInlineSizeThreshold () const ;
141- Type *
142- getMemcpyLoopLoweringType (LLVMContext &Context, Value *Length,
143- unsigned SrcAddrSpace, unsigned DestAddrSpace,
144- Align SrcAlign, Align DestAlign,
145- std::optional<uint32_t > AtomicElementSize) const ;
141+ uint64_t getMaxMemIntrinsicInlineSizeThreshold () const override ;
142+ Type *getMemcpyLoopLoweringType (
143+ LLVMContext &Context, Value *Length, unsigned SrcAddrSpace,
144+ unsigned DestAddrSpace, Align SrcAlign, Align DestAlign,
145+ std::optional<uint32_t > AtomicElementSize) const override ;
146146
147147 void getMemcpyLoopResidualLoweringType (
148148 SmallVectorImpl<Type *> &OpsOut, LLVMContext &Context,
149149 unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace,
150150 Align SrcAlign, Align DestAlign,
151- std::optional<uint32_t > AtomicCpySize) const ;
152- unsigned getMaxInterleaveFactor (ElementCount VF) const ;
151+ std::optional<uint32_t > AtomicCpySize) const override ;
152+ unsigned getMaxInterleaveFactor (ElementCount VF) const override ;
153153
154- bool getTgtMemIntrinsic (IntrinsicInst *Inst, MemIntrinsicInfo &Info) const ;
154+ bool getTgtMemIntrinsic (IntrinsicInst *Inst,
155+ MemIntrinsicInfo &Info) const override ;
155156
156157 InstructionCost getArithmeticInstrCost (
157158 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
158159 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
159160 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
160161 ArrayRef<const Value *> Args = {},
161- const Instruction *CxtI = nullptr ) const ;
162+ const Instruction *CxtI = nullptr ) const override ;
162163
163164 InstructionCost getCFInstrCost (unsigned Opcode, TTI::TargetCostKind CostKind,
164- const Instruction *I = nullptr ) const ;
165+ const Instruction *I = nullptr ) const override ;
165166
166167 bool isInlineAsmSourceOfDivergence (const CallInst *CI,
167168 ArrayRef<unsigned > Indices = {}) const ;
@@ -170,13 +171,13 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
170171 InstructionCost getVectorInstrCost (unsigned Opcode, Type *ValTy,
171172 TTI::TargetCostKind CostKind,
172173 unsigned Index, Value *Op0,
173- Value *Op1) const ;
174+ Value *Op1) const override ;
174175
175176 bool isReadRegisterSourceOfDivergence (const IntrinsicInst *ReadReg) const ;
176- bool isSourceOfDivergence (const Value *V) const ;
177- bool isAlwaysUniform (const Value *V) const ;
177+ bool isSourceOfDivergence (const Value *V) const override ;
178+ bool isAlwaysUniform (const Value *V) const override ;
178179
179- bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const {
180+ bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const override {
180181 // Address space casts must cast between different address spaces.
181182 if (FromAS == ToAS)
182183 return false ;
@@ -197,11 +198,11 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
197198 return false ;
198199 }
199200
200- bool addrspacesMayAlias (unsigned AS0, unsigned AS1) const {
201+ bool addrspacesMayAlias (unsigned AS0, unsigned AS1) const override {
201202 return AMDGPU::addrspacesMayAlias (AS0, AS1);
202203 }
203204
204- unsigned getFlatAddressSpace () const {
205+ unsigned getFlatAddressSpace () const override {
205206 // Don't bother running InferAddressSpaces pass on graphics shaders which
206207 // don't use flat addressing.
207208 if (IsGraphics)
@@ -210,24 +211,25 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
210211 }
211212
212213 bool collectFlatAddressOperands (SmallVectorImpl<int > &OpIndexes,
213- Intrinsic::ID IID) const ;
214+ Intrinsic::ID IID) const override ;
214215
215- bool canHaveNonUndefGlobalInitializerInAddressSpace (unsigned AS) const {
216+ bool
217+ canHaveNonUndefGlobalInitializerInAddressSpace (unsigned AS) const override {
216218 return AS != AMDGPUAS::LOCAL_ADDRESS && AS != AMDGPUAS::REGION_ADDRESS &&
217219 AS != AMDGPUAS::PRIVATE_ADDRESS;
218220 }
219221
220222 Value *rewriteIntrinsicWithAddressSpace (IntrinsicInst *II, Value *OldV,
221- Value *NewV) const ;
223+ Value *NewV) const override ;
222224
223225 bool canSimplifyLegacyMulToMul (const Instruction &I, const Value *Op0,
224226 const Value *Op1, InstCombiner &IC) const ;
225227
226228 bool simplifyDemandedLaneMaskArg (InstCombiner &IC, IntrinsicInst &II,
227229 unsigned LaneAgIdx) const ;
228230
229- std::optional<Instruction *> instCombineIntrinsic (InstCombiner &IC,
230- IntrinsicInst &II) const ;
231+ std::optional<Instruction *>
232+ instCombineIntrinsic (InstCombiner &IC, IntrinsicInst &II) const override ;
231233
232234 Value *simplifyAMDGCNLaneIntrinsicDemanded (InstCombiner &IC,
233235 IntrinsicInst &II,
@@ -238,40 +240,43 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
238240 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
239241 APInt &UndefElts2, APInt &UndefElts3,
240242 std::function<void (Instruction *, unsigned , APInt, APInt &)>
241- SimplifyAndSetOp) const ;
243+ SimplifyAndSetOp) const override ;
242244
243245 InstructionCost getVectorSplitCost () const { return 0 ; }
244246
245- InstructionCost getShuffleCost (TTI::ShuffleKind Kind, VectorType *Tp,
246- ArrayRef<int > Mask,
247- TTI::TargetCostKind CostKind, int Index,
248- VectorType *SubTp,
249- ArrayRef<const Value *> Args = {},
250- const Instruction *CxtI = nullptr ) const ;
247+ InstructionCost
248+ getShuffleCost (TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef<int > Mask,
249+ TTI::TargetCostKind CostKind, int Index, VectorType *SubTp,
250+ ArrayRef<const Value *> Args = {},
251+ const Instruction *CxtI = nullptr ) const override ;
251252
252253 bool isProfitableToSinkOperands (Instruction *I,
253- SmallVectorImpl<Use *> &Ops) const ;
254+ SmallVectorImpl<Use *> &Ops) const override ;
254255
255256 bool areInlineCompatible (const Function *Caller,
256- const Function *Callee) const ;
257+ const Function *Callee) const override ;
257258
258- int getInliningLastCallToStaticBonus () const ;
259- unsigned getInliningThresholdMultiplier () const { return 11 ; }
260- unsigned adjustInliningThreshold (const CallBase *CB) const ;
261- unsigned getCallerAllocaCost (const CallBase *CB, const AllocaInst *AI) const ;
259+ int getInliningLastCallToStaticBonus () const override ;
260+ unsigned getInliningThresholdMultiplier () const override { return 11 ; }
261+ unsigned adjustInliningThreshold (const CallBase *CB) const override ;
262+ unsigned getCallerAllocaCost (const CallBase *CB,
263+ const AllocaInst *AI) const override ;
262264
263- int getInlinerVectorBonusPercent () const { return InlinerVectorBonusPercent; }
265+ int getInlinerVectorBonusPercent () const override {
266+ return InlinerVectorBonusPercent;
267+ }
264268
265269 InstructionCost
266270 getArithmeticReductionCost (unsigned Opcode, VectorType *Ty,
267271 std::optional<FastMathFlags> FMF,
268- TTI::TargetCostKind CostKind) const ;
272+ TTI::TargetCostKind CostKind) const override ;
269273
270- InstructionCost getIntrinsicInstrCost (const IntrinsicCostAttributes &ICA,
271- TTI::TargetCostKind CostKind) const ;
272- InstructionCost getMinMaxReductionCost (Intrinsic::ID IID, VectorType *Ty,
273- FastMathFlags FMF,
274- TTI::TargetCostKind CostKind) const ;
274+ InstructionCost
275+ getIntrinsicInstrCost (const IntrinsicCostAttributes &ICA,
276+ TTI::TargetCostKind CostKind) const override ;
277+ InstructionCost
278+ getMinMaxReductionCost (Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
279+ TTI::TargetCostKind CostKind) const override ;
275280
276281 // / Data cache line size for LoopDataPrefetch pass. Has no use before GFX12.
277282 unsigned getCacheLineSize () const override { return 128 ; }
@@ -284,7 +289,7 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
284289 bool shouldPrefetchAddressSpace (unsigned AS) const override ;
285290 void collectKernelLaunchBounds (
286291 const Function &F,
287- SmallVectorImpl<std::pair<StringRef, int64_t >> &LB) const ;
292+ SmallVectorImpl<std::pair<StringRef, int64_t >> &LB) const override ;
288293};
289294
290295} // end namespace llvm
0 commit comments