blob: 389fdc9d6364981c376797728cf58895a18e57d2 [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"
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"
Valery Pykhtinfd4c4102017-03-21 13:15:46 +000025#include "SIMachineFunctionInfo.h"
Tom Stellard347ac792015-06-26 21:15:07 +000026#include "Utils/AMDGPUBaseInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000027#include "llvm/ADT/Triple.h"
Tom Stellard000c5af2016-04-14 19:09:28 +000028#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000029#include "llvm/CodeGen/MachineFunction.h"
Matt Arsenault56684d42016-08-11 17:31:42 +000030#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000031#include "llvm/MC/MCInstrItineraries.h"
32#include "llvm/Support/MathExtras.h"
33#include <cassert>
34#include <cstdint>
35#include <memory>
36#include <utility>
Tom Stellard75aadc22012-12-11 21:25:42 +000037
38#define GET_SUBTARGETINFO_HEADER
39#include "AMDGPUGenSubtargetInfo.inc"
40
Tom Stellard75aadc22012-12-11 21:25:42 +000041namespace llvm {
42
Matt Arsenault43e92fe2016-06-24 06:30:11 +000043class StringRef;
Tom Stellarde99fb652015-01-20 19:33:04 +000044
Tom Stellard75aadc22012-12-11 21:25:42 +000045class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000046public:
47 enum Generation {
48 R600 = 0,
49 R700,
50 EVERGREEN,
51 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000052 SOUTHERN_ISLANDS,
Marek Olsak5df00d62014-12-07 12:18:57 +000053 SEA_ISLANDS,
54 VOLCANIC_ISLANDS,
Matt Arsenaulte823d922017-02-18 18:29:53 +000055 GFX9,
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000056 };
57
Marek Olsak4d00dd22015-03-09 15:48:09 +000058 enum {
Tom Stellard347ac792015-06-26 21:15:07 +000059 ISAVersion0_0_0,
Wei Ding7c3e5112017-06-10 03:53:19 +000060 ISAVersion6_0_0,
61 ISAVersion6_0_1,
Tom Stellard347ac792015-06-26 21:15:07 +000062 ISAVersion7_0_0,
63 ISAVersion7_0_1,
Yaxun Liu94add852016-10-26 16:37:56 +000064 ISAVersion7_0_2,
Wei Ding7c3e5112017-06-10 03:53:19 +000065 ISAVersion7_0_3,
Tom Stellard347ac792015-06-26 21:15:07 +000066 ISAVersion8_0_0,
Changpeng Fangc16be002016-01-13 20:39:25 +000067 ISAVersion8_0_1,
Changpeng Fang98317d22016-10-11 16:00:47 +000068 ISAVersion8_0_2,
Yaxun Liu94add852016-10-26 16:37:56 +000069 ISAVersion8_0_3,
70 ISAVersion8_0_4,
71 ISAVersion8_1_0,
Matt Arsenaulte823d922017-02-18 18:29:53 +000072 ISAVersion9_0_0,
Wei Ding7c3e5112017-06-10 03:53:19 +000073 ISAVersion9_0_1,
74 ISAVersion9_0_2,
75 ISAVersion9_0_3
Tom Stellard347ac792015-06-26 21:15:07 +000076 };
77
Wei Ding205bfdb2017-02-10 02:15:29 +000078 enum TrapHandlerAbi {
79 TrapHandlerAbiNone = 0,
80 TrapHandlerAbiHsa = 1
81 };
82
Wei Dingf2cce022017-02-22 23:22:19 +000083 enum TrapID {
84 TrapIDHardwareReserved = 0,
85 TrapIDHSADebugTrap = 1,
86 TrapIDLLVMTrap = 2,
87 TrapIDLLVMDebugTrap = 3,
88 TrapIDDebugBreakpoint = 7,
89 TrapIDDebugReserved8 = 8,
90 TrapIDDebugReservedFE = 0xfe,
91 TrapIDDebugReservedFF = 0xff
Wei Ding205bfdb2017-02-10 02:15:29 +000092 };
93
94 enum TrapRegValues {
Wei Dingf2cce022017-02-22 23:22:19 +000095 LLVMTrapHandlerRegValue = 1
Wei Ding205bfdb2017-02-10 02:15:29 +000096 };
97
Matt Arsenault43e92fe2016-06-24 06:30:11 +000098protected:
99 // Basic subtarget description.
100 Triple TargetTriple;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000101 Generation Gen;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000102 unsigned IsaVersion;
103 unsigned WavefrontSize;
104 int LocalMemorySize;
105 int LDSBankCount;
106 unsigned MaxPrivateElementSize;
107
108 // Possibly statically set by tablegen, but may want to be overridden.
Matt Arsenaultb035a572015-01-29 19:34:25 +0000109 bool FastFMAF32;
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000110 bool HalfRate64Ops;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000111
112 // Dynamially set bits that enable features.
113 bool FP32Denormals;
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000114 bool FP64FP16Denormals;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000115 bool FPExceptions;
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000116 bool DX10Clamp;
Changpeng Fangb41574a2015-12-22 20:55:23 +0000117 bool FlatForGlobal;
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000118 bool AutoWaitcntBeforeBarrier;
Tom Stellard64a9d082016-10-14 18:10:39 +0000119 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000120 bool UnalignedBufferAccess;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000121 bool HasApertureRegs;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000122 bool EnableXNACK;
Wei Ding205bfdb2017-02-10 02:15:29 +0000123 bool TrapHandler;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000124 bool DebuggerInsertNops;
125 bool DebuggerReserveRegs;
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000126 bool DebuggerEmitPrologue;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000127
128 // Used as options.
129 bool EnableVGPRSpilling;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000130 bool EnablePromoteAlloca;
Matt Arsenault41033282014-10-10 22:01:59 +0000131 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +0000132 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000133 bool EnableSIScheduler;
134 bool DumpCode;
135
136 // Subtarget statically properties set by tablegen
137 bool FP64;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000138 bool IsGCN;
139 bool GCN1Encoding;
140 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000141 bool CIInsts;
Matt Arsenault2021f082017-02-18 19:12:26 +0000142 bool GFX9Insts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000143 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000144 bool HasSMemRealTime;
145 bool Has16BitInsts;
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000146 bool HasVOP3PInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000147 bool HasMovrel;
148 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000149 bool HasScalarStores;
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000150 bool HasInv2PiInlineImm;
Sam Kolton07dbde22017-01-20 10:01:25 +0000151 bool HasSDWA;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000152 bool HasSDWAOmod;
153 bool HasSDWAScalar;
154 bool HasSDWASdst;
155 bool HasSDWAMac;
Sam Koltona179d252017-06-27 15:02:23 +0000156 bool HasSDWAOutModsVOPC;
Sam Kolton07dbde22017-01-20 10:01:25 +0000157 bool HasDPP;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000158 bool FlatAddressSpace;
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000159 bool FlatInstOffsets;
160 bool FlatGlobalInsts;
161 bool FlatScratchInsts;
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000162 bool AddNoCarryInsts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000163 bool R600ALUInst;
164 bool CaymanISA;
165 bool CFALUBug;
166 bool HasVertexCache;
167 short TexVTXClauseSize;
Alexander Timofeev18009562016-12-08 17:28:47 +0000168 bool ScalarizeGlobal;
Tom Stellard75aadc22012-12-11 21:25:42 +0000169
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000170 // Dummy feature to use for assembler in tablegen.
171 bool FeatureDisable;
172
Tom Stellard75aadc22012-12-11 21:25:42 +0000173 InstrItineraryData InstrItins;
Matt Arsenault56684d42016-08-11 17:31:42 +0000174 SelectionDAGTargetInfo TSInfo;
Yaxun Liu1a14bfa2017-03-27 14:04:01 +0000175 AMDGPUAS AS;
Tom Stellard75aadc22012-12-11 21:25:42 +0000176
177public:
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000178 AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
179 const TargetMachine &TM);
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000180 ~AMDGPUSubtarget() override;
181
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000182 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
183 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000184
Matt Arsenaultf9245b72016-07-22 17:01:25 +0000185 const AMDGPUInstrInfo *getInstrInfo() const override = 0;
186 const AMDGPUFrameLowering *getFrameLowering() const override = 0;
187 const AMDGPUTargetLowering *getTargetLowering() const override = 0;
188 const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
Tom Stellard000c5af2016-04-14 19:09:28 +0000189
Eric Christopherd9134482014-08-04 21:25:23 +0000190 const InstrItineraryData *getInstrItineraryData() const override {
191 return &InstrItins;
192 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000193
Matt Arsenault56684d42016-08-11 17:31:42 +0000194 // Nothing implemented, just prevent crashes on use.
195 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
196 return &TSInfo;
197 }
198
Craig Topperee7b0f32014-04-30 05:53:27 +0000199 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000200
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000201 bool isAmdHsaOS() const {
202 return TargetTriple.getOS() == Triple::AMDHSA;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000203 }
204
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000205 bool isMesa3DOS() const {
206 return TargetTriple.getOS() == Triple::Mesa3D;
207 }
208
Tom Stellarde88bbc32016-09-23 01:33:26 +0000209 bool isOpenCLEnv() const {
Yaxun Liua618acf2017-06-01 21:31:53 +0000210 return TargetTriple.getEnvironment() == Triple::OpenCL ||
211 TargetTriple.getEnvironmentName() == "amdgizcl";
Tom Stellarde88bbc32016-09-23 01:33:26 +0000212 }
213
Matt Arsenaultd782d052014-06-27 17:57:00 +0000214 Generation getGeneration() const {
215 return Gen;
216 }
217
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000218 unsigned getWavefrontSize() const {
219 return WavefrontSize;
220 }
221
222 int getLocalMemorySize() const {
223 return LocalMemorySize;
224 }
225
226 int getLDSBankCount() const {
227 return LDSBankCount;
228 }
229
230 unsigned getMaxPrivateElementSize() const {
231 return MaxPrivateElementSize;
232 }
233
Yaxun Liu1a14bfa2017-03-27 14:04:01 +0000234 AMDGPUAS getAMDGPUAS() const {
235 return AS;
236 }
237
Konstantin Zhuravlyovd971a112016-11-01 17:49:33 +0000238 bool has16BitInsts() const {
239 return Has16BitInsts;
240 }
241
Matt Arsenault9be7b0d2017-02-27 18:49:11 +0000242 bool hasVOP3PInsts() const {
243 return HasVOP3PInsts;
244 }
245
Matt Arsenaultd782d052014-06-27 17:57:00 +0000246 bool hasHWFP64() const {
247 return FP64;
248 }
249
Matt Arsenaultb035a572015-01-29 19:34:25 +0000250 bool hasFastFMAF32() const {
251 return FastFMAF32;
252 }
253
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000254 bool hasHalfRate64Ops() const {
255 return HalfRate64Ops;
256 }
257
Matt Arsenault88701812016-06-09 23:42:48 +0000258 bool hasAddr64() const {
259 return (getGeneration() < VOLCANIC_ISLANDS);
260 }
261
Matt Arsenaultfae02982014-03-17 18:58:11 +0000262 bool hasBFE() const {
263 return (getGeneration() >= EVERGREEN);
264 }
265
Matt Arsenault6e439652014-06-10 19:00:20 +0000266 bool hasBFI() const {
267 return (getGeneration() >= EVERGREEN);
268 }
269
Matt Arsenaultfae02982014-03-17 18:58:11 +0000270 bool hasBFM() const {
271 return hasBFE();
272 }
273
Matt Arsenault60425062014-06-10 19:18:28 +0000274 bool hasBCNT(unsigned Size) const {
275 if (Size == 32)
276 return (getGeneration() >= EVERGREEN);
277
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000278 if (Size == 64)
279 return (getGeneration() >= SOUTHERN_ISLANDS);
280
281 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000282 }
283
Tom Stellard50122a52014-04-07 19:45:41 +0000284 bool hasMulU24() const {
285 return (getGeneration() >= EVERGREEN);
286 }
287
288 bool hasMulI24() const {
289 return (getGeneration() >= SOUTHERN_ISLANDS ||
290 hasCaymanISA());
291 }
292
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000293 bool hasFFBL() const {
294 return (getGeneration() >= EVERGREEN);
295 }
296
297 bool hasFFBH() const {
298 return (getGeneration() >= EVERGREEN);
299 }
300
Matt Arsenault10268f92017-02-27 22:40:39 +0000301 bool hasMed3_16() const {
302 return getGeneration() >= GFX9;
303 }
304
Matt Arsenaultee324ff2017-05-17 19:25:06 +0000305 bool hasMin3Max3_16() const {
306 return getGeneration() >= GFX9;
307 }
308
Jan Vesely808fff52015-04-30 17:15:56 +0000309 bool hasCARRY() const {
310 return (getGeneration() >= EVERGREEN);
311 }
312
313 bool hasBORROW() const {
314 return (getGeneration() >= EVERGREEN);
315 }
316
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000317 bool hasCaymanISA() const {
318 return CaymanISA;
319 }
320
Wei Ding205bfdb2017-02-10 02:15:29 +0000321 TrapHandlerAbi getTrapHandlerAbi() const {
322 return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
323 }
324
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000325 bool isPromoteAllocaEnabled() const {
326 return EnablePromoteAlloca;
327 }
328
Matt Arsenault706f9302015-07-06 16:01:58 +0000329 bool unsafeDSOffsetFoldingEnabled() const {
330 return EnableUnsafeDSOffsetFolding;
331 }
332
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000333 bool dumpCode() const {
334 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000335 }
336
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000337 /// Return the amount of LDS that can be used that will not restrict the
338 /// occupancy lower than WaveCount.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000339 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
340 const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000341
342 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
343 /// the given LDS memory size is the only constraint.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000344 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000345
Valery Pykhtinfd4c4102017-03-21 13:15:46 +0000346 unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const {
347 const auto *MFI = MF.getInfo<SIMachineFunctionInfo>();
348 return getOccupancyWithLocalMemSize(MFI->getLDSSize(), *MF.getFunction());
349 }
350
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000351 bool hasFP16Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000352 return FP64FP16Denormals;
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000353 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000354
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000355 bool hasFP32Denormals() const {
356 return FP32Denormals;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000357 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000358
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000359 bool hasFP64Denormals() const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000360 return FP64FP16Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000361 }
362
Stanislav Mekhanoshindc2890a2017-07-13 23:59:15 +0000363 bool supportsMinMaxDenormModes() const {
364 return getGeneration() >= AMDGPUSubtarget::GFX9;
365 }
366
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000367 bool hasFPExceptions() const {
368 return FPExceptions;
Marek Olsak4d00dd22015-03-09 15:48:09 +0000369 }
370
Matt Arsenault2fdf2a12017-02-21 23:35:48 +0000371 bool enableDX10Clamp() const {
372 return DX10Clamp;
373 }
374
375 bool enableIEEEBit(const MachineFunction &MF) const {
376 return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
377 }
378
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000379 bool useFlatForGlobal() const {
380 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000381 }
382
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000383 bool hasAutoWaitcntBeforeBarrier() const {
384 return AutoWaitcntBeforeBarrier;
385 }
386
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000387 bool hasUnalignedBufferAccess() const {
388 return UnalignedBufferAccess;
389 }
390
Tom Stellard64a9d082016-10-14 18:10:39 +0000391 bool hasUnalignedScratchAccess() const {
392 return UnalignedScratchAccess;
393 }
394
Matt Arsenaulte823d922017-02-18 18:29:53 +0000395 bool hasApertureRegs() const {
396 return HasApertureRegs;
397 }
398
Wei Ding205bfdb2017-02-10 02:15:29 +0000399 bool isTrapHandlerEnabled() const {
400 return TrapHandler;
401 }
402
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000403 bool isXNACKEnabled() const {
404 return EnableXNACK;
405 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000406
Matt Arsenaultb6491cc2017-01-31 01:20:54 +0000407 bool hasFlatAddressSpace() const {
408 return FlatAddressSpace;
409 }
410
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000411 bool hasFlatInstOffsets() const {
412 return FlatInstOffsets;
413 }
414
415 bool hasFlatGlobalInsts() const {
416 return FlatGlobalInsts;
417 }
418
419 bool hasFlatScratchInsts() const {
420 return FlatScratchInsts;
421 }
422
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000423 bool hasAddNoCarry() const {
424 return AddNoCarryInsts;
425 }
426
Tom Stellard2f3f9852017-01-25 01:25:13 +0000427 bool isMesaKernel(const MachineFunction &MF) const {
428 return isMesa3DOS() && !AMDGPU::isShader(MF.getFunction()->getCallingConv());
429 }
430
431 // Covers VS/PS/CS graphics shaders
432 bool isMesaGfxShader(const MachineFunction &MF) const {
433 return isMesa3DOS() && AMDGPU::isShader(MF.getFunction()->getCallingConv());
434 }
435
436 bool isAmdCodeObjectV2(const MachineFunction &MF) const {
437 return isAmdHsaOS() || isMesaKernel(MF);
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000438 }
439
Matt Arsenaultda7a6562017-02-01 00:42:40 +0000440 bool hasFminFmaxLegacy() const {
441 return getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS;
442 }
443
Stanislav Mekhanoshin53a21292017-05-23 19:54:48 +0000444 bool hasSDWA() const {
445 return HasSDWA;
446 }
447
Sam Kolton3c4933f2017-06-22 06:26:41 +0000448 bool hasSDWAOmod() const {
449 return HasSDWAOmod;
450 }
451
452 bool hasSDWAScalar() const {
453 return HasSDWAScalar;
454 }
455
456 bool hasSDWASdst() const {
457 return HasSDWASdst;
458 }
459
460 bool hasSDWAMac() const {
461 return HasSDWAMac;
462 }
463
Sam Koltona179d252017-06-27 15:02:23 +0000464 bool hasSDWAOutModsVOPC() const {
465 return HasSDWAOutModsVOPC;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000466 }
467
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000468 /// \brief Returns the offset in bytes from the start of the input buffer
469 /// of the first explicit kernel argument.
Tom Stellard2f3f9852017-01-25 01:25:13 +0000470 unsigned getExplicitKernelArgOffset(const MachineFunction &MF) const {
471 return isAmdCodeObjectV2(MF) ? 0 : 36;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000472 }
473
Tom Stellardb2869eb2016-09-09 19:28:00 +0000474 unsigned getAlignmentForImplicitArgPtr() const {
475 return isAmdHsaOS() ? 8 : 4;
476 }
477
Tom Stellard2f3f9852017-01-25 01:25:13 +0000478 unsigned getImplicitArgNumBytes(const MachineFunction &MF) const {
479 if (isMesaKernel(MF))
Tom Stellarde88bbc32016-09-23 01:33:26 +0000480 return 16;
481 if (isAmdHsaOS() && isOpenCLEnv())
482 return 32;
483 return 0;
484 }
485
Matt Arsenault869fec22017-04-17 19:48:24 +0000486 // Scratch is allocated in 256 dword per wave blocks for the entire
487 // wavefront. When viewed from the perspecive of an arbitrary workitem, this
488 // is 4-byte aligned.
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000489 unsigned getStackAlignment() const {
Matt Arsenault869fec22017-04-17 19:48:24 +0000490 return 4;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000491 }
Tom Stellard347ac792015-06-26 21:15:07 +0000492
Craig Topper5656db42014-04-29 07:57:24 +0000493 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000494 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000495 }
496
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000497 bool enableSubRegLiveness() const override {
498 return true;
499 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000500
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000501 void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b;}
502 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal;}
503
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000504 /// \returns Number of execution units per compute unit supported by the
505 /// subtarget.
506 unsigned getEUsPerCU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000507 return AMDGPU::IsaInfo::getEUsPerCU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000508 }
509
510 /// \returns Maximum number of work groups per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000511 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000512 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000513 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(getFeatureBits(),
514 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000515 }
516
517 /// \returns Maximum number of waves per compute unit supported by the
518 /// subtarget without any kind of limitation.
519 unsigned getMaxWavesPerCU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000520 return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000521 }
522
523 /// \returns Maximum number of waves per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000524 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000525 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000526 return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits(),
527 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000528 }
529
530 /// \returns Minimum number of waves per execution unit supported by the
531 /// subtarget.
532 unsigned getMinWavesPerEU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000533 return AMDGPU::IsaInfo::getMinWavesPerEU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000534 }
535
536 /// \returns Maximum number of waves per execution unit supported by the
537 /// subtarget without any kind of limitation.
538 unsigned getMaxWavesPerEU() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000539 return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000540 }
541
542 /// \returns Maximum number of waves per execution unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000543 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000544 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000545 return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits(),
546 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000547 }
548
549 /// \returns Minimum flat work group size supported by the subtarget.
550 unsigned getMinFlatWorkGroupSize() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000551 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000552 }
553
554 /// \returns Maximum flat work group size supported by the subtarget.
555 unsigned getMaxFlatWorkGroupSize() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000556 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(getFeatureBits());
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000557 }
558
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000559 /// \returns Number of waves per work group supported by the subtarget and
560 /// limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000561 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000562 return AMDGPU::IsaInfo::getWavesPerWorkGroup(getFeatureBits(),
563 FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000564 }
565
566 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
567 /// for function \p F, or minimum/maximum flat work group sizes explicitly
568 /// requested using "amdgpu-flat-work-group-size" attribute attached to
569 /// function \p F.
570 ///
571 /// \returns Subtarget's default values if explicitly requested values cannot
572 /// be converted to integer, or violate subtarget's specifications.
573 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
574
575 /// \returns Subtarget's default pair of minimum/maximum number of waves per
576 /// execution unit for function \p F, or minimum/maximum number of waves per
577 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
578 /// attached to function \p F.
579 ///
580 /// \returns Subtarget's default values if explicitly requested values cannot
581 /// be converted to integer, violate subtarget's specifications, or are not
582 /// compatible with minimum/maximum number of waves limited by flat work group
583 /// size, register usage, and/or lds usage.
584 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
Stanislav Mekhanoshinc90347d2017-04-12 20:48:56 +0000585
586 /// Creates value range metadata on an workitemid.* inrinsic call or load.
587 bool makeLIDRangeMetadata(Instruction *I) const;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000588};
589
590class R600Subtarget final : public AMDGPUSubtarget {
591private:
592 R600InstrInfo InstrInfo;
593 R600FrameLowering FrameLowering;
594 R600TargetLowering TLInfo;
595
596public:
597 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
598 const TargetMachine &TM);
599
600 const R600InstrInfo *getInstrInfo() const override {
601 return &InstrInfo;
602 }
603
604 const R600FrameLowering *getFrameLowering() const override {
605 return &FrameLowering;
606 }
607
608 const R600TargetLowering *getTargetLowering() const override {
609 return &TLInfo;
610 }
611
612 const R600RegisterInfo *getRegisterInfo() const override {
613 return &InstrInfo.getRegisterInfo();
614 }
615
616 bool hasCFAluBug() const {
617 return CFALUBug;
618 }
619
620 bool hasVertexCache() const {
621 return HasVertexCache;
622 }
623
624 short getTexVTXClauseSize() const {
625 return TexVTXClauseSize;
626 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000627};
628
629class SISubtarget final : public AMDGPUSubtarget {
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000630private:
631 SIInstrInfo InstrInfo;
632 SIFrameLowering FrameLowering;
633 SITargetLowering TLInfo;
634 std::unique_ptr<GISelAccessor> GISel;
635
636public:
637 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
638 const TargetMachine &TM);
639
640 const SIInstrInfo *getInstrInfo() const override {
641 return &InstrInfo;
642 }
643
644 const SIFrameLowering *getFrameLowering() const override {
645 return &FrameLowering;
646 }
647
648 const SITargetLowering *getTargetLowering() const override {
649 return &TLInfo;
650 }
651
652 const CallLowering *getCallLowering() const override {
653 assert(GISel && "Access to GlobalISel APIs not set");
654 return GISel->getCallLowering();
655 }
656
Tom Stellardca166212017-01-30 21:56:46 +0000657 const InstructionSelector *getInstructionSelector() const override {
658 assert(GISel && "Access to GlobalISel APIs not set");
659 return GISel->getInstructionSelector();
660 }
661
662 const LegalizerInfo *getLegalizerInfo() const override {
663 assert(GISel && "Access to GlobalISel APIs not set");
664 return GISel->getLegalizerInfo();
665 }
666
667 const RegisterBankInfo *getRegBankInfo() const override {
668 assert(GISel && "Access to GlobalISel APIs not set");
669 return GISel->getRegBankInfo();
670 }
671
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000672 const SIRegisterInfo *getRegisterInfo() const override {
673 return &InstrInfo.getRegisterInfo();
674 }
675
676 void setGISelAccessor(GISelAccessor &GISel) {
677 this->GISel.reset(&GISel);
678 }
679
Matt Arsenault9f5e0ef2017-01-25 04:25:02 +0000680 // XXX - Why is this here if it isn't in the default pass set?
681 bool enableEarlyIfConversion() const override {
682 return true;
683 }
684
Tom Stellard83f0bce2015-01-29 16:55:25 +0000685 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000686 unsigned NumRegionInstrs) const override;
687
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000688 bool isVGPRSpillingEnabled(const Function& F) const;
689
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000690 unsigned getMaxNumUserSGPRs() const {
691 return 16;
692 }
693
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000694 bool hasSMemRealTime() const {
695 return HasSMemRealTime;
696 }
697
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000698 bool hasMovrel() const {
699 return HasMovrel;
700 }
701
702 bool hasVGPRIndexMode() const {
703 return HasVGPRIndexMode;
704 }
705
Marek Olsake22fdb92017-03-21 17:00:32 +0000706 bool useVGPRIndexMode(bool UserEnable) const {
707 return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
708 }
709
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000710 bool hasScalarCompareEq64() const {
711 return getGeneration() >= VOLCANIC_ISLANDS;
712 }
713
Matt Arsenault7b647552016-10-28 21:55:15 +0000714 bool hasScalarStores() const {
715 return HasScalarStores;
716 }
717
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000718 bool hasInv2PiInlineImm() const {
719 return HasInv2PiInlineImm;
720 }
721
Sam Kolton07dbde22017-01-20 10:01:25 +0000722 bool hasDPP() const {
723 return HasDPP;
724 }
725
Tom Stellardde008d32016-01-21 04:28:34 +0000726 bool enableSIScheduler() const {
727 return EnableSIScheduler;
728 }
729
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000730 bool debuggerSupported() const {
731 return debuggerInsertNops() && debuggerReserveRegs() &&
732 debuggerEmitPrologue();
733 }
734
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000735 bool debuggerInsertNops() const {
736 return DebuggerInsertNops;
737 }
738
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000739 bool debuggerReserveRegs() const {
740 return DebuggerReserveRegs;
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000741 }
742
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000743 bool debuggerEmitPrologue() const {
744 return DebuggerEmitPrologue;
745 }
746
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000747 bool loadStoreOptEnabled() const {
748 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000749 }
750
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000751 bool hasSGPRInitBug() const {
752 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000753 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000754
Tom Stellardb133fbb2016-10-27 23:05:31 +0000755 bool has12DWordStoreHazard() const {
756 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
757 }
758
Matt Arsenaulte823d922017-02-18 18:29:53 +0000759 bool hasSMovFedHazard() const {
760 return getGeneration() >= AMDGPUSubtarget::GFX9;
761 }
762
763 bool hasReadM0Hazard() const {
764 return getGeneration() >= AMDGPUSubtarget::GFX9;
765 }
766
Tom Stellard2f3f9852017-01-25 01:25:13 +0000767 unsigned getKernArgSegmentSize(const MachineFunction &MF, unsigned ExplictArgBytes) const;
Tom Stellarde88bbc32016-09-23 01:33:26 +0000768
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000769 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
770 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
771
772 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
773 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000774
Matt Arsenaulte823d922017-02-18 18:29:53 +0000775 /// \returns true if the flat_scratch register should be initialized with the
776 /// pointer to the wave's scratch memory rather than a size and offset.
777 bool flatScratchIsPointer() const {
778 return getGeneration() >= GFX9;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000779 }
Matt Arsenault4eae3012016-10-28 20:31:47 +0000780
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000781 /// \returns SGPR allocation granularity supported by the subtarget.
782 unsigned getSGPRAllocGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000783 return AMDGPU::IsaInfo::getSGPRAllocGranule(getFeatureBits());
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000784 }
785
786 /// \returns SGPR encoding granularity supported by the subtarget.
787 unsigned getSGPREncodingGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000788 return AMDGPU::IsaInfo::getSGPREncodingGranule(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000789 }
790
791 /// \returns Total number of SGPRs supported by the subtarget.
792 unsigned getTotalNumSGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000793 return AMDGPU::IsaInfo::getTotalNumSGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000794 }
795
796 /// \returns Addressable number of SGPRs supported by the subtarget.
797 unsigned getAddressableNumSGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000798 return AMDGPU::IsaInfo::getAddressableNumSGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000799 }
800
801 /// \returns Minimum number of SGPRs that meets the given number of waves per
802 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000803 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
804 return AMDGPU::IsaInfo::getMinNumSGPRs(getFeatureBits(), WavesPerEU);
805 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000806
807 /// \returns Maximum number of SGPRs that meets the given number of waves per
808 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000809 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
810 return AMDGPU::IsaInfo::getMaxNumSGPRs(getFeatureBits(), WavesPerEU,
811 Addressable);
812 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000813
814 /// \returns Reserved number of SGPRs for given function \p MF.
815 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
816
817 /// \returns Maximum number of SGPRs that meets number of waves per execution
818 /// unit requirement for function \p MF, or number of SGPRs explicitly
819 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
820 ///
821 /// \returns Value that meets number of waves per execution unit requirement
822 /// if explicitly requested value cannot be converted to integer, violates
823 /// subtarget's specifications, or does not meet number of waves per execution
824 /// unit requirement.
825 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
826
827 /// \returns VGPR allocation granularity supported by the subtarget.
828 unsigned getVGPRAllocGranule() const {
Mandeep Singh Grang5e1697e2017-06-06 05:08:36 +0000829 return AMDGPU::IsaInfo::getVGPRAllocGranule(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000830 }
831
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000832 /// \returns VGPR encoding granularity supported by the subtarget.
833 unsigned getVGPREncodingGranule() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000834 return AMDGPU::IsaInfo::getVGPREncodingGranule(getFeatureBits());
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +0000835 }
836
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000837 /// \returns Total number of VGPRs supported by the subtarget.
838 unsigned getTotalNumVGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000839 return AMDGPU::IsaInfo::getTotalNumVGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000840 }
841
842 /// \returns Addressable number of VGPRs supported by the subtarget.
843 unsigned getAddressableNumVGPRs() const {
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000844 return AMDGPU::IsaInfo::getAddressableNumVGPRs(getFeatureBits());
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000845 }
846
847 /// \returns Minimum number of VGPRs that meets given number of waves per
848 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000849 unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
850 return AMDGPU::IsaInfo::getMinNumVGPRs(getFeatureBits(), WavesPerEU);
851 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000852
853 /// \returns Maximum number of VGPRs that meets given number of waves per
854 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000855 unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
856 return AMDGPU::IsaInfo::getMaxNumVGPRs(getFeatureBits(), WavesPerEU);
857 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +0000858
859 /// \returns Reserved number of VGPRs for given function \p MF.
860 unsigned getReservedNumVGPRs(const MachineFunction &MF) const {
861 return debuggerReserveRegs() ? 4 : 0;
862 }
863
864 /// \returns Maximum number of VGPRs that meets number of waves per execution
865 /// unit requirement for function \p MF, or number of VGPRs explicitly
866 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
867 ///
868 /// \returns Value that meets number of waves per execution unit requirement
869 /// if explicitly requested value cannot be converted to integer, violates
870 /// subtarget's specifications, or does not meet number of waves per execution
871 /// unit requirement.
872 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000873};
874
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000875} // end namespace llvm
Tom Stellard75aadc22012-12-11 21:25:42 +0000876
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000877#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H