blob: 3eed8a125eaf7e1c4ba4a88fb6a260ccb37dfdc0 [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 "R600InstrInfo.h"
20#include "R600ISelLowering.h"
21#include "R600FrameLowering.h"
22#include "SIInstrInfo.h"
23#include "SIISelLowering.h"
24#include "SIFrameLowering.h"
Tom Stellard347ac792015-06-26 21:15:07 +000025#include "Utils/AMDGPUBaseInfo.h"
Tom Stellard000c5af2016-04-14 19:09:28 +000026#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
Matt Arsenault56684d42016-08-11 17:31:42 +000027#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000028#include "llvm/Target/TargetSubtargetInfo.h"
29
30#define GET_SUBTARGETINFO_HEADER
31#include "AMDGPUGenSubtargetInfo.inc"
32
Tom Stellard75aadc22012-12-11 21:25:42 +000033namespace llvm {
34
Tom Stellarde99fb652015-01-20 19:33:04 +000035class SIMachineFunctionInfo;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000036class StringRef;
Tom Stellarde99fb652015-01-20 19:33:04 +000037
Tom Stellard75aadc22012-12-11 21:25:42 +000038class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000039public:
40 enum Generation {
41 R600 = 0,
42 R700,
43 EVERGREEN,
44 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000045 SOUTHERN_ISLANDS,
Marek Olsak5df00d62014-12-07 12:18:57 +000046 SEA_ISLANDS,
47 VOLCANIC_ISLANDS,
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000048 };
49
Marek Olsak4d00dd22015-03-09 15:48:09 +000050 enum {
Tom Stellard347ac792015-06-26 21:15:07 +000051 ISAVersion0_0_0,
52 ISAVersion7_0_0,
53 ISAVersion7_0_1,
Yaxun Liu94add852016-10-26 16:37:56 +000054 ISAVersion7_0_2,
Tom Stellard347ac792015-06-26 21:15:07 +000055 ISAVersion8_0_0,
Changpeng Fangc16be002016-01-13 20:39:25 +000056 ISAVersion8_0_1,
Changpeng Fang98317d22016-10-11 16:00:47 +000057 ISAVersion8_0_2,
Yaxun Liu94add852016-10-26 16:37:56 +000058 ISAVersion8_0_3,
59 ISAVersion8_0_4,
60 ISAVersion8_1_0,
Tom Stellard347ac792015-06-26 21:15:07 +000061 };
62
Matt Arsenault43e92fe2016-06-24 06:30:11 +000063protected:
64 // Basic subtarget description.
65 Triple TargetTriple;
Matt Arsenaultd782d052014-06-27 17:57:00 +000066 Generation Gen;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000067 unsigned IsaVersion;
68 unsigned WavefrontSize;
69 int LocalMemorySize;
70 int LDSBankCount;
71 unsigned MaxPrivateElementSize;
72
73 // Possibly statically set by tablegen, but may want to be overridden.
Matt Arsenaultb035a572015-01-29 19:34:25 +000074 bool FastFMAF32;
Matt Arsenaulte83690c2016-01-18 21:13:50 +000075 bool HalfRate64Ops;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000076
77 // Dynamially set bits that enable features.
78 bool FP32Denormals;
79 bool FP64Denormals;
80 bool FPExceptions;
Changpeng Fangb41574a2015-12-22 20:55:23 +000081 bool FlatForGlobal;
Tom Stellard64a9d082016-10-14 18:10:39 +000082 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +000083 bool UnalignedBufferAccess;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000084 bool EnableXNACK;
85 bool DebuggerInsertNops;
86 bool DebuggerReserveRegs;
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +000087 bool DebuggerEmitPrologue;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000088
89 // Used as options.
90 bool EnableVGPRSpilling;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000091 bool EnablePromoteAlloca;
Matt Arsenault41033282014-10-10 22:01:59 +000092 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +000093 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000094 bool EnableSIScheduler;
95 bool DumpCode;
96
97 // Subtarget statically properties set by tablegen
98 bool FP64;
Tom Stellardd7e6f132015-04-08 01:09:26 +000099 bool IsGCN;
100 bool GCN1Encoding;
101 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000102 bool CIInsts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000103 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000104 bool HasSMemRealTime;
105 bool Has16BitInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000106 bool HasMovrel;
107 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000108 bool HasScalarStores;
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000109 bool HasInv2PiInlineImm;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000110 bool FlatAddressSpace;
111 bool R600ALUInst;
112 bool CaymanISA;
113 bool CFALUBug;
114 bool HasVertexCache;
115 short TexVTXClauseSize;
Tom Stellard75aadc22012-12-11 21:25:42 +0000116
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000117 // Dummy feature to use for assembler in tablegen.
118 bool FeatureDisable;
119
Tom Stellard75aadc22012-12-11 21:25:42 +0000120 InstrItineraryData InstrItins;
Matt Arsenault56684d42016-08-11 17:31:42 +0000121 SelectionDAGTargetInfo TSInfo;
Tom Stellard75aadc22012-12-11 21:25:42 +0000122
123public:
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000124 AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
125 const TargetMachine &TM);
126 virtual ~AMDGPUSubtarget();
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000127 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
128 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000129
Matt Arsenaultf9245b72016-07-22 17:01:25 +0000130 const AMDGPUInstrInfo *getInstrInfo() const override = 0;
131 const AMDGPUFrameLowering *getFrameLowering() const override = 0;
132 const AMDGPUTargetLowering *getTargetLowering() const override = 0;
133 const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
Tom Stellard000c5af2016-04-14 19:09:28 +0000134
Eric Christopherd9134482014-08-04 21:25:23 +0000135 const InstrItineraryData *getInstrItineraryData() const override {
136 return &InstrItins;
137 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000138
Matt Arsenault56684d42016-08-11 17:31:42 +0000139 // Nothing implemented, just prevent crashes on use.
140 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
141 return &TSInfo;
142 }
143
Craig Topperee7b0f32014-04-30 05:53:27 +0000144 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000145
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000146 bool isAmdHsaOS() const {
147 return TargetTriple.getOS() == Triple::AMDHSA;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000148 }
149
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000150 bool isMesa3DOS() const {
151 return TargetTriple.getOS() == Triple::Mesa3D;
152 }
153
Tom Stellarde88bbc32016-09-23 01:33:26 +0000154 bool isOpenCLEnv() const {
155 return TargetTriple.getEnvironment() == Triple::OpenCL;
156 }
157
Matt Arsenaultd782d052014-06-27 17:57:00 +0000158 Generation getGeneration() const {
159 return Gen;
160 }
161
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000162 unsigned getWavefrontSize() const {
163 return WavefrontSize;
164 }
165
166 int getLocalMemorySize() const {
167 return LocalMemorySize;
168 }
169
170 int getLDSBankCount() const {
171 return LDSBankCount;
172 }
173
174 unsigned getMaxPrivateElementSize() const {
175 return MaxPrivateElementSize;
176 }
177
Konstantin Zhuravlyovd971a112016-11-01 17:49:33 +0000178 bool has16BitInsts() const {
179 return Has16BitInsts;
180 }
181
Matt Arsenaultd782d052014-06-27 17:57:00 +0000182 bool hasHWFP64() const {
183 return FP64;
184 }
185
Matt Arsenaultb035a572015-01-29 19:34:25 +0000186 bool hasFastFMAF32() const {
187 return FastFMAF32;
188 }
189
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000190 bool hasHalfRate64Ops() const {
191 return HalfRate64Ops;
192 }
193
Matt Arsenault88701812016-06-09 23:42:48 +0000194 bool hasAddr64() const {
195 return (getGeneration() < VOLCANIC_ISLANDS);
196 }
197
Matt Arsenaultfae02982014-03-17 18:58:11 +0000198 bool hasBFE() const {
199 return (getGeneration() >= EVERGREEN);
200 }
201
Matt Arsenault6e439652014-06-10 19:00:20 +0000202 bool hasBFI() const {
203 return (getGeneration() >= EVERGREEN);
204 }
205
Matt Arsenaultfae02982014-03-17 18:58:11 +0000206 bool hasBFM() const {
207 return hasBFE();
208 }
209
Matt Arsenault60425062014-06-10 19:18:28 +0000210 bool hasBCNT(unsigned Size) const {
211 if (Size == 32)
212 return (getGeneration() >= EVERGREEN);
213
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000214 if (Size == 64)
215 return (getGeneration() >= SOUTHERN_ISLANDS);
216
217 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000218 }
219
Tom Stellard50122a52014-04-07 19:45:41 +0000220 bool hasMulU24() const {
221 return (getGeneration() >= EVERGREEN);
222 }
223
224 bool hasMulI24() const {
225 return (getGeneration() >= SOUTHERN_ISLANDS ||
226 hasCaymanISA());
227 }
228
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000229 bool hasFFBL() const {
230 return (getGeneration() >= EVERGREEN);
231 }
232
233 bool hasFFBH() const {
234 return (getGeneration() >= EVERGREEN);
235 }
236
Jan Vesely808fff52015-04-30 17:15:56 +0000237 bool hasCARRY() const {
238 return (getGeneration() >= EVERGREEN);
239 }
240
241 bool hasBORROW() const {
242 return (getGeneration() >= EVERGREEN);
243 }
244
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000245 bool hasCaymanISA() const {
246 return CaymanISA;
247 }
248
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000249 bool isPromoteAllocaEnabled() const {
250 return EnablePromoteAlloca;
251 }
252
Matt Arsenault706f9302015-07-06 16:01:58 +0000253 bool unsafeDSOffsetFoldingEnabled() const {
254 return EnableUnsafeDSOffsetFolding;
255 }
256
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000257 bool dumpCode() const {
258 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000259 }
260
Wei Ding3cb2a1e2016-10-19 22:34:49 +0000261 bool enableIEEEBit(const MachineFunction &MF) const {
262 return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
263 }
264
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000265 /// Return the amount of LDS that can be used that will not restrict the
266 /// occupancy lower than WaveCount.
267 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount) const;
268
269 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
270 /// the given LDS memory size is the only constraint.
271 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes) const;
272
273
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000274 bool hasFP32Denormals() const {
275 return FP32Denormals;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000276 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000277
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000278 bool hasFP64Denormals() const {
279 return FP64Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000280 }
281
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000282 bool hasFPExceptions() const {
283 return FPExceptions;
Marek Olsak4d00dd22015-03-09 15:48:09 +0000284 }
285
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000286 bool useFlatForGlobal() const {
287 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000288 }
289
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000290 bool hasUnalignedBufferAccess() const {
291 return UnalignedBufferAccess;
292 }
293
Tom Stellard64a9d082016-10-14 18:10:39 +0000294 bool hasUnalignedScratchAccess() const {
295 return UnalignedScratchAccess;
296 }
297
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000298 bool isXNACKEnabled() const {
299 return EnableXNACK;
300 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000301
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000302 bool isAmdCodeObjectV2() const {
303 return isAmdHsaOS() || isMesa3DOS();
304 }
305
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000306 /// \brief Returns the offset in bytes from the start of the input buffer
307 /// of the first explicit kernel argument.
308 unsigned getExplicitKernelArgOffset() const {
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000309 return isAmdCodeObjectV2() ? 0 : 36;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000310 }
311
Tom Stellardb2869eb2016-09-09 19:28:00 +0000312 unsigned getAlignmentForImplicitArgPtr() const {
313 return isAmdHsaOS() ? 8 : 4;
314 }
315
Tom Stellarde88bbc32016-09-23 01:33:26 +0000316 unsigned getImplicitArgNumBytes() const {
317 if (isMesa3DOS())
318 return 16;
319 if (isAmdHsaOS() && isOpenCLEnv())
320 return 32;
321 return 0;
322 }
323
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000324 unsigned getStackAlignment() const {
325 // Scratch is allocated in 256 dword per wave blocks.
326 return 4 * 256 / getWavefrontSize();
327 }
Tom Stellard347ac792015-06-26 21:15:07 +0000328
Craig Topper5656db42014-04-29 07:57:24 +0000329 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000330 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000331 }
332
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000333 bool enableSubRegLiveness() const override {
334 return true;
335 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000336
337 /// \returns Number of execution units per compute unit supported by the
338 /// subtarget.
339 unsigned getEUsPerCU() const {
340 return 4;
341 }
342
343 /// \returns Maximum number of work groups per compute unit supported by the
344 /// subtarget and limited by given flat work group size.
345 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
346 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
347 return 8;
348 return getWavesPerWorkGroup(FlatWorkGroupSize) == 1 ? 40 : 16;
349 }
350
351 /// \returns Maximum number of waves per compute unit supported by the
352 /// subtarget without any kind of limitation.
353 unsigned getMaxWavesPerCU() const {
354 return getMaxWavesPerEU() * getEUsPerCU();
355 }
356
357 /// \returns Maximum number of waves per compute unit supported by the
358 /// subtarget and limited by given flat work group size.
359 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
360 return getWavesPerWorkGroup(FlatWorkGroupSize);
361 }
362
363 /// \returns Minimum number of waves per execution unit supported by the
364 /// subtarget.
365 unsigned getMinWavesPerEU() const {
366 return 1;
367 }
368
369 /// \returns Maximum number of waves per execution unit supported by the
370 /// subtarget without any kind of limitation.
371 unsigned getMaxWavesPerEU() const {
372 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
373 return 8;
374 // FIXME: Need to take scratch memory into account.
375 return 10;
376 }
377
378 /// \returns Maximum number of waves per execution unit supported by the
379 /// subtarget and limited by given flat work group size.
380 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
381 return alignTo(getMaxWavesPerCU(FlatWorkGroupSize), getEUsPerCU()) /
382 getEUsPerCU();
383 }
384
385 /// \returns Minimum flat work group size supported by the subtarget.
386 unsigned getMinFlatWorkGroupSize() const {
387 return 1;
388 }
389
390 /// \returns Maximum flat work group size supported by the subtarget.
391 unsigned getMaxFlatWorkGroupSize() const {
392 return 2048;
393 }
394
395 /// \returns Number of waves per work group given the flat work group size.
396 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
397 return alignTo(FlatWorkGroupSize, getWavefrontSize()) / getWavefrontSize();
398 }
399
400 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
401 /// for function \p F, or minimum/maximum flat work group sizes explicitly
402 /// requested using "amdgpu-flat-work-group-size" attribute attached to
403 /// function \p F.
404 ///
405 /// \returns Subtarget's default values if explicitly requested values cannot
406 /// be converted to integer, or violate subtarget's specifications.
407 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
408
409 /// \returns Subtarget's default pair of minimum/maximum number of waves per
410 /// execution unit for function \p F, or minimum/maximum number of waves per
411 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
412 /// attached to function \p F.
413 ///
414 /// \returns Subtarget's default values if explicitly requested values cannot
415 /// be converted to integer, violate subtarget's specifications, or are not
416 /// compatible with minimum/maximum number of waves limited by flat work group
417 /// size, register usage, and/or lds usage.
418 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000419};
420
421class R600Subtarget final : public AMDGPUSubtarget {
422private:
423 R600InstrInfo InstrInfo;
424 R600FrameLowering FrameLowering;
425 R600TargetLowering TLInfo;
426
427public:
428 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
429 const TargetMachine &TM);
430
431 const R600InstrInfo *getInstrInfo() const override {
432 return &InstrInfo;
433 }
434
435 const R600FrameLowering *getFrameLowering() const override {
436 return &FrameLowering;
437 }
438
439 const R600TargetLowering *getTargetLowering() const override {
440 return &TLInfo;
441 }
442
443 const R600RegisterInfo *getRegisterInfo() const override {
444 return &InstrInfo.getRegisterInfo();
445 }
446
447 bool hasCFAluBug() const {
448 return CFALUBug;
449 }
450
451 bool hasVertexCache() const {
452 return HasVertexCache;
453 }
454
455 short getTexVTXClauseSize() const {
456 return TexVTXClauseSize;
457 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000458};
459
460class SISubtarget final : public AMDGPUSubtarget {
461public:
462 enum {
Marek Olsak355a8642016-08-05 21:23:29 +0000463 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
464 // doesn't spill SGPRs as much as when 80 is set.
465 FIXED_SGPR_COUNT_FOR_INIT_BUG = 96
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000466 };
467
468private:
469 SIInstrInfo InstrInfo;
470 SIFrameLowering FrameLowering;
471 SITargetLowering TLInfo;
472 std::unique_ptr<GISelAccessor> GISel;
473
474public:
475 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
476 const TargetMachine &TM);
477
478 const SIInstrInfo *getInstrInfo() const override {
479 return &InstrInfo;
480 }
481
482 const SIFrameLowering *getFrameLowering() const override {
483 return &FrameLowering;
484 }
485
486 const SITargetLowering *getTargetLowering() const override {
487 return &TLInfo;
488 }
489
490 const CallLowering *getCallLowering() const override {
491 assert(GISel && "Access to GlobalISel APIs not set");
492 return GISel->getCallLowering();
493 }
494
495 const SIRegisterInfo *getRegisterInfo() const override {
496 return &InstrInfo.getRegisterInfo();
497 }
498
499 void setGISelAccessor(GISelAccessor &GISel) {
500 this->GISel.reset(&GISel);
501 }
502
Tom Stellard83f0bce2015-01-29 16:55:25 +0000503 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000504 unsigned NumRegionInstrs) const override;
505
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000506 bool isVGPRSpillingEnabled(const Function& F) const;
507
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000508 unsigned getMaxNumUserSGPRs() const {
509 return 16;
510 }
511
512 bool hasFlatAddressSpace() const {
513 return FlatAddressSpace;
514 }
515
516 bool hasSMemRealTime() const {
517 return HasSMemRealTime;
518 }
519
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000520 bool hasMovrel() const {
521 return HasMovrel;
522 }
523
524 bool hasVGPRIndexMode() const {
525 return HasVGPRIndexMode;
526 }
527
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000528 bool hasScalarCompareEq64() const {
529 return getGeneration() >= VOLCANIC_ISLANDS;
530 }
531
Matt Arsenault7b647552016-10-28 21:55:15 +0000532 bool hasScalarStores() const {
533 return HasScalarStores;
534 }
535
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000536 bool hasInv2PiInlineImm() const {
537 return HasInv2PiInlineImm;
538 }
539
Tom Stellardde008d32016-01-21 04:28:34 +0000540 bool enableSIScheduler() const {
541 return EnableSIScheduler;
542 }
543
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000544 bool debuggerSupported() const {
545 return debuggerInsertNops() && debuggerReserveRegs() &&
546 debuggerEmitPrologue();
547 }
548
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000549 bool debuggerInsertNops() const {
550 return DebuggerInsertNops;
551 }
552
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000553 bool debuggerReserveRegs() const {
554 return DebuggerReserveRegs;
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000555 }
556
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000557 bool debuggerEmitPrologue() const {
558 return DebuggerEmitPrologue;
559 }
560
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000561 bool loadStoreOptEnabled() const {
562 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000563 }
564
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000565 bool hasSGPRInitBug() const {
566 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000567 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000568
Tom Stellardb133fbb2016-10-27 23:05:31 +0000569 bool has12DWordStoreHazard() const {
570 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
571 }
572
Tom Stellarde88bbc32016-09-23 01:33:26 +0000573 unsigned getKernArgSegmentSize(unsigned ExplictArgBytes) const;
574
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000575 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
576 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
577
578 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
579 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000580
581 /// \returns True if waitcnt instruction is needed before barrier instruction,
582 /// false otherwise.
583 bool needWaitcntBeforeBarrier() const {
584 return true;
585 }
Matt Arsenault4eae3012016-10-28 20:31:47 +0000586
587 unsigned getMaxNumSGPRs() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000588};
589
590} // End namespace llvm
591
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000592#endif