7
7
// ===----------------------------------------------------------------------===//
8
8
//
9
9
// / \file
10
- // / This file a TargetTransformInfo::Concept conforming object specific to the
10
+ // / This file a TargetTransformInfoImplBase conforming object specific to the
11
11
// / AMDGPU target machine. It uses the target's detailed information to
12
12
// / provide more precise answers to certain TTI queries, while letting the
13
13
// / target independent and default TTI implementations handle the rest.
@@ -52,12 +52,12 @@ class AMDGPUTTIImpl final : public BasicTTIImplBase<AMDGPUTTIImpl> {
52
52
53
53
void getUnrollingPreferences (Loop *L, ScalarEvolution &SE,
54
54
TTI::UnrollingPreferences &UP,
55
- OptimizationRemarkEmitter *ORE) const ;
55
+ OptimizationRemarkEmitter *ORE) const override ;
56
56
57
57
void getPeelingPreferences (Loop *L, ScalarEvolution &SE,
58
- TTI::PeelingPreferences &PP) const ;
58
+ TTI::PeelingPreferences &PP) const override ;
59
59
60
- uint64_t getMaxMemIntrinsicInlineSizeThreshold () const ;
60
+ uint64_t getMaxMemIntrinsicInlineSizeThreshold () const override ;
61
61
};
62
62
63
63
class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
@@ -104,64 +104,65 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
104
104
public:
105
105
explicit GCNTTIImpl (const AMDGPUTargetMachine *TM, const Function &F);
106
106
107
- bool hasBranchDivergence (const Function *F = nullptr ) const ;
107
+ bool hasBranchDivergence (const Function *F = nullptr ) const override ;
108
108
109
109
void getUnrollingPreferences (Loop *L, ScalarEvolution &SE,
110
110
TTI::UnrollingPreferences &UP,
111
- OptimizationRemarkEmitter *ORE) const ;
111
+ OptimizationRemarkEmitter *ORE) const override ;
112
112
113
113
void getPeelingPreferences (Loop *L, ScalarEvolution &SE,
114
- TTI::PeelingPreferences &PP) const ;
114
+ TTI::PeelingPreferences &PP) const override ;
115
115
116
- TTI::PopcntSupportKind getPopcntSupport (unsigned TyWidth) const {
116
+ TTI::PopcntSupportKind getPopcntSupport (unsigned TyWidth) const override {
117
117
assert (isPowerOf2_32 (TyWidth) && " Ty width must be power of 2" );
118
118
return TTI::PSK_FastHardware;
119
119
}
120
120
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 ;
125
126
unsigned getLoadVectorFactor (unsigned VF, unsigned LoadSize,
126
127
unsigned ChainSizeInBytes,
127
- VectorType *VecTy) const ;
128
+ VectorType *VecTy) const override ;
128
129
unsigned getStoreVectorFactor (unsigned VF, unsigned StoreSize,
129
130
unsigned ChainSizeInBytes,
130
- VectorType *VecTy) const ;
131
- unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const ;
131
+ VectorType *VecTy) const override ;
132
+ unsigned getLoadStoreVecRegBitWidth (unsigned AddrSpace) const override ;
132
133
133
134
bool isLegalToVectorizeMemChain (unsigned ChainSizeInBytes, Align Alignment,
134
135
unsigned AddrSpace) const ;
135
136
bool isLegalToVectorizeLoadChain (unsigned ChainSizeInBytes, Align Alignment,
136
- unsigned AddrSpace) const ;
137
+ unsigned AddrSpace) const override ;
137
138
bool isLegalToVectorizeStoreChain (unsigned ChainSizeInBytes, Align Alignment,
138
- unsigned AddrSpace) const ;
139
+ unsigned AddrSpace) const override ;
139
140
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 ;
146
146
147
147
void getMemcpyLoopResidualLoweringType (
148
148
SmallVectorImpl<Type *> &OpsOut, LLVMContext &Context,
149
149
unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace,
150
150
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 ;
153
153
154
- bool getTgtMemIntrinsic (IntrinsicInst *Inst, MemIntrinsicInfo &Info) const ;
154
+ bool getTgtMemIntrinsic (IntrinsicInst *Inst,
155
+ MemIntrinsicInfo &Info) const override ;
155
156
156
157
InstructionCost getArithmeticInstrCost (
157
158
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
158
159
TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
159
160
TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
160
161
ArrayRef<const Value *> Args = {},
161
- const Instruction *CxtI = nullptr ) const ;
162
+ const Instruction *CxtI = nullptr ) const override ;
162
163
163
164
InstructionCost getCFInstrCost (unsigned Opcode, TTI::TargetCostKind CostKind,
164
- const Instruction *I = nullptr ) const ;
165
+ const Instruction *I = nullptr ) const override ;
165
166
166
167
bool isInlineAsmSourceOfDivergence (const CallInst *CI,
167
168
ArrayRef<unsigned > Indices = {}) const ;
@@ -170,13 +171,13 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
170
171
InstructionCost getVectorInstrCost (unsigned Opcode, Type *ValTy,
171
172
TTI::TargetCostKind CostKind,
172
173
unsigned Index, Value *Op0,
173
- Value *Op1) const ;
174
+ Value *Op1) const override ;
174
175
175
176
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 ;
178
179
179
- bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const {
180
+ bool isValidAddrSpaceCast (unsigned FromAS, unsigned ToAS) const override {
180
181
// Address space casts must cast between different address spaces.
181
182
if (FromAS == ToAS)
182
183
return false ;
@@ -197,11 +198,11 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
197
198
return false ;
198
199
}
199
200
200
- bool addrspacesMayAlias (unsigned AS0, unsigned AS1) const {
201
+ bool addrspacesMayAlias (unsigned AS0, unsigned AS1) const override {
201
202
return AMDGPU::addrspacesMayAlias (AS0, AS1);
202
203
}
203
204
204
- unsigned getFlatAddressSpace () const {
205
+ unsigned getFlatAddressSpace () const override {
205
206
// Don't bother running InferAddressSpaces pass on graphics shaders which
206
207
// don't use flat addressing.
207
208
if (IsGraphics)
@@ -210,24 +211,25 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
210
211
}
211
212
212
213
bool collectFlatAddressOperands (SmallVectorImpl<int > &OpIndexes,
213
- Intrinsic::ID IID) const ;
214
+ Intrinsic::ID IID) const override ;
214
215
215
- bool canHaveNonUndefGlobalInitializerInAddressSpace (unsigned AS) const {
216
+ bool
217
+ canHaveNonUndefGlobalInitializerInAddressSpace (unsigned AS) const override {
216
218
return AS != AMDGPUAS::LOCAL_ADDRESS && AS != AMDGPUAS::REGION_ADDRESS &&
217
219
AS != AMDGPUAS::PRIVATE_ADDRESS;
218
220
}
219
221
220
222
Value *rewriteIntrinsicWithAddressSpace (IntrinsicInst *II, Value *OldV,
221
- Value *NewV) const ;
223
+ Value *NewV) const override ;
222
224
223
225
bool canSimplifyLegacyMulToMul (const Instruction &I, const Value *Op0,
224
226
const Value *Op1, InstCombiner &IC) const ;
225
227
226
228
bool simplifyDemandedLaneMaskArg (InstCombiner &IC, IntrinsicInst &II,
227
229
unsigned LaneAgIdx) const ;
228
230
229
- std::optional<Instruction *> instCombineIntrinsic (InstCombiner &IC,
230
- IntrinsicInst &II) const ;
231
+ std::optional<Instruction *>
232
+ instCombineIntrinsic (InstCombiner &IC, IntrinsicInst &II) const override ;
231
233
232
234
Value *simplifyAMDGCNLaneIntrinsicDemanded (InstCombiner &IC,
233
235
IntrinsicInst &II,
@@ -238,40 +240,43 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
238
240
InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
239
241
APInt &UndefElts2, APInt &UndefElts3,
240
242
std::function<void (Instruction *, unsigned , APInt, APInt &)>
241
- SimplifyAndSetOp) const ;
243
+ SimplifyAndSetOp) const override ;
242
244
243
245
InstructionCost getVectorSplitCost () const { return 0 ; }
244
246
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 ;
251
252
252
253
bool isProfitableToSinkOperands (Instruction *I,
253
- SmallVectorImpl<Use *> &Ops) const ;
254
+ SmallVectorImpl<Use *> &Ops) const override ;
254
255
255
256
bool areInlineCompatible (const Function *Caller,
256
- const Function *Callee) const ;
257
+ const Function *Callee) const override ;
257
258
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 ;
262
264
263
- int getInlinerVectorBonusPercent () const { return InlinerVectorBonusPercent; }
265
+ int getInlinerVectorBonusPercent () const override {
266
+ return InlinerVectorBonusPercent;
267
+ }
264
268
265
269
InstructionCost
266
270
getArithmeticReductionCost (unsigned Opcode, VectorType *Ty,
267
271
std::optional<FastMathFlags> FMF,
268
- TTI::TargetCostKind CostKind) const ;
272
+ TTI::TargetCostKind CostKind) const override ;
269
273
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 ;
275
280
276
281
// / Data cache line size for LoopDataPrefetch pass. Has no use before GFX12.
277
282
unsigned getCacheLineSize () const override { return 128 ; }
@@ -284,7 +289,7 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
284
289
bool shouldPrefetchAddressSpace (unsigned AS) const override ;
285
290
void collectKernelLaunchBounds (
286
291
const Function &F,
287
- SmallVectorImpl<std::pair<StringRef, int64_t >> &LB) const ;
292
+ SmallVectorImpl<std::pair<StringRef, int64_t >> &LB) const override ;
288
293
};
289
294
290
295
} // end namespace llvm
0 commit comments