blob: e64b262082c427fba90593b20fd5f3d1d7895fd6 [file] [log] [blame]
Matt Arsenault0c90e952015-11-06 18:17:45 +00001//=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
Tom Stellard75aadc22012-12-11 21:25:42 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Tom Stellard75aadc22012-12-11 21:25:42 +00006//
7//==-----------------------------------------------------------------------===//
8//
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// AMDGPU specific subclass of TargetSubtarget.
Tom Stellard75aadc22012-12-11 21:25:42 +000011//
12//===----------------------------------------------------------------------===//
13
Matt Arsenault0c90e952015-11-06 18:17:45 +000014#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
15#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
Matt Arsenaultf59e5382015-11-06 18:23:00 +000016
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000018#include "AMDGPUCallLowering.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000019#include "R600FrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000020#include "R600ISelLowering.h"
21#include "R600InstrInfo.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000022#include "SIFrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000023#include "SIISelLowering.h"
24#include "SIInstrInfo.h"
Tom Stellard347ac792015-06-26 21:15:07 +000025#include "Utils/AMDGPUBaseInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000026#include "llvm/ADT/Triple.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000027#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
28#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
29#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000030#include "llvm/CodeGen/MachineFunction.h"
Matt Arsenault56684d42016-08-11 17:31:42 +000031#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000032#include "llvm/MC/MCInstrItineraries.h"
33#include "llvm/Support/MathExtras.h"
34#include <cassert>
35#include <cstdint>
36#include <memory>
37#include <utility>
Tom Stellard75aadc22012-12-11 21:25:42 +000038
39#define GET_SUBTARGETINFO_HEADER
40#include "AMDGPUGenSubtargetInfo.inc"
Tom Stellardc5a154d2018-06-28 23:47:12 +000041#define GET_SUBTARGETINFO_HEADER
42#include "R600GenSubtargetInfo.inc"
Tom Stellard75aadc22012-12-11 21:25:42 +000043
Tom Stellard75aadc22012-12-11 21:25:42 +000044namespace llvm {
45
Matt Arsenault43e92fe2016-06-24 06:30:11 +000046class StringRef;
Tom Stellarde99fb652015-01-20 19:33:04 +000047
Tom Stellard5bfbae52018-07-11 20:59:01 +000048class AMDGPUSubtarget {
49public:
50 enum Generation {
51 R600 = 0,
52 R700 = 1,
Matt Arsenault4bec7d42018-07-20 09:05:08 +000053 EVERGREEN = 2,
Tom Stellard5bfbae52018-07-11 20:59:01 +000054 NORTHERN_ISLANDS = 3,
55 SOUTHERN_ISLANDS = 4,
56 SEA_ISLANDS = 5,
57 VOLCANIC_ISLANDS = 6,
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +000058 GFX9 = 7,
59 GFX10 = 8
Tom Stellard5bfbae52018-07-11 20:59:01 +000060 };
61
Tom Stellardc5a154d2018-06-28 23:47:12 +000062private:
63 Triple TargetTriple;
64
65protected:
Tom Stellardc5a154d2018-06-28 23:47:12 +000066 bool Has16BitInsts;
67 bool HasMadMixInsts;
68 bool FP32Denormals;
69 bool FPExceptions;
70 bool HasSDWA;
71 bool HasVOP3PInsts;
72 bool HasMulI24;
73 bool HasMulU24;
Matt Arsenault6c7ba822018-08-15 21:03:55 +000074 bool HasInv2PiInlineImm;
Tom Stellardc5a154d2018-06-28 23:47:12 +000075 bool HasFminFmaxLegacy;
76 bool EnablePromoteAlloca;
David Stuttard20de3e92018-09-14 10:27:19 +000077 bool HasTrigReducedRange;
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +000078 unsigned MaxWavesPerEU;
Tom Stellardc5a154d2018-06-28 23:47:12 +000079 int LocalMemorySize;
80 unsigned WavefrontSize;
81
82public:
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +000083 AMDGPUSubtarget(const Triple &TT);
Tom Stellardc5a154d2018-06-28 23:47:12 +000084
Tom Stellard5bfbae52018-07-11 20:59:01 +000085 static const AMDGPUSubtarget &get(const MachineFunction &MF);
86 static const AMDGPUSubtarget &get(const TargetMachine &TM,
Matt Arsenault4bec7d42018-07-20 09:05:08 +000087 const Function &F);
Tom Stellardc5a154d2018-06-28 23:47:12 +000088
89 /// \returns Default range flat work group size for a calling convention.
90 std::pair<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC) const;
91
92 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
93 /// for function \p F, or minimum/maximum flat work group sizes explicitly
94 /// requested using "amdgpu-flat-work-group-size" attribute attached to
95 /// function \p F.
96 ///
97 /// \returns Subtarget's default values if explicitly requested values cannot
98 /// be converted to integer, or violate subtarget's specifications.
99 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
100
101 /// \returns Subtarget's default pair of minimum/maximum number of waves per
102 /// execution unit for function \p F, or minimum/maximum number of waves per
103 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
104 /// attached to function \p F.
105 ///
106 /// \returns Subtarget's default values if explicitly requested values cannot
107 /// be converted to integer, violate subtarget's specifications, or are not
108 /// compatible with minimum/maximum number of waves limited by flat work group
109 /// size, register usage, and/or lds usage.
110 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
111
112 /// Return the amount of LDS that can be used that will not restrict the
113 /// occupancy lower than WaveCount.
114 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
115 const Function &) const;
116
117 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
118 /// the given LDS memory size is the only constraint.
119 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
120
121 unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const;
122
123 bool isAmdHsaOS() const {
124 return TargetTriple.getOS() == Triple::AMDHSA;
125 }
126
127 bool isAmdPalOS() const {
128 return TargetTriple.getOS() == Triple::AMDPAL;
129 }
130
Tom Stellardec4feae2018-07-06 17:16:17 +0000131 bool isMesa3DOS() const {
132 return TargetTriple.getOS() == Triple::Mesa3D;
133 }
134
135 bool isMesaKernel(const Function &F) const {
136 return isMesa3DOS() && !AMDGPU::isShader(F.getCallingConv());
137 }
138
Konstantin Zhuravlyovaa067cb2018-10-04 21:02:16 +0000139 bool isAmdHsaOrMesa(const Function &F) const {
Tom Stellardec4feae2018-07-06 17:16:17 +0000140 return isAmdHsaOS() || isMesaKernel(F);
141 }
142
Tom Stellardc5a154d2018-06-28 23:47:12 +0000143 bool has16BitInsts() const {
144 return Has16BitInsts;
145 }
146
147 bool hasMadMixInsts() const {
148 return HasMadMixInsts;
149 }
150
151 bool hasFP32Denormals() const {
152 return FP32Denormals;
153 }
154
155 bool hasFPExceptions() const {
156 return FPExceptions;
157 }
158
159 bool hasSDWA() const {
160 return HasSDWA;
161 }
162
163 bool hasVOP3PInsts() const {
164 return HasVOP3PInsts;
165 }
166
167 bool hasMulI24() const {
168 return HasMulI24;
169 }
170
171 bool hasMulU24() const {
172 return HasMulU24;
173 }
174
Matt Arsenault6c7ba822018-08-15 21:03:55 +0000175 bool hasInv2PiInlineImm() const {
176 return HasInv2PiInlineImm;
177 }
178
Tom Stellardc5a154d2018-06-28 23:47:12 +0000179 bool hasFminFmaxLegacy() const {
180 return HasFminFmaxLegacy;
181 }
182
David Stuttard20de3e92018-09-14 10:27:19 +0000183 bool hasTrigReducedRange() const {
184 return HasTrigReducedRange;
185 }
186
Tom Stellardc5a154d2018-06-28 23:47:12 +0000187 bool isPromoteAllocaEnabled() const {
188 return EnablePromoteAlloca;
189 }
190
191 unsigned getWavefrontSize() const {
192 return WavefrontSize;
193 }
194
195 int getLocalMemorySize() const {
196 return LocalMemorySize;
197 }
198
199 unsigned getAlignmentForImplicitArgPtr() const {
200 return isAmdHsaOS() ? 8 : 4;
201 }
202
Tom Stellardec4feae2018-07-06 17:16:17 +0000203 /// Returns the offset in bytes from the start of the input buffer
204 /// of the first explicit kernel argument.
205 unsigned getExplicitKernelArgOffset(const Function &F) const {
Konstantin Zhuravlyovaa067cb2018-10-04 21:02:16 +0000206 return isAmdHsaOrMesa(F) ? 0 : 36;
Tom Stellardec4feae2018-07-06 17:16:17 +0000207 }
208
Tom Stellardc5a154d2018-06-28 23:47:12 +0000209 /// \returns Maximum number of work groups per compute unit supported by the
210 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000211 virtual unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000212
213 /// \returns Minimum flat work group size supported by the subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000214 virtual unsigned getMinFlatWorkGroupSize() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000215
216 /// \returns Maximum flat work group size supported by the subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000217 virtual unsigned getMaxFlatWorkGroupSize() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000218
219 /// \returns Maximum number of waves per execution unit supported by the
220 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000221 virtual unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000222
223 /// \returns Minimum number of waves per execution unit supported by the
224 /// subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000225 virtual unsigned getMinWavesPerEU() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000226
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +0000227 /// \returns Maximum number of waves per execution unit supported by the
228 /// subtarget without any kind of limitation.
229 unsigned getMaxWavesPerEU() const { return MaxWavesPerEU; }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000230
231 /// Creates value range metadata on an workitemid.* inrinsic call or load.
232 bool makeLIDRangeMetadata(Instruction *I) const;
233
Matt Arsenault4bec7d42018-07-20 09:05:08 +0000234 /// \returns Number of bytes of arguments that are passed to a shader or
235 /// kernel in addition to the explicit ones declared for the function.
236 unsigned getImplicitArgNumBytes(const Function &F) const {
237 if (isMesaKernel(F))
238 return 16;
239 return AMDGPU::getIntegerAttribute(F, "amdgpu-implicitarg-num-bytes", 0);
240 }
241 uint64_t getExplicitKernArgSize(const Function &F,
242 unsigned &MaxAlign) const;
243 unsigned getKernArgSegmentSize(const Function &F,
244 unsigned &MaxAlign) const;
245
Tom Stellard5bfbae52018-07-11 20:59:01 +0000246 virtual ~AMDGPUSubtarget() {}
Tom Stellardc5a154d2018-06-28 23:47:12 +0000247};
248
Tom Stellard5bfbae52018-07-11 20:59:01 +0000249class GCNSubtarget : public AMDGPUGenSubtargetInfo,
250 public AMDGPUSubtarget {
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +0000251
252 using AMDGPUSubtarget::getMaxWavesPerEU;
253
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000254public:
Wei Ding205bfdb2017-02-10 02:15:29 +0000255 enum TrapHandlerAbi {
256 TrapHandlerAbiNone = 0,
257 TrapHandlerAbiHsa = 1
258 };
259
Wei Dingf2cce022017-02-22 23:22:19 +0000260 enum TrapID {
261 TrapIDHardwareReserved = 0,
262 TrapIDHSADebugTrap = 1,
263 TrapIDLLVMTrap = 2,
264 TrapIDLLVMDebugTrap = 3,
265 TrapIDDebugBreakpoint = 7,
266 TrapIDDebugReserved8 = 8,
267 TrapIDDebugReservedFE = 0xfe,
268 TrapIDDebugReservedFF = 0xff
Wei Ding205bfdb2017-02-10 02:15:29 +0000269 };
270
271 enum TrapRegValues {
Wei Dingf2cce022017-02-22 23:22:19 +0000272 LLVMTrapHandlerRegValue = 1
Wei Ding205bfdb2017-02-10 02:15:29 +0000273 };
274
Tom Stellardc5a154d2018-06-28 23:47:12 +0000275private:
Tom Stellardc5a154d2018-06-28 23:47:12 +0000276 /// GlobalISel related APIs.
277 std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
278 std::unique_ptr<InstructionSelector> InstSelector;
279 std::unique_ptr<LegalizerInfo> Legalizer;
280 std::unique_ptr<RegisterBankInfo> RegBankInfo;
281
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000282protected:
283 // Basic subtarget description.
284 Triple TargetTriple;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000285 unsigned Gen;
Stanislav Mekhanoshin06d3b412018-09-17 16:04:32 +0000286 InstrItineraryData InstrItins;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000287 int LDSBankCount;
288 unsigned MaxPrivateElementSize;
289
290 // Possibly statically set by tablegen, but may want to be overridden.
Matt Arsenaultb035a572015-01-29 19:34:25 +0000291 bool FastFMAF32;
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000292 bool HalfRate64Ops;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000293
294 // Dynamially set bits that enable features.
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000295 bool FP64FP16Denormals;
Changpeng Fangb41574a2015-12-22 20:55:23 +0000296 bool FlatForGlobal;
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000297 bool AutoWaitcntBeforeBarrier;
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000298 bool CodeObjectV3;
Tom Stellard64a9d082016-10-14 18:10:39 +0000299 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000300 bool UnalignedBufferAccess;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000301 bool HasApertureRegs;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000302 bool EnableXNACK;
Matt Arsenaultdf24c922019-05-16 14:48:34 +0000303 bool DoesNotSupportXNACK;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000304 bool EnableCuMode;
Wei Ding205bfdb2017-02-10 02:15:29 +0000305 bool TrapHandler;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000306
307 // Used as options.
Matt Arsenault41033282014-10-10 22:01:59 +0000308 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +0000309 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000310 bool EnableSIScheduler;
Marek Olsaka9a58fa2018-04-10 22:48:23 +0000311 bool EnableDS128;
David Stuttardf77079f2019-01-14 11:55:24 +0000312 bool EnablePRTStrictNull;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000313 bool DumpCode;
314
315 // Subtarget statically properties set by tablegen
316 bool FP64;
Jan Vesely39aeab42017-12-04 23:07:28 +0000317 bool FMA;
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000318 bool MIMG_R128;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000319 bool IsGCN;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000320 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000321 bool CIInsts;
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000322 bool GFX8Insts;
Matt Arsenault2021f082017-02-18 19:12:26 +0000323 bool GFX9Insts;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000324 bool GFX10Insts;
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000325 bool GFX7GFX8GFX9Insts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000326 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000327 bool HasSMemRealTime;
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000328 bool HasIntClamp;
Matt Arsenault0084adc2018-04-30 19:08:16 +0000329 bool HasFmaMixInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000330 bool HasMovrel;
331 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000332 bool HasScalarStores;
Dmitry Preobrazhensky6bad04e2018-04-02 16:10:25 +0000333 bool HasScalarAtomics;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000334 bool HasSDWAOmod;
335 bool HasSDWAScalar;
336 bool HasSDWASdst;
337 bool HasSDWAMac;
Sam Koltona179d252017-06-27 15:02:23 +0000338 bool HasSDWAOutModsVOPC;
Sam Kolton07dbde22017-01-20 10:01:25 +0000339 bool HasDPP;
Stanislav Mekhanoshin245b5ba2019-06-12 18:02:41 +0000340 bool HasDPP8;
Ryan Taylor1f334d02018-08-28 15:07:30 +0000341 bool HasR128A16;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000342 bool HasNSAEncoding;
Matt Arsenault0084adc2018-04-30 19:08:16 +0000343 bool HasDLInsts;
Stanislav Mekhanoshin0e858b02019-02-09 00:34:21 +0000344 bool HasDot1Insts;
345 bool HasDot2Insts;
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000346 bool HasDot3Insts;
347 bool HasDot4Insts;
Stanislav Mekhanoshinc43e67b2019-06-14 00:33:31 +0000348 bool HasDot5Insts;
349 bool HasDot6Insts;
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000350 bool HasMAIInsts;
351 bool HasPkFmacF16Inst;
352 bool HasAtomicFaddInsts;
Konstantin Zhuravlyov108927b2018-11-05 22:44:19 +0000353 bool EnableSRAMECC;
Matt Arsenaultf426ddb2019-04-03 01:58:57 +0000354 bool DoesNotSupportSRAMECC;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000355 bool HasNoSdstCMPX;
356 bool HasVscnt;
357 bool HasRegisterBanking;
358 bool HasVOP3Literal;
359 bool HasNoDataDepHazard;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000360 bool FlatAddressSpace;
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000361 bool FlatInstOffsets;
362 bool FlatGlobalInsts;
363 bool FlatScratchInsts;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000364 bool ScalarFlatScratchInsts;
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000365 bool AddNoCarryInsts;
Changpeng Fang44dfa1d2018-01-12 21:12:19 +0000366 bool HasUnpackedD16VMem;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000367 bool R600ALUInst;
368 bool CaymanISA;
369 bool CFALUBug;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000370 bool LDSMisalignedBug;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000371 bool HasVertexCache;
372 short TexVTXClauseSize;
Alexander Timofeev18009562016-12-08 17:28:47 +0000373 bool ScalarizeGlobal;
Tom Stellard75aadc22012-12-11 21:25:42 +0000374
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000375 bool HasVcmpxPermlaneHazard;
376 bool HasVMEMtoScalarWriteHazard;
377 bool HasSMEMtoVectorWriteHazard;
378 bool HasInstFwdPrefetchBug;
379 bool HasVcmpxExecWARHazard;
380 bool HasLdsBranchVmemWARHazard;
381 bool HasNSAtoVMEMBug;
Ryan Taylor9ab812d2019-06-26 17:34:57 +0000382 bool HasOffset3fBug;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000383 bool HasFlatSegmentOffsetBug;
384
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000385 // Dummy feature to use for assembler in tablegen.
386 bool FeatureDisable;
387
Matt Arsenault56684d42016-08-11 17:31:42 +0000388 SelectionDAGTargetInfo TSInfo;
Tom Stellard5bfbae52018-07-11 20:59:01 +0000389private:
Tom Stellard5bfbae52018-07-11 20:59:01 +0000390 SIInstrInfo InstrInfo;
Tom Stellard752ddbd2018-07-11 22:15:15 +0000391 SITargetLowering TLInfo;
Tom Stellard5bfbae52018-07-11 20:59:01 +0000392 SIFrameLowering FrameLowering;
Tom Stellard75aadc22012-12-11 21:25:42 +0000393
Matt Arsenault5c714cb2019-05-23 19:38:14 +0000394 // See COMPUTE_TMPRING_SIZE.WAVESIZE, 13-bit field in units of 256-dword.
395 static const unsigned MaxWaveScratchSize = (256 * 4) * ((1 << 13) - 1);
396
Tom Stellard75aadc22012-12-11 21:25:42 +0000397public:
Tom Stellard5bfbae52018-07-11 20:59:01 +0000398 GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
399 const GCNTargetMachine &TM);
400 ~GCNSubtarget() override;
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000401
Tom Stellard5bfbae52018-07-11 20:59:01 +0000402 GCNSubtarget &initializeSubtargetDependencies(const Triple &TT,
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000403 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000404
Tom Stellard5bfbae52018-07-11 20:59:01 +0000405 const SIInstrInfo *getInstrInfo() const override {
406 return &InstrInfo;
407 }
Tom Stellard000c5af2016-04-14 19:09:28 +0000408
Tom Stellardc5a154d2018-06-28 23:47:12 +0000409 const SIFrameLowering *getFrameLowering() const override {
410 return &FrameLowering;
411 }
412
Tom Stellard5bfbae52018-07-11 20:59:01 +0000413 const SITargetLowering *getTargetLowering() const override {
414 return &TLInfo;
415 }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000416
Tom Stellard5bfbae52018-07-11 20:59:01 +0000417 const SIRegisterInfo *getRegisterInfo() const override {
418 return &InstrInfo.getRegisterInfo();
419 }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000420
421 const CallLowering *getCallLowering() const override {
422 return CallLoweringInfo.get();
423 }
424
Amara Emersone14c91b2019-08-13 06:26:59 +0000425 InstructionSelector *getInstructionSelector() const override {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000426 return InstSelector.get();
427 }
428
429 const LegalizerInfo *getLegalizerInfo() const override {
430 return Legalizer.get();
431 }
432
433 const RegisterBankInfo *getRegBankInfo() const override {
434 return RegBankInfo.get();
Eric Christopherd9134482014-08-04 21:25:23 +0000435 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000436
Matt Arsenault56684d42016-08-11 17:31:42 +0000437 // Nothing implemented, just prevent crashes on use.
438 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
439 return &TSInfo;
440 }
441
Stanislav Mekhanoshin06d3b412018-09-17 16:04:32 +0000442 const InstrItineraryData *getInstrItineraryData() const override {
443 return &InstrItins;
444 }
445
Craig Topperee7b0f32014-04-30 05:53:27 +0000446 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000447
Matt Arsenaultd782d052014-06-27 17:57:00 +0000448 Generation getGeneration() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000449 return (Generation)Gen;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000450 }
451
Matt Arsenault4eea3f32017-11-13 22:55:05 +0000452 unsigned getWavefrontSizeLog2() const {
453 return Log2_32(WavefrontSize);
454 }
455
Matt Arsenault5c714cb2019-05-23 19:38:14 +0000456 /// Return the number of high bits known to be zero fror a frame index.
457 unsigned getKnownHighZeroBitsForFrameIndex() const {
458 return countLeadingZeros(MaxWaveScratchSize) + getWavefrontSizeLog2();
459 }
460
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000461 int getLDSBankCount() const {
462 return LDSBankCount;
463 }
464
465 unsigned getMaxPrivateElementSize() const {
466 return MaxPrivateElementSize;
467 }
468
Stanislav Mekhanoshinf2baae02019-05-02 03:47:23 +0000469 unsigned getConstantBusLimit(unsigned Opcode) const;
470
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000471 bool hasIntClamp() const {
472 return HasIntClamp;
473 }
474
Jan Veselyd1c9b612017-12-04 22:57:29 +0000475 bool hasFP64() const {
Matt Arsenaultd782d052014-06-27 17:57:00 +0000476 return FP64;
477 }
478
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000479 bool hasMIMG_R128() const {
480 return MIMG_R128;
481 }
482
Tom Stellardc5a154d2018-06-28 23:47:12 +0000483 bool hasHWFP64() const {
484 return FP64;
485 }
486
Matt Arsenaultb035a572015-01-29 19:34:25 +0000487 bool hasFastFMAF32() const {
488 return FastFMAF32;
489 }
490
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000491 bool hasHalfRate64Ops() const {
492 return HalfRate64Ops;
493 }
494
Matt Arsenault88701812016-06-09 23:42:48 +0000495 bool hasAddr64() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000496 return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS);
Matt Arsenault88701812016-06-09 23:42:48 +0000497 }
498
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000499 // Return true if the target only has the reverse operand versions of VALU
500 // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
501 bool hasOnlyRevVALUShifts() const {
502 return getGeneration() >= VOLCANIC_ISLANDS;
503 }
504
Matt Arsenaultfae02982014-03-17 18:58:11 +0000505 bool hasBFE() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000506 return true;
Matt Arsenaultfae02982014-03-17 18:58:11 +0000507 }
508
Matt Arsenault6e439652014-06-10 19:00:20 +0000509 bool hasBFI() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000510 return true;
Matt Arsenault6e439652014-06-10 19:00:20 +0000511 }
512
Matt Arsenaultfae02982014-03-17 18:58:11 +0000513 bool hasBFM() const {
514 return hasBFE();
515 }
516
Matt Arsenault60425062014-06-10 19:18:28 +0000517 bool hasBCNT(unsigned Size) const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000518 return true;
Tom Stellard50122a52014-04-07 19:45:41 +0000519 }
520
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000521 bool hasFFBL() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000522 return true;
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000523 }
524
525 bool hasFFBH() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000526 return true;
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000527 }
528
Matt Arsenault10268f92017-02-27 22:40:39 +0000529 bool hasMed3_16() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000530 return getGeneration() >= AMDGPUSubtarget::GFX9;
Matt Arsenault10268f92017-02-27 22:40:39 +0000531 }
532
Matt Arsenaultee324ff2017-05-17 19:25:06 +0000533 bool hasMin3Max3_16() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000534 return getGeneration() >= AMDGPUSubtarget::GFX9;
Matt Arsenaultd7e23032017-09-07 18:05:07 +0000535 }
536
Matt Arsenault0084adc2018-04-30 19:08:16 +0000537 bool hasFmaMixInsts() const {
538 return HasFmaMixInsts;
539 }
540
Jan Vesely808fff52015-04-30 17:15:56 +0000541 bool hasCARRY() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000542 return true;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000543 }
544
Jan Vesely39aeab42017-12-04 23:07:28 +0000545 bool hasFMA() const {
546 return FMA;
547 }
548
Stanislav Mekhanoshin79080ec2018-10-29 17:26:01 +0000549 bool hasSwap() const {
550 return GFX9Insts;
551 }
552
Wei Ding205bfdb2017-02-10 02:15:29 +0000553 TrapHandlerAbi getTrapHandlerAbi() const {
554 return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
555 }
556
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000557 /// True if the offset field of DS instructions works as expected. On SI, the
558 /// offset uses a 16-bit adder and does not always wrap properly.
559 bool hasUsableDSOffset() const {
560 return getGeneration() >= SEA_ISLANDS;
561 }
562
Matt Arsenault706f9302015-07-06 16:01:58 +0000563 bool unsafeDSOffsetFoldingEnabled() const {
564 return EnableUnsafeDSOffsetFolding;
565 }
566
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000567 /// Condition output from div_scale is usable.
568 bool hasUsableDivScaleConditionOutput() const {
569 return getGeneration() != SOUTHERN_ISLANDS;
570 }
571
572 /// Extra wait hazard is needed in some cases before
573 /// s_cbranch_vccnz/s_cbranch_vccz.
574 bool hasReadVCCZBug() const {
575 return getGeneration() <= SEA_ISLANDS;
576 }
577
578 /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
579 /// was written by a VALU instruction.
580 bool hasSMRDReadVALUDefHazard() const {
581 return getGeneration() == SOUTHERN_ISLANDS;
582 }
583
584 /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
585 /// SGPR was written by a VALU Instruction.
586 bool hasVMEMReadSGPRVALUDefHazard() const {
587 return getGeneration() >= VOLCANIC_ISLANDS;
588 }
589
590 bool hasRFEHazards() const {
591 return getGeneration() >= VOLCANIC_ISLANDS;
592 }
593
594 /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
595 unsigned getSetRegWaitStates() const {
596 return getGeneration() <= SEA_ISLANDS ? 1 : 2;
597 }
598
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000599 bool dumpCode() const {
600 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000601 }
602
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000603 /// Return the amount of LDS that can be used that will not restrict the
604 /// occupancy lower than WaveCount.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000605 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
606 const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000607
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000608 bool hasFP16Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000609 return FP64FP16Denormals;
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000610 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000611
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000612 bool hasFP64Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000613 return FP64FP16Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000614 }
615
Stanislav Mekhanoshindc2890a2017-07-13 23:59:15 +0000616 bool supportsMinMaxDenormModes() const {
617 return getGeneration() >= AMDGPUSubtarget::GFX9;
618 }
619
Austin Kerbowa05c3842019-08-06 02:16:11 +0000620 /// \returns If target supports S_DENORM_MODE.
621 bool hasDenormModeInst() const {
622 return getGeneration() >= AMDGPUSubtarget::GFX10;
623 }
624
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000625 bool useFlatForGlobal() const {
626 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000627 }
628
Farhana Aleena7cb3112018-03-09 17:41:39 +0000629 /// \returns If target supports ds_read/write_b128 and user enables generation
630 /// of ds_read/write_b128.
Marek Olsaka9a58fa2018-04-10 22:48:23 +0000631 bool useDS128() const {
632 return CIInsts && EnableDS128;
Farhana Aleena7cb3112018-03-09 17:41:39 +0000633 }
634
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000635 /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
636 bool haveRoundOpsF64() const {
637 return CIInsts;
638 }
639
Matt Arsenaultcaf0ed42017-11-30 00:52:40 +0000640 /// \returns If MUBUF instructions always perform range checking, even for
641 /// buffer resources used for private memory access.
642 bool privateMemoryResourceIsRangeChecked() const {
643 return getGeneration() < AMDGPUSubtarget::GFX9;
644 }
645
David Stuttardf77079f2019-01-14 11:55:24 +0000646 /// \returns If target requires PRT Struct NULL support (zero result registers
647 /// for sparse texture support).
648 bool usePRTStrictNull() const {
649 return EnablePRTStrictNull;
650 }
651
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000652 bool hasAutoWaitcntBeforeBarrier() const {
653 return AutoWaitcntBeforeBarrier;
654 }
655
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000656 bool hasCodeObjectV3() const {
Konstantin Zhuravlyova25e0522018-11-15 02:32:43 +0000657 // FIXME: Need to add code object v3 support for mesa and pal.
658 return isAmdHsaOS() ? CodeObjectV3 : false;
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000659 }
660
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000661 bool hasUnalignedBufferAccess() const {
662 return UnalignedBufferAccess;
663 }
664
Tom Stellard64a9d082016-10-14 18:10:39 +0000665 bool hasUnalignedScratchAccess() const {
666 return UnalignedScratchAccess;
667 }
668
Matt Arsenaulte823d922017-02-18 18:29:53 +0000669 bool hasApertureRegs() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000670 return HasApertureRegs;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000671 }
672
Wei Ding205bfdb2017-02-10 02:15:29 +0000673 bool isTrapHandlerEnabled() const {
674 return TrapHandler;
675 }
676
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000677 bool isXNACKEnabled() const {
678 return EnableXNACK;
679 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000680
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000681 bool isCuModeEnabled() const {
682 return EnableCuMode;
683 }
684
Matt Arsenaultb6491cc2017-01-31 01:20:54 +0000685 bool hasFlatAddressSpace() const {
686 return FlatAddressSpace;
687 }
688
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000689 bool hasFlatScrRegister() const {
690 return hasFlatAddressSpace();
691 }
692
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000693 bool hasFlatInstOffsets() const {
694 return FlatInstOffsets;
695 }
696
697 bool hasFlatGlobalInsts() const {
698 return FlatGlobalInsts;
699 }
700
701 bool hasFlatScratchInsts() const {
702 return FlatScratchInsts;
703 }
704
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000705 bool hasScalarFlatScratchInsts() const {
706 return ScalarFlatScratchInsts;
707 }
708
709 bool hasFlatSegmentOffsetBug() const {
710 return HasFlatSegmentOffsetBug;
711 }
712
Mark Searlesf0b93f12018-06-04 16:51:59 +0000713 bool hasFlatLgkmVMemCountInOrder() const {
714 return getGeneration() > GFX9;
715 }
716
Matt Arsenaulted6e8f02017-09-01 18:36:06 +0000717 bool hasD16LoadStore() const {
718 return getGeneration() >= GFX9;
719 }
720
Matt Arsenaulte8c03a22019-03-08 20:58:11 +0000721 bool d16PreservesUnusedBits() const {
722 return hasD16LoadStore() && !isSRAMECCEnabled();
723 }
724
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000725 bool hasD16Images() const {
726 return getGeneration() >= VOLCANIC_ISLANDS;
727 }
728
Matt Arsenault3f71c0e2017-11-29 00:55:57 +0000729 /// Return if most LDS instructions have an m0 use that require m0 to be
730 /// iniitalized.
731 bool ldsRequiresM0Init() const {
732 return getGeneration() < GFX9;
733 }
734
Matt Arsenault8ad1dec2019-06-20 20:54:32 +0000735 // True if the hardware rewinds and replays GWS operations if a wave is
736 // preempted.
737 //
738 // If this is false, a GWS operation requires testing if a nack set the
739 // MEM_VIOL bit, and repeating if so.
740 bool hasGWSAutoReplay() const {
741 return getGeneration() >= GFX9;
742 }
743
Matt Arsenault740322f2019-06-20 21:11:42 +0000744 /// \returns if target has ds_gws_sema_release_all instruction.
745 bool hasGWSSemaReleaseAll() const {
746 return CIInsts;
747 }
748
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000749 bool hasAddNoCarry() const {
750 return AddNoCarryInsts;
751 }
752
Changpeng Fang44dfa1d2018-01-12 21:12:19 +0000753 bool hasUnpackedD16VMem() const {
754 return HasUnpackedD16VMem;
755 }
756
Tom Stellard2f3f9852017-01-25 01:25:13 +0000757 // Covers VS/PS/CS graphics shaders
Matt Arsenaultceafc552018-05-29 17:42:50 +0000758 bool isMesaGfxShader(const Function &F) const {
759 return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
Tom Stellard2f3f9852017-01-25 01:25:13 +0000760 }
761
Matt Arsenault4f6318f2017-11-06 17:04:37 +0000762 bool hasMad64_32() const {
763 return getGeneration() >= SEA_ISLANDS;
764 }
765
Sam Kolton3c4933f2017-06-22 06:26:41 +0000766 bool hasSDWAOmod() const {
767 return HasSDWAOmod;
768 }
769
770 bool hasSDWAScalar() const {
771 return HasSDWAScalar;
772 }
773
774 bool hasSDWASdst() const {
775 return HasSDWASdst;
776 }
777
778 bool hasSDWAMac() const {
779 return HasSDWAMac;
780 }
781
Sam Koltona179d252017-06-27 15:02:23 +0000782 bool hasSDWAOutModsVOPC() const {
783 return HasSDWAOutModsVOPC;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000784 }
785
Matt Arsenault0084adc2018-04-30 19:08:16 +0000786 bool hasDLInsts() const {
787 return HasDLInsts;
788 }
789
Stanislav Mekhanoshin0e858b02019-02-09 00:34:21 +0000790 bool hasDot1Insts() const {
791 return HasDot1Insts;
792 }
793
794 bool hasDot2Insts() const {
795 return HasDot2Insts;
Stanislav Mekhanoshind3757d32019-01-10 03:25:20 +0000796 }
797
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000798 bool hasDot3Insts() const {
799 return HasDot3Insts;
800 }
801
802 bool hasDot4Insts() const {
803 return HasDot4Insts;
804 }
805
Stanislav Mekhanoshinc43e67b2019-06-14 00:33:31 +0000806 bool hasDot5Insts() const {
807 return HasDot5Insts;
808 }
809
810 bool hasDot6Insts() const {
811 return HasDot6Insts;
812 }
813
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000814 bool hasMAIInsts() const {
815 return HasMAIInsts;
816 }
817
818 bool hasPkFmacF16Inst() const {
819 return HasPkFmacF16Inst;
820 }
821
822 bool hasAtomicFaddInsts() const {
823 return HasAtomicFaddInsts;
824 }
825
Konstantin Zhuravlyov108927b2018-11-05 22:44:19 +0000826 bool isSRAMECCEnabled() const {
827 return EnableSRAMECC;
Konstantin Zhuravlyovc2c2eb72018-05-04 20:06:57 +0000828 }
829
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000830 bool hasNoSdstCMPX() const {
831 return HasNoSdstCMPX;
832 }
833
834 bool hasVscnt() const {
835 return HasVscnt;
836 }
837
838 bool hasRegisterBanking() const {
839 return HasRegisterBanking;
840 }
841
842 bool hasVOP3Literal() const {
843 return HasVOP3Literal;
844 }
845
846 bool hasNoDataDepHazard() const {
847 return HasNoDataDepHazard;
848 }
849
850 bool vmemWriteNeedsExpWaitcnt() const {
851 return getGeneration() < SEA_ISLANDS;
852 }
853
Matt Arsenault869fec22017-04-17 19:48:24 +0000854 // Scratch is allocated in 256 dword per wave blocks for the entire
855 // wavefront. When viewed from the perspecive of an arbitrary workitem, this
856 // is 4-byte aligned.
Matt Arsenaultffb132e2018-03-29 20:22:04 +0000857 //
858 // Only 4-byte alignment is really needed to access anything. Transformations
859 // on the pointer value itself may rely on the alignment / known low bits of
860 // the pointer. Set this to something above the minimum to avoid needing
861 // dynamic realignment in common cases.
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000862 unsigned getStackAlignment() const {
Matt Arsenaultffb132e2018-03-29 20:22:04 +0000863 return 16;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000864 }
Tom Stellard347ac792015-06-26 21:15:07 +0000865
Craig Topper5656db42014-04-29 07:57:24 +0000866 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000867 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000868 }
869
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000870 bool enableSubRegLiveness() const override {
871 return true;
872 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000873
Tom Stellardc5a154d2018-06-28 23:47:12 +0000874 void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; }
875 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; }
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000876
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000877 /// \returns Number of execution units per compute unit supported by the
878 /// subtarget.
879 unsigned getEUsPerCU() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000880 return AMDGPU::IsaInfo::getEUsPerCU(this);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000881 }
882
883 /// \returns Maximum number of waves per compute unit supported by the
884 /// subtarget without any kind of limitation.
885 unsigned getMaxWavesPerCU() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000886 return AMDGPU::IsaInfo::getMaxWavesPerCU(this);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000887 }
888
889 /// \returns Maximum number of waves per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000890 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000891 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000892 return AMDGPU::IsaInfo::getMaxWavesPerCU(this, FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000893 }
894
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000895 /// \returns Number of waves per work group supported by the subtarget and
896 /// limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000897 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000898 return AMDGPU::IsaInfo::getWavesPerWorkGroup(this, FlatWorkGroupSize);
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000899 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000900
Tom Stellardc5a154d2018-06-28 23:47:12 +0000901 // static wrappers
902 static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000903
Matt Arsenault9f5e0ef2017-01-25 04:25:02 +0000904 // XXX - Why is this here if it isn't in the default pass set?
905 bool enableEarlyIfConversion() const override {
906 return true;
907 }
908
Tom Stellard83f0bce2015-01-29 16:55:25 +0000909 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000910 unsigned NumRegionInstrs) const override;
911
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000912 unsigned getMaxNumUserSGPRs() const {
913 return 16;
914 }
915
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000916 bool hasSMemRealTime() const {
917 return HasSMemRealTime;
918 }
919
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000920 bool hasMovrel() const {
921 return HasMovrel;
922 }
923
924 bool hasVGPRIndexMode() const {
925 return HasVGPRIndexMode;
926 }
927
Marek Olsake22fdb92017-03-21 17:00:32 +0000928 bool useVGPRIndexMode(bool UserEnable) const {
929 return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
930 }
931
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000932 bool hasScalarCompareEq64() const {
933 return getGeneration() >= VOLCANIC_ISLANDS;
934 }
935
Matt Arsenault7b647552016-10-28 21:55:15 +0000936 bool hasScalarStores() const {
937 return HasScalarStores;
938 }
939
Dmitry Preobrazhensky6bad04e2018-04-02 16:10:25 +0000940 bool hasScalarAtomics() const {
941 return HasScalarAtomics;
942 }
943
Matt Arsenaulta5840c32019-01-22 18:36:06 +0000944 bool hasLDSFPAtomics() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000945 return GFX8Insts;
Matt Arsenaulta5840c32019-01-22 18:36:06 +0000946 }
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000947
Sam Kolton07dbde22017-01-20 10:01:25 +0000948 bool hasDPP() const {
949 return HasDPP;
950 }
951
Jay Foadeac23862019-08-23 10:07:43 +0000952 bool hasDPPBroadcasts() const {
953 return HasDPP && getGeneration() < GFX10;
954 }
955
956 bool hasDPPWavefrontShifts() const {
957 return HasDPP && getGeneration() < GFX10;
958 }
959
Stanislav Mekhanoshin245b5ba2019-06-12 18:02:41 +0000960 bool hasDPP8() const {
961 return HasDPP8;
962 }
963
Ryan Taylor1f334d02018-08-28 15:07:30 +0000964 bool hasR128A16() const {
965 return HasR128A16;
966 }
967
Ryan Taylor9ab812d2019-06-26 17:34:57 +0000968 bool hasOffset3fBug() const {
969 return HasOffset3fBug;
970 }
971
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000972 bool hasNSAEncoding() const {
973 return HasNSAEncoding;
974 }
975
976 bool hasMadF16() const;
977
Tom Stellardde008d32016-01-21 04:28:34 +0000978 bool enableSIScheduler() const {
979 return EnableSIScheduler;
980 }
981
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000982 bool loadStoreOptEnabled() const {
983 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000984 }
985
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000986 bool hasSGPRInitBug() const {
987 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000988 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000989
Tom Stellardb133fbb2016-10-27 23:05:31 +0000990 bool has12DWordStoreHazard() const {
991 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
992 }
993
Neil Henninge85d45a2019-01-10 16:21:08 +0000994 // \returns true if the subtarget supports DWORDX3 load/store instructions.
995 bool hasDwordx3LoadStores() const {
996 return CIInsts;
997 }
998
Matt Arsenaulte823d922017-02-18 18:29:53 +0000999 bool hasSMovFedHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001000 return getGeneration() == AMDGPUSubtarget::GFX9;
Matt Arsenaulte823d922017-02-18 18:29:53 +00001001 }
1002
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001003 bool hasReadM0MovRelInterpHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001004 return getGeneration() == AMDGPUSubtarget::GFX9;
Matt Arsenaulte823d922017-02-18 18:29:53 +00001005 }
1006
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001007 bool hasReadM0SendMsgHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001008 return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&
1009 getGeneration() <= AMDGPUSubtarget::GFX9;
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001010 }
1011
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +00001012 bool hasVcmpxPermlaneHazard() const {
1013 return HasVcmpxPermlaneHazard;
1014 }
1015
1016 bool hasVMEMtoScalarWriteHazard() const {
1017 return HasVMEMtoScalarWriteHazard;
1018 }
1019
1020 bool hasSMEMtoVectorWriteHazard() const {
1021 return HasSMEMtoVectorWriteHazard;
1022 }
1023
1024 bool hasLDSMisalignedBug() const {
1025 return LDSMisalignedBug && !EnableCuMode;
1026 }
1027
1028 bool hasInstFwdPrefetchBug() const {
1029 return HasInstFwdPrefetchBug;
1030 }
1031
1032 bool hasVcmpxExecWARHazard() const {
1033 return HasVcmpxExecWARHazard;
1034 }
1035
1036 bool hasLdsBranchVmemWARHazard() const {
1037 return HasLdsBranchVmemWARHazard;
1038 }
1039
1040 bool hasNSAtoVMEMBug() const {
1041 return HasNSAtoVMEMBug;
1042 }
1043
Tom Stellardc5a154d2018-06-28 23:47:12 +00001044 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
1045 /// SGPRs
Tom Stellard0d23ebe2016-08-29 19:42:52 +00001046 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
1047
Tom Stellardc5a154d2018-06-28 23:47:12 +00001048 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
1049 /// VGPRs
Tom Stellard0d23ebe2016-08-29 19:42:52 +00001050 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +00001051
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +00001052 /// Return occupancy for the given function. Used LDS and a number of
1053 /// registers if provided.
1054 /// Note, occupancy can be affected by the scratch allocation as well, but
1055 /// we do not have enough information to compute it.
1056 unsigned computeOccupancy(const MachineFunction &MF, unsigned LDSSize = 0,
1057 unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const;
1058
Matt Arsenaulte823d922017-02-18 18:29:53 +00001059 /// \returns true if the flat_scratch register should be initialized with the
1060 /// pointer to the wave's scratch memory rather than a size and offset.
1061 bool flatScratchIsPointer() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +00001062 return getGeneration() >= AMDGPUSubtarget::GFX9;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +00001063 }
Matt Arsenault4eae3012016-10-28 20:31:47 +00001064
Tim Renouf832f90f2018-02-26 14:46:43 +00001065 /// \returns true if the machine has merged shaders in which s0-s7 are
1066 /// reserved by the hardware and user SGPRs start at s8
1067 bool hasMergedShaders() const {
1068 return getGeneration() >= GFX9;
1069 }
1070
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001071 /// \returns SGPR allocation granularity supported by the subtarget.
1072 unsigned getSGPRAllocGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001073 return AMDGPU::IsaInfo::getSGPRAllocGranule(this);
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001074 }
1075
1076 /// \returns SGPR encoding granularity supported by the subtarget.
1077 unsigned getSGPREncodingGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001078 return AMDGPU::IsaInfo::getSGPREncodingGranule(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001079 }
1080
1081 /// \returns Total number of SGPRs supported by the subtarget.
1082 unsigned getTotalNumSGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001083 return AMDGPU::IsaInfo::getTotalNumSGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001084 }
1085
1086 /// \returns Addressable number of SGPRs supported by the subtarget.
1087 unsigned getAddressableNumSGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001088 return AMDGPU::IsaInfo::getAddressableNumSGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001089 }
1090
1091 /// \returns Minimum number of SGPRs that meets the given number of waves per
1092 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001093 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001094 return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001095 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001096
1097 /// \returns Maximum number of SGPRs that meets the given number of waves per
1098 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001099 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001100 return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001101 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001102
1103 /// \returns Reserved number of SGPRs for given function \p MF.
1104 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
1105
1106 /// \returns Maximum number of SGPRs that meets number of waves per execution
1107 /// unit requirement for function \p MF, or number of SGPRs explicitly
1108 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
1109 ///
1110 /// \returns Value that meets number of waves per execution unit requirement
1111 /// if explicitly requested value cannot be converted to integer, violates
1112 /// subtarget's specifications, or does not meet number of waves per execution
1113 /// unit requirement.
1114 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
1115
1116 /// \returns VGPR allocation granularity supported by the subtarget.
1117 unsigned getVGPRAllocGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001118 return AMDGPU::IsaInfo::getVGPRAllocGranule(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001119 }
1120
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001121 /// \returns VGPR encoding granularity supported by the subtarget.
1122 unsigned getVGPREncodingGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001123 return AMDGPU::IsaInfo::getVGPREncodingGranule(this);
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001124 }
1125
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001126 /// \returns Total number of VGPRs supported by the subtarget.
1127 unsigned getTotalNumVGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001128 return AMDGPU::IsaInfo::getTotalNumVGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001129 }
1130
1131 /// \returns Addressable number of VGPRs supported by the subtarget.
1132 unsigned getAddressableNumVGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001133 return AMDGPU::IsaInfo::getAddressableNumVGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001134 }
1135
1136 /// \returns Minimum number of VGPRs that meets given number of waves per
1137 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001138 unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001139 return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001140 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001141
1142 /// \returns Maximum number of VGPRs that meets given number of waves per
1143 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001144 unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001145 return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001146 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001147
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001148 /// \returns Maximum number of VGPRs that meets number of waves per execution
1149 /// unit requirement for function \p MF, or number of VGPRs explicitly
1150 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
1151 ///
1152 /// \returns Value that meets number of waves per execution unit requirement
1153 /// if explicitly requested value cannot be converted to integer, violates
1154 /// subtarget's specifications, or does not meet number of waves per execution
1155 /// unit requirement.
1156 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
Stanislav Mekhanoshind4ae4702017-09-19 20:54:38 +00001157
1158 void getPostRAMutations(
1159 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
1160 const override;
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001161
Stanislav Mekhanoshin68a2fef2019-06-13 23:47:36 +00001162 bool isWave32() const {
1163 return WavefrontSize == 32;
1164 }
1165
Stanislav Mekhanoshin52500212019-06-16 17:13:09 +00001166 const TargetRegisterClass *getBoolRC() const {
1167 return getRegisterInfo()->getBoolRC();
1168 }
1169
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001170 /// \returns Maximum number of work groups per compute unit supported by the
1171 /// subtarget and limited by given \p FlatWorkGroupSize.
1172 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1173 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1174 }
1175
1176 /// \returns Minimum flat work group size supported by the subtarget.
1177 unsigned getMinFlatWorkGroupSize() const override {
1178 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1179 }
1180
1181 /// \returns Maximum flat work group size supported by the subtarget.
1182 unsigned getMaxFlatWorkGroupSize() const override {
1183 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1184 }
1185
1186 /// \returns Maximum number of waves per execution unit supported by the
1187 /// subtarget and limited by given \p FlatWorkGroupSize.
1188 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override {
1189 return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize);
1190 }
1191
1192 /// \returns Minimum number of waves per execution unit supported by the
1193 /// subtarget.
1194 unsigned getMinWavesPerEU() const override {
1195 return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1196 }
Tom Stellard75aadc22012-12-11 21:25:42 +00001197};
1198
Tom Stellardc5a154d2018-06-28 23:47:12 +00001199class R600Subtarget final : public R600GenSubtargetInfo,
Tom Stellard5bfbae52018-07-11 20:59:01 +00001200 public AMDGPUSubtarget {
Tom Stellardc5a154d2018-06-28 23:47:12 +00001201private:
1202 R600InstrInfo InstrInfo;
1203 R600FrameLowering FrameLowering;
1204 bool FMA;
1205 bool CaymanISA;
1206 bool CFALUBug;
Tom Stellardc5a154d2018-06-28 23:47:12 +00001207 bool HasVertexCache;
1208 bool R600ALUInst;
1209 bool FP64;
1210 short TexVTXClauseSize;
1211 Generation Gen;
1212 R600TargetLowering TLInfo;
1213 InstrItineraryData InstrItins;
1214 SelectionDAGTargetInfo TSInfo;
Tom Stellardc5a154d2018-06-28 23:47:12 +00001215
1216public:
1217 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
1218 const TargetMachine &TM);
1219
1220 const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; }
1221
1222 const R600FrameLowering *getFrameLowering() const override {
1223 return &FrameLowering;
1224 }
1225
1226 const R600TargetLowering *getTargetLowering() const override {
1227 return &TLInfo;
1228 }
1229
1230 const R600RegisterInfo *getRegisterInfo() const override {
1231 return &InstrInfo.getRegisterInfo();
1232 }
1233
1234 const InstrItineraryData *getInstrItineraryData() const override {
1235 return &InstrItins;
1236 }
1237
1238 // Nothing implemented, just prevent crashes on use.
1239 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
1240 return &TSInfo;
1241 }
1242
1243 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
1244
1245 Generation getGeneration() const {
1246 return Gen;
1247 }
1248
1249 unsigned getStackAlignment() const {
1250 return 4;
1251 }
1252
1253 R600Subtarget &initializeSubtargetDependencies(const Triple &TT,
1254 StringRef GPU, StringRef FS);
1255
1256 bool hasBFE() const {
1257 return (getGeneration() >= EVERGREEN);
1258 }
1259
1260 bool hasBFI() const {
1261 return (getGeneration() >= EVERGREEN);
1262 }
1263
1264 bool hasBCNT(unsigned Size) const {
1265 if (Size == 32)
1266 return (getGeneration() >= EVERGREEN);
1267
1268 return false;
1269 }
1270
1271 bool hasBORROW() const {
1272 return (getGeneration() >= EVERGREEN);
1273 }
1274
1275 bool hasCARRY() const {
1276 return (getGeneration() >= EVERGREEN);
1277 }
1278
1279 bool hasCaymanISA() const {
1280 return CaymanISA;
1281 }
1282
1283 bool hasFFBL() const {
1284 return (getGeneration() >= EVERGREEN);
1285 }
1286
1287 bool hasFFBH() const {
1288 return (getGeneration() >= EVERGREEN);
1289 }
1290
1291 bool hasFMA() const { return FMA; }
1292
Tom Stellardc5a154d2018-06-28 23:47:12 +00001293 bool hasCFAluBug() const { return CFALUBug; }
1294
1295 bool hasVertexCache() const { return HasVertexCache; }
1296
1297 short getTexVTXClauseSize() const { return TexVTXClauseSize; }
1298
Tom Stellardc5a154d2018-06-28 23:47:12 +00001299 bool enableMachineScheduler() const override {
1300 return true;
1301 }
1302
1303 bool enableSubRegLiveness() const override {
1304 return true;
1305 }
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001306
1307 /// \returns Maximum number of work groups per compute unit supported by the
1308 /// subtarget and limited by given \p FlatWorkGroupSize.
1309 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1310 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1311 }
1312
1313 /// \returns Minimum flat work group size supported by the subtarget.
1314 unsigned getMinFlatWorkGroupSize() const override {
1315 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1316 }
1317
1318 /// \returns Maximum flat work group size supported by the subtarget.
1319 unsigned getMaxFlatWorkGroupSize() const override {
1320 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1321 }
1322
1323 /// \returns Maximum number of waves per execution unit supported by the
1324 /// subtarget and limited by given \p FlatWorkGroupSize.
1325 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override {
1326 return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize);
1327 }
1328
1329 /// \returns Minimum number of waves per execution unit supported by the
1330 /// subtarget.
1331 unsigned getMinWavesPerEU() const override {
1332 return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1333 }
Tom Stellardc5a154d2018-06-28 23:47:12 +00001334};
1335
Eugene Zelenko2bc2f332016-12-09 22:06:55 +00001336} // end namespace llvm
Tom Stellard75aadc22012-12-11 21:25:42 +00001337
Eugene Zelenko2bc2f332016-12-09 22:06:55 +00001338#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H