blob: 3ac6fe283c4cc1ed352130270226d59c2ec7b4ca [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//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//==-----------------------------------------------------------------------===//
9//
10/// \file
11/// \brief AMDGPU specific subclass of TargetSubtarget.
12//
13//===----------------------------------------------------------------------===//
14
Matt Arsenault0c90e952015-11-06 18:17:45 +000015#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
16#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
Matt Arsenaultf59e5382015-11-06 18:23:00 +000017
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000018#include "AMDGPU.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000019#include "AMDGPUCallLowering.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000020#include "R600FrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000021#include "R600ISelLowering.h"
22#include "R600InstrInfo.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000023#include "SIFrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000024#include "SIISelLowering.h"
25#include "SIInstrInfo.h"
Valery Pykhtinfd4c4102017-03-21 13:15:46 +000026#include "SIMachineFunctionInfo.h"
Tom Stellard347ac792015-06-26 21:15:07 +000027#include "Utils/AMDGPUBaseInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000028#include "llvm/ADT/Triple.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000029#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
30#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
31#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000032#include "llvm/CodeGen/MachineFunction.h"
Matt Arsenault56684d42016-08-11 17:31:42 +000033#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000034#include "llvm/MC/MCInstrItineraries.h"
35#include "llvm/Support/MathExtras.h"
36#include <cassert>
37#include <cstdint>
38#include <memory>
39#include <utility>
Tom Stellard75aadc22012-12-11 21:25:42 +000040
41#define GET_SUBTARGETINFO_HEADER
42#include "AMDGPUGenSubtargetInfo.inc"
43
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 Stellard75aadc22012-12-11 21:25:42 +000048class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000049public:
50 enum Generation {
51 R600 = 0,
52 R700,
53 EVERGREEN,
54 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000055 SOUTHERN_ISLANDS,
Marek Olsak5df00d62014-12-07 12:18:57 +000056 SEA_ISLANDS,
57 VOLCANIC_ISLANDS,
Matt Arsenaulte823d922017-02-18 18:29:53 +000058 GFX9,
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000059 };
60
Marek Olsak4d00dd22015-03-09 15:48:09 +000061 enum {
Tom Stellard347ac792015-06-26 21:15:07 +000062 ISAVersion0_0_0,
Wei Ding7c3e5112017-06-10 03:53:19 +000063 ISAVersion6_0_0,
64 ISAVersion6_0_1,
Tom Stellard347ac792015-06-26 21:15:07 +000065 ISAVersion7_0_0,
66 ISAVersion7_0_1,
Yaxun Liu94add852016-10-26 16:37:56 +000067 ISAVersion7_0_2,
Wei Ding7c3e5112017-06-10 03:53:19 +000068 ISAVersion7_0_3,
Tom Stellard347ac792015-06-26 21:15:07 +000069 ISAVersion8_0_0,
Changpeng Fangc16be002016-01-13 20:39:25 +000070 ISAVersion8_0_1,
Changpeng Fang98317d22016-10-11 16:00:47 +000071 ISAVersion8_0_2,
Yaxun Liu94add852016-10-26 16:37:56 +000072 ISAVersion8_0_3,
73 ISAVersion8_0_4,
74 ISAVersion8_1_0,
Matt Arsenaulte823d922017-02-18 18:29:53 +000075 ISAVersion9_0_0,
Wei Ding7c3e5112017-06-10 03:53:19 +000076 ISAVersion9_0_1,
77 ISAVersion9_0_2,
78 ISAVersion9_0_3
Tom Stellard347ac792015-06-26 21:15:07 +000079 };
80
Wei Ding205bfdb2017-02-10 02:15:29 +000081 enum TrapHandlerAbi {
82 TrapHandlerAbiNone = 0,
83 TrapHandlerAbiHsa = 1
84 };
85
Wei Dingf2cce022017-02-22 23:22:19 +000086 enum TrapID {
87 TrapIDHardwareReserved = 0,
88 TrapIDHSADebugTrap = 1,
89 TrapIDLLVMTrap = 2,
90 TrapIDLLVMDebugTrap = 3,
91 TrapIDDebugBreakpoint = 7,
92 TrapIDDebugReserved8 = 8,
93 TrapIDDebugReservedFE = 0xfe,
94 TrapIDDebugReservedFF = 0xff
Wei Ding205bfdb2017-02-10 02:15:29 +000095 };
96
97 enum TrapRegValues {
Wei Dingf2cce022017-02-22 23:22:19 +000098 LLVMTrapHandlerRegValue = 1
Wei Ding205bfdb2017-02-10 02:15:29 +000099 };
100
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000101protected:
102 // Basic subtarget description.
103 Triple TargetTriple;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000104 Generation Gen;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000105 unsigned IsaVersion;
106 unsigned WavefrontSize;
107 int LocalMemorySize;
108 int LDSBankCount;
109 unsigned MaxPrivateElementSize;
110
111 // Possibly statically set by tablegen, but may want to be overridden.
Matt Arsenaultb035a572015-01-29 19:34:25 +0000112 bool FastFMAF32;
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000113 bool HalfRate64Ops;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000114
115 // Dynamially set bits that enable features.
116 bool FP32Denormals;
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000117 bool FP64FP16Denormals;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000118 bool FPExceptions;
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000119 bool DX10Clamp;
Changpeng Fangb41574a2015-12-22 20:55:23 +0000120 bool FlatForGlobal;
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000121 bool AutoWaitcntBeforeBarrier;
Tom Stellard64a9d082016-10-14 18:10:39 +0000122 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000123 bool UnalignedBufferAccess;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000124 bool HasApertureRegs;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000125 bool EnableXNACK;
Wei Ding205bfdb2017-02-10 02:15:29 +0000126 bool TrapHandler;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000127 bool DebuggerInsertNops;
128 bool DebuggerReserveRegs;
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000129 bool DebuggerEmitPrologue;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000130
131 // Used as options.
132 bool EnableVGPRSpilling;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000133 bool EnablePromoteAlloca;
Matt Arsenault41033282014-10-10 22:01:59 +0000134 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +0000135 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000136 bool EnableSIScheduler;
137 bool DumpCode;
138
139 // Subtarget statically properties set by tablegen
140 bool FP64;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000141 bool IsGCN;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000142 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000143 bool CIInsts;
Matt Arsenault2021f082017-02-18 19:12:26 +0000144 bool GFX9Insts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000145 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000146 bool HasSMemRealTime;
147 bool Has16BitInsts;
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000148 bool HasIntClamp;
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000149 bool HasVOP3PInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000150 bool HasMovrel;
151 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000152 bool HasScalarStores;
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000153 bool HasInv2PiInlineImm;
Sam Kolton07dbde22017-01-20 10:01:25 +0000154 bool HasSDWA;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000155 bool HasSDWAOmod;
156 bool HasSDWAScalar;
157 bool HasSDWASdst;
158 bool HasSDWAMac;
Sam Koltona179d252017-06-27 15:02:23 +0000159 bool HasSDWAOutModsVOPC;
Sam Kolton07dbde22017-01-20 10:01:25 +0000160 bool HasDPP;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000161 bool FlatAddressSpace;
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000162 bool FlatInstOffsets;
163 bool FlatGlobalInsts;
164 bool FlatScratchInsts;
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000165 bool AddNoCarryInsts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000166 bool R600ALUInst;
167 bool CaymanISA;
168 bool CFALUBug;
169 bool HasVertexCache;
170 short TexVTXClauseSize;
Alexander Timofeev18009562016-12-08 17:28:47 +0000171 bool ScalarizeGlobal;
Tom Stellard75aadc22012-12-11 21:25:42 +0000172
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000173 // Dummy feature to use for assembler in tablegen.
174 bool FeatureDisable;
175
Tom Stellard75aadc22012-12-11 21:25:42 +0000176 InstrItineraryData InstrItins;
Matt Arsenault56684d42016-08-11 17:31:42 +0000177 SelectionDAGTargetInfo TSInfo;
Yaxun Liu1a14bfa2017-03-27 14:04:01 +0000178 AMDGPUAS AS;
Tom Stellard75aadc22012-12-11 21:25:42 +0000179
180public:
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000181 AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
182 const TargetMachine &TM);
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000183 ~AMDGPUSubtarget() override;
184
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000185 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
186 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000187
Matt Arsenaultf9245b72016-07-22 17:01:25 +0000188 const AMDGPUInstrInfo *getInstrInfo() const override = 0;
189 const AMDGPUFrameLowering *getFrameLowering() const override = 0;
190 const AMDGPUTargetLowering *getTargetLowering() const override = 0;
191 const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
Tom Stellard000c5af2016-04-14 19:09:28 +0000192
Eric Christopherd9134482014-08-04 21:25:23 +0000193 const InstrItineraryData *getInstrItineraryData() const override {
194 return &InstrItins;
195 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000196
Matt Arsenault56684d42016-08-11 17:31:42 +0000197 // Nothing implemented, just prevent crashes on use.
198 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
199 return &TSInfo;
200 }
201
Craig Topperee7b0f32014-04-30 05:53:27 +0000202 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000203
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000204 bool isAmdHsaOS() const {
205 return TargetTriple.getOS() == Triple::AMDHSA;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000206 }
207
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000208 bool isMesa3DOS() const {
209 return TargetTriple.getOS() == Triple::Mesa3D;
210 }
211
Tom Stellarde88bbc32016-09-23 01:33:26 +0000212 bool isOpenCLEnv() const {
Yaxun Liua618acf2017-06-01 21:31:53 +0000213 return TargetTriple.getEnvironment() == Triple::OpenCL ||
214 TargetTriple.getEnvironmentName() == "amdgizcl";
Tom Stellarde88bbc32016-09-23 01:33:26 +0000215 }
216
Matt Arsenaultd782d052014-06-27 17:57:00 +0000217 Generation getGeneration() const {
218 return Gen;
219 }
220
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000221 unsigned getWavefrontSize() const {
222 return WavefrontSize;
223 }
224
225 int getLocalMemorySize() const {
226 return LocalMemorySize;
227 }
228
229 int getLDSBankCount() const {
230 return LDSBankCount;
231 }
232
233 unsigned getMaxPrivateElementSize() const {
234 return MaxPrivateElementSize;
235 }
236
Yaxun Liu1a14bfa2017-03-27 14:04:01 +0000237 AMDGPUAS getAMDGPUAS() const {
238 return AS;
239 }
240
Konstantin Zhuravlyovd971a112016-11-01 17:49:33 +0000241 bool has16BitInsts() const {
242 return Has16BitInsts;
243 }
244
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000245 bool hasIntClamp() const {
246 return HasIntClamp;
247 }
248
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000249 bool hasVOP3PInsts() const {
250 return HasVOP3PInsts;
251 }
252
Matt Arsenaultd782d052014-06-27 17:57:00 +0000253 bool hasHWFP64() const {
254 return FP64;
255 }
256
Matt Arsenaultb035a572015-01-29 19:34:25 +0000257 bool hasFastFMAF32() const {
258 return FastFMAF32;
259 }
260
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000261 bool hasHalfRate64Ops() const {
262 return HalfRate64Ops;
263 }
264
Matt Arsenault88701812016-06-09 23:42:48 +0000265 bool hasAddr64() const {
266 return (getGeneration() < VOLCANIC_ISLANDS);
267 }
268
Matt Arsenaultfae02982014-03-17 18:58:11 +0000269 bool hasBFE() const {
270 return (getGeneration() >= EVERGREEN);
271 }
272
Matt Arsenault6e439652014-06-10 19:00:20 +0000273 bool hasBFI() const {
274 return (getGeneration() >= EVERGREEN);
275 }
276
Matt Arsenaultfae02982014-03-17 18:58:11 +0000277 bool hasBFM() const {
278 return hasBFE();
279 }
280
Matt Arsenault60425062014-06-10 19:18:28 +0000281 bool hasBCNT(unsigned Size) const {
282 if (Size == 32)
283 return (getGeneration() >= EVERGREEN);
284
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000285 if (Size == 64)
286 return (getGeneration() >= SOUTHERN_ISLANDS);
287
288 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000289 }
290
Tom Stellard50122a52014-04-07 19:45:41 +0000291 bool hasMulU24() const {
292 return (getGeneration() >= EVERGREEN);
293 }
294
295 bool hasMulI24() const {
296 return (getGeneration() >= SOUTHERN_ISLANDS ||
297 hasCaymanISA());
298 }
299
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000300 bool hasFFBL() const {
301 return (getGeneration() >= EVERGREEN);
302 }
303
304 bool hasFFBH() const {
305 return (getGeneration() >= EVERGREEN);
306 }
307
Matt Arsenault10268f92017-02-27 22:40:39 +0000308 bool hasMed3_16() const {
309 return getGeneration() >= GFX9;
310 }
311
Matt Arsenaultee324ff2017-05-17 19:25:06 +0000312 bool hasMin3Max3_16() const {
313 return getGeneration() >= GFX9;
314 }
315
Jan Vesely808fff52015-04-30 17:15:56 +0000316 bool hasCARRY() const {
317 return (getGeneration() >= EVERGREEN);
318 }
319
320 bool hasBORROW() const {
321 return (getGeneration() >= EVERGREEN);
322 }
323
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000324 bool hasCaymanISA() const {
325 return CaymanISA;
326 }
327
Wei Ding205bfdb2017-02-10 02:15:29 +0000328 TrapHandlerAbi getTrapHandlerAbi() const {
329 return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
330 }
331
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000332 bool isPromoteAllocaEnabled() const {
333 return EnablePromoteAlloca;
334 }
335
Matt Arsenault706f9302015-07-06 16:01:58 +0000336 bool unsafeDSOffsetFoldingEnabled() const {
337 return EnableUnsafeDSOffsetFolding;
338 }
339
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000340 bool dumpCode() const {
341 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000342 }
343
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000344 /// Return the amount of LDS that can be used that will not restrict the
345 /// occupancy lower than WaveCount.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000346 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
347 const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000348
349 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
350 /// the given LDS memory size is the only constraint.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000351 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000352
Valery Pykhtinfd4c4102017-03-21 13:15:46 +0000353 unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const {
354 const auto *MFI = MF.getInfo<SIMachineFunctionInfo>();
355 return getOccupancyWithLocalMemSize(MFI->getLDSSize(), *MF.getFunction());
356 }
357
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000358 bool hasFP16Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000359 return FP64FP16Denormals;
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000360 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000361
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000362 bool hasFP32Denormals() const {
363 return FP32Denormals;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000364 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000365
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000366 bool hasFP64Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000367 return FP64FP16Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000368 }
369
Stanislav Mekhanoshindc2890a2017-07-13 23:59:15 +0000370 bool supportsMinMaxDenormModes() const {
371 return getGeneration() >= AMDGPUSubtarget::GFX9;
372 }
373
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000374 bool hasFPExceptions() const {
375 return FPExceptions;
Marek Olsak4d00dd22015-03-09 15:48:09 +0000376 }
377
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000378 bool enableDX10Clamp() const {
379 return DX10Clamp;
380 }
381
382 bool enableIEEEBit(const MachineFunction &MF) const {
383 return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
384 }
385
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000386 bool useFlatForGlobal() const {
387 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000388 }
389
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000390 bool hasAutoWaitcntBeforeBarrier() const {
391 return AutoWaitcntBeforeBarrier;
392 }
393
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000394 bool hasUnalignedBufferAccess() const {
395 return UnalignedBufferAccess;
396 }
397
Tom Stellard64a9d082016-10-14 18:10:39 +0000398 bool hasUnalignedScratchAccess() const {
399 return UnalignedScratchAccess;
400 }
401
Matt Arsenaulte823d922017-02-18 18:29:53 +0000402 bool hasApertureRegs() const {
403 return HasApertureRegs;
404 }
405
Wei Ding205bfdb2017-02-10 02:15:29 +0000406 bool isTrapHandlerEnabled() const {
407 return TrapHandler;
408 }
409
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000410 bool isXNACKEnabled() const {
411 return EnableXNACK;
412 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000413
Matt Arsenaultb6491cc2017-01-31 01:20:54 +0000414 bool hasFlatAddressSpace() const {
415 return FlatAddressSpace;
416 }
417
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000418 bool hasFlatInstOffsets() const {
419 return FlatInstOffsets;
420 }
421
422 bool hasFlatGlobalInsts() const {
423 return FlatGlobalInsts;
424 }
425
426 bool hasFlatScratchInsts() const {
427 return FlatScratchInsts;
428 }
429
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000430 bool hasAddNoCarry() const {
431 return AddNoCarryInsts;
432 }
433
Tom Stellard2f3f9852017-01-25 01:25:13 +0000434 bool isMesaKernel(const MachineFunction &MF) const {
435 return isMesa3DOS() && !AMDGPU::isShader(MF.getFunction()->getCallingConv());
436 }
437
438 // Covers VS/PS/CS graphics shaders
439 bool isMesaGfxShader(const MachineFunction &MF) const {
440 return isMesa3DOS() && AMDGPU::isShader(MF.getFunction()->getCallingConv());
441 }
442
443 bool isAmdCodeObjectV2(const MachineFunction &MF) const {
444 return isAmdHsaOS() || isMesaKernel(MF);
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000445 }
446
Matt Arsenaultda7a6562017-02-01 00:42:40 +0000447 bool hasFminFmaxLegacy() const {
448 return getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS;
449 }
450
Stanislav Mekhanoshin53a21292017-05-23 19:54:48 +0000451 bool hasSDWA() const {
452 return HasSDWA;
453 }
454
Sam Kolton3c4933f2017-06-22 06:26:41 +0000455 bool hasSDWAOmod() const {
456 return HasSDWAOmod;
457 }
458
459 bool hasSDWAScalar() const {
460 return HasSDWAScalar;
461 }
462
463 bool hasSDWASdst() const {
464 return HasSDWASdst;
465 }
466
467 bool hasSDWAMac() const {
468 return HasSDWAMac;
469 }
470
Sam Koltona179d252017-06-27 15:02:23 +0000471 bool hasSDWAOutModsVOPC() const {
472 return HasSDWAOutModsVOPC;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000473 }
474
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000475 /// \brief Returns the offset in bytes from the start of the input buffer
476 /// of the first explicit kernel argument.
Tom Stellard2f3f9852017-01-25 01:25:13 +0000477 unsigned getExplicitKernelArgOffset(const MachineFunction &MF) const {
478 return isAmdCodeObjectV2(MF) ? 0 : 36;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000479 }
480
Tom Stellardb2869eb2016-09-09 19:28:00 +0000481 unsigned getAlignmentForImplicitArgPtr() const {
482 return isAmdHsaOS() ? 8 : 4;
483 }
484
Tom Stellard2f3f9852017-01-25 01:25:13 +0000485 unsigned getImplicitArgNumBytes(const MachineFunction &MF) const {
486 if (isMesaKernel(MF))
Tom Stellarde88bbc32016-09-23 01:33:26 +0000487 return 16;
488 if (isAmdHsaOS() && isOpenCLEnv())
489 return 32;
490 return 0;
491 }
492
Matt Arsenault869fec22017-04-17 19:48:24 +0000493 // Scratch is allocated in 256 dword per wave blocks for the entire
494 // wavefront. When viewed from the perspecive of an arbitrary workitem, this
495 // is 4-byte aligned.
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000496 unsigned getStackAlignment() const {
Matt Arsenault869fec22017-04-17 19:48:24 +0000497 return 4;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000498 }
Tom Stellard347ac792015-06-26 21:15:07 +0000499
Craig Topper5656db42014-04-29 07:57:24 +0000500 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000501 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000502 }
503
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000504 bool enableSubRegLiveness() const override {
505 return true;
506 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000507
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000508 void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b;}
509 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal;}
510
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000511 /// \returns Number of execution units per compute unit supported by the
512 /// subtarget.
513 unsigned getEUsPerCU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000514 return AMDGPU::IsaInfo::getEUsPerCU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000515 }
516
517 /// \returns Maximum number of work groups per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000518 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000519 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000520 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(getFeatureBits(),
521 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000522 }
523
524 /// \returns Maximum number of waves per compute unit supported by the
525 /// subtarget without any kind of limitation.
526 unsigned getMaxWavesPerCU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000527 return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000528 }
529
530 /// \returns Maximum number of waves per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000531 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000532 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000533 return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits(),
534 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000535 }
536
537 /// \returns Minimum number of waves per execution unit supported by the
538 /// subtarget.
539 unsigned getMinWavesPerEU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000540 return AMDGPU::IsaInfo::getMinWavesPerEU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000541 }
542
543 /// \returns Maximum number of waves per execution unit supported by the
544 /// subtarget without any kind of limitation.
545 unsigned getMaxWavesPerEU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000546 return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000547 }
548
549 /// \returns Maximum number of waves per execution unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000550 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000551 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000552 return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits(),
553 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000554 }
555
556 /// \returns Minimum flat work group size supported by the subtarget.
557 unsigned getMinFlatWorkGroupSize() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000558 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000559 }
560
561 /// \returns Maximum flat work group size supported by the subtarget.
562 unsigned getMaxFlatWorkGroupSize() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000563 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000564 }
565
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000566 /// \returns Number of waves per work group supported by the subtarget and
567 /// limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000568 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000569 return AMDGPU::IsaInfo::getWavesPerWorkGroup(getFeatureBits(),
570 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000571 }
572
573 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
574 /// for function \p F, or minimum/maximum flat work group sizes explicitly
575 /// requested using "amdgpu-flat-work-group-size" attribute attached to
576 /// function \p F.
577 ///
578 /// \returns Subtarget's default values if explicitly requested values cannot
579 /// be converted to integer, or violate subtarget's specifications.
580 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
581
582 /// \returns Subtarget's default pair of minimum/maximum number of waves per
583 /// execution unit for function \p F, or minimum/maximum number of waves per
584 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
585 /// attached to function \p F.
586 ///
587 /// \returns Subtarget's default values if explicitly requested values cannot
588 /// be converted to integer, violate subtarget's specifications, or are not
589 /// compatible with minimum/maximum number of waves limited by flat work group
590 /// size, register usage, and/or lds usage.
591 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
Stanislav Mekhanoshinc90347d2017-04-12 20:48:56 +0000592
593 /// Creates value range metadata on an workitemid.* inrinsic call or load.
594 bool makeLIDRangeMetadata(Instruction *I) const;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000595};
596
597class R600Subtarget final : public AMDGPUSubtarget {
598private:
599 R600InstrInfo InstrInfo;
600 R600FrameLowering FrameLowering;
601 R600TargetLowering TLInfo;
602
603public:
604 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
605 const TargetMachine &TM);
606
607 const R600InstrInfo *getInstrInfo() const override {
608 return &InstrInfo;
609 }
610
611 const R600FrameLowering *getFrameLowering() const override {
612 return &FrameLowering;
613 }
614
615 const R600TargetLowering *getTargetLowering() const override {
616 return &TLInfo;
617 }
618
619 const R600RegisterInfo *getRegisterInfo() const override {
620 return &InstrInfo.getRegisterInfo();
621 }
622
623 bool hasCFAluBug() const {
624 return CFALUBug;
625 }
626
627 bool hasVertexCache() const {
628 return HasVertexCache;
629 }
630
631 short getTexVTXClauseSize() const {
632 return TexVTXClauseSize;
633 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000634};
635
636class SISubtarget final : public AMDGPUSubtarget {
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000637private:
638 SIInstrInfo InstrInfo;
639 SIFrameLowering FrameLowering;
640 SITargetLowering TLInfo;
Quentin Colombet61d71a12017-08-15 22:31:51 +0000641
642 /// GlobalISel related APIs.
643 std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
644 std::unique_ptr<InstructionSelector> InstSelector;
645 std::unique_ptr<LegalizerInfo> Legalizer;
646 std::unique_ptr<RegisterBankInfo> RegBankInfo;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000647
648public:
649 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
650 const TargetMachine &TM);
651
652 const SIInstrInfo *getInstrInfo() const override {
653 return &InstrInfo;
654 }
655
656 const SIFrameLowering *getFrameLowering() const override {
657 return &FrameLowering;
658 }
659
660 const SITargetLowering *getTargetLowering() const override {
661 return &TLInfo;
662 }
663
664 const CallLowering *getCallLowering() const override {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000665 return CallLoweringInfo.get();
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000666 }
667
Tom Stellardca166212017-01-30 21:56:46 +0000668 const InstructionSelector *getInstructionSelector() const override {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000669 return InstSelector.get();
Tom Stellardca166212017-01-30 21:56:46 +0000670 }
671
672 const LegalizerInfo *getLegalizerInfo() const override {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000673 return Legalizer.get();
Tom Stellardca166212017-01-30 21:56:46 +0000674 }
675
676 const RegisterBankInfo *getRegBankInfo() const override {
Quentin Colombet61d71a12017-08-15 22:31:51 +0000677 return RegBankInfo.get();
Tom Stellardca166212017-01-30 21:56:46 +0000678 }
679
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000680 const SIRegisterInfo *getRegisterInfo() const override {
681 return &InstrInfo.getRegisterInfo();
682 }
683
Matt Arsenault9f5e0ef2017-01-25 04:25:02 +0000684 // XXX - Why is this here if it isn't in the default pass set?
685 bool enableEarlyIfConversion() const override {
686 return true;
687 }
688
Tom Stellard83f0bce2015-01-29 16:55:25 +0000689 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000690 unsigned NumRegionInstrs) const override;
691
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000692 bool isVGPRSpillingEnabled(const Function& F) const;
693
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000694 unsigned getMaxNumUserSGPRs() const {
695 return 16;
696 }
697
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000698 bool hasSMemRealTime() const {
699 return HasSMemRealTime;
700 }
701
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000702 bool hasMovrel() const {
703 return HasMovrel;
704 }
705
706 bool hasVGPRIndexMode() const {
707 return HasVGPRIndexMode;
708 }
709
Marek Olsake22fdb92017-03-21 17:00:32 +0000710 bool useVGPRIndexMode(bool UserEnable) const {
711 return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
712 }
713
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000714 bool hasScalarCompareEq64() const {
715 return getGeneration() >= VOLCANIC_ISLANDS;
716 }
717
Matt Arsenault7b647552016-10-28 21:55:15 +0000718 bool hasScalarStores() const {
719 return HasScalarStores;
720 }
721
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000722 bool hasInv2PiInlineImm() const {
723 return HasInv2PiInlineImm;
724 }
725
Sam Kolton07dbde22017-01-20 10:01:25 +0000726 bool hasDPP() const {
727 return HasDPP;
728 }
729
Tom Stellardde008d32016-01-21 04:28:34 +0000730 bool enableSIScheduler() const {
731 return EnableSIScheduler;
732 }
733
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000734 bool debuggerSupported() const {
735 return debuggerInsertNops() && debuggerReserveRegs() &&
736 debuggerEmitPrologue();
737 }
738
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000739 bool debuggerInsertNops() const {
740 return DebuggerInsertNops;
741 }
742
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000743 bool debuggerReserveRegs() const {
744 return DebuggerReserveRegs;
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000745 }
746
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000747 bool debuggerEmitPrologue() const {
748 return DebuggerEmitPrologue;
749 }
750
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000751 bool loadStoreOptEnabled() const {
752 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000753 }
754
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000755 bool hasSGPRInitBug() const {
756 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000757 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000758
Tom Stellardb133fbb2016-10-27 23:05:31 +0000759 bool has12DWordStoreHazard() const {
760 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
761 }
762
Matt Arsenaulte823d922017-02-18 18:29:53 +0000763 bool hasSMovFedHazard() const {
764 return getGeneration() >= AMDGPUSubtarget::GFX9;
765 }
766
767 bool hasReadM0Hazard() const {
768 return getGeneration() >= AMDGPUSubtarget::GFX9;
769 }
770
Matt Arsenault9166ce82017-07-28 15:52:08 +0000771 unsigned getKernArgSegmentSize(const MachineFunction &MF,
772 unsigned ExplictArgBytes) const;
Tom Stellarde88bbc32016-09-23 01:33:26 +0000773
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000774 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
775 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
776
777 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
778 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000779
Matt Arsenaulte823d922017-02-18 18:29:53 +0000780 /// \returns true if the flat_scratch register should be initialized with the
781 /// pointer to the wave's scratch memory rather than a size and offset.
782 bool flatScratchIsPointer() const {
783 return getGeneration() >= GFX9;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000784 }
Matt Arsenault4eae3012016-10-28 20:31:47 +0000785
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000786 /// \returns SGPR allocation granularity supported by the subtarget.
787 unsigned getSGPRAllocGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000788 return AMDGPU::IsaInfo::getSGPRAllocGranule(getFeatureBits());
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000789 }
790
791 /// \returns SGPR encoding granularity supported by the subtarget.
792 unsigned getSGPREncodingGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000793 return AMDGPU::IsaInfo::getSGPREncodingGranule(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000794 }
795
796 /// \returns Total number of SGPRs supported by the subtarget.
797 unsigned getTotalNumSGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000798 return AMDGPU::IsaInfo::getTotalNumSGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000799 }
800
801 /// \returns Addressable number of SGPRs supported by the subtarget.
802 unsigned getAddressableNumSGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000803 return AMDGPU::IsaInfo::getAddressableNumSGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000804 }
805
806 /// \returns Minimum number of SGPRs that meets the given number of waves per
807 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000808 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
809 return AMDGPU::IsaInfo::getMinNumSGPRs(getFeatureBits(), WavesPerEU);
810 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000811
812 /// \returns Maximum number of SGPRs that meets the given number of waves per
813 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000814 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
815 return AMDGPU::IsaInfo::getMaxNumSGPRs(getFeatureBits(), WavesPerEU,
816 Addressable);
817 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000818
819 /// \returns Reserved number of SGPRs for given function \p MF.
820 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
821
822 /// \returns Maximum number of SGPRs that meets number of waves per execution
823 /// unit requirement for function \p MF, or number of SGPRs explicitly
824 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
825 ///
826 /// \returns Value that meets number of waves per execution unit requirement
827 /// if explicitly requested value cannot be converted to integer, violates
828 /// subtarget's specifications, or does not meet number of waves per execution
829 /// unit requirement.
830 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
831
832 /// \returns VGPR allocation granularity supported by the subtarget.
833 unsigned getVGPRAllocGranule() const {
Mandeep Singh Grang5e1697e2017-06-06 05:08:36 +0000834 return AMDGPU::IsaInfo::getVGPRAllocGranule(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000835 }
836
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000837 /// \returns VGPR encoding granularity supported by the subtarget.
838 unsigned getVGPREncodingGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000839 return AMDGPU::IsaInfo::getVGPREncodingGranule(getFeatureBits());
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000840 }
841
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000842 /// \returns Total number of VGPRs supported by the subtarget.
843 unsigned getTotalNumVGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000844 return AMDGPU::IsaInfo::getTotalNumVGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000845 }
846
847 /// \returns Addressable number of VGPRs supported by the subtarget.
848 unsigned getAddressableNumVGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000849 return AMDGPU::IsaInfo::getAddressableNumVGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000850 }
851
852 /// \returns Minimum number of VGPRs that meets given number of waves per
853 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000854 unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
855 return AMDGPU::IsaInfo::getMinNumVGPRs(getFeatureBits(), WavesPerEU);
856 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000857
858 /// \returns Maximum number of VGPRs that meets given number of waves per
859 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000860 unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
861 return AMDGPU::IsaInfo::getMaxNumVGPRs(getFeatureBits(), WavesPerEU);
862 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000863
864 /// \returns Reserved number of VGPRs for given function \p MF.
865 unsigned getReservedNumVGPRs(const MachineFunction &MF) const {
866 return debuggerReserveRegs() ? 4 : 0;
867 }
868
869 /// \returns Maximum number of VGPRs that meets number of waves per execution
870 /// unit requirement for function \p MF, or number of VGPRs explicitly
871 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
872 ///
873 /// \returns Value that meets number of waves per execution unit requirement
874 /// if explicitly requested value cannot be converted to integer, violates
875 /// subtarget's specifications, or does not meet number of waves per execution
876 /// unit requirement.
877 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000878};
879
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000880} // end namespace llvm
Tom Stellard75aadc22012-12-11 21:25:42 +0000881
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000882#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H