blob: 842711b0dd3ddc0804a01cc02ab3f58e04ad61cf [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.
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000078 bool FP16Denormals;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000079 bool FP32Denormals;
80 bool FP64Denormals;
81 bool FPExceptions;
Changpeng Fangb41574a2015-12-22 20:55:23 +000082 bool FlatForGlobal;
Tom Stellard64a9d082016-10-14 18:10:39 +000083 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +000084 bool UnalignedBufferAccess;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000085 bool EnableXNACK;
86 bool DebuggerInsertNops;
87 bool DebuggerReserveRegs;
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +000088 bool DebuggerEmitPrologue;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000089
90 // Used as options.
91 bool EnableVGPRSpilling;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000092 bool EnablePromoteAlloca;
Matt Arsenault41033282014-10-10 22:01:59 +000093 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +000094 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +000095 bool EnableSIScheduler;
96 bool DumpCode;
97
98 // Subtarget statically properties set by tablegen
99 bool FP64;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000100 bool IsGCN;
101 bool GCN1Encoding;
102 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000103 bool CIInsts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000104 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000105 bool HasSMemRealTime;
106 bool Has16BitInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000107 bool HasMovrel;
108 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000109 bool HasScalarStores;
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000110 bool HasInv2PiInlineImm;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000111 bool FlatAddressSpace;
112 bool R600ALUInst;
113 bool CaymanISA;
114 bool CFALUBug;
115 bool HasVertexCache;
116 short TexVTXClauseSize;
Tom Stellard75aadc22012-12-11 21:25:42 +0000117
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000118 // Dummy feature to use for assembler in tablegen.
119 bool FeatureDisable;
120
Tom Stellard75aadc22012-12-11 21:25:42 +0000121 InstrItineraryData InstrItins;
Matt Arsenault56684d42016-08-11 17:31:42 +0000122 SelectionDAGTargetInfo TSInfo;
Tom Stellard75aadc22012-12-11 21:25:42 +0000123
124public:
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000125 AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
126 const TargetMachine &TM);
127 virtual ~AMDGPUSubtarget();
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000128 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
129 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000130
Matt Arsenaultf9245b72016-07-22 17:01:25 +0000131 const AMDGPUInstrInfo *getInstrInfo() const override = 0;
132 const AMDGPUFrameLowering *getFrameLowering() const override = 0;
133 const AMDGPUTargetLowering *getTargetLowering() const override = 0;
134 const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
Tom Stellard000c5af2016-04-14 19:09:28 +0000135
Eric Christopherd9134482014-08-04 21:25:23 +0000136 const InstrItineraryData *getInstrItineraryData() const override {
137 return &InstrItins;
138 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000139
Matt Arsenault56684d42016-08-11 17:31:42 +0000140 // Nothing implemented, just prevent crashes on use.
141 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
142 return &TSInfo;
143 }
144
Craig Topperee7b0f32014-04-30 05:53:27 +0000145 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000146
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000147 bool isAmdHsaOS() const {
148 return TargetTriple.getOS() == Triple::AMDHSA;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000149 }
150
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000151 bool isMesa3DOS() const {
152 return TargetTriple.getOS() == Triple::Mesa3D;
153 }
154
Tom Stellarde88bbc32016-09-23 01:33:26 +0000155 bool isOpenCLEnv() const {
156 return TargetTriple.getEnvironment() == Triple::OpenCL;
157 }
158
Matt Arsenaultd782d052014-06-27 17:57:00 +0000159 Generation getGeneration() const {
160 return Gen;
161 }
162
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000163 unsigned getWavefrontSize() const {
164 return WavefrontSize;
165 }
166
167 int getLocalMemorySize() const {
168 return LocalMemorySize;
169 }
170
171 int getLDSBankCount() const {
172 return LDSBankCount;
173 }
174
175 unsigned getMaxPrivateElementSize() const {
176 return MaxPrivateElementSize;
177 }
178
Konstantin Zhuravlyovd971a112016-11-01 17:49:33 +0000179 bool has16BitInsts() const {
180 return Has16BitInsts;
181 }
182
Matt Arsenaultd782d052014-06-27 17:57:00 +0000183 bool hasHWFP64() const {
184 return FP64;
185 }
186
Matt Arsenaultb035a572015-01-29 19:34:25 +0000187 bool hasFastFMAF32() const {
188 return FastFMAF32;
189 }
190
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000191 bool hasHalfRate64Ops() const {
192 return HalfRate64Ops;
193 }
194
Matt Arsenault88701812016-06-09 23:42:48 +0000195 bool hasAddr64() const {
196 return (getGeneration() < VOLCANIC_ISLANDS);
197 }
198
Matt Arsenaultfae02982014-03-17 18:58:11 +0000199 bool hasBFE() const {
200 return (getGeneration() >= EVERGREEN);
201 }
202
Matt Arsenault6e439652014-06-10 19:00:20 +0000203 bool hasBFI() const {
204 return (getGeneration() >= EVERGREEN);
205 }
206
Matt Arsenaultfae02982014-03-17 18:58:11 +0000207 bool hasBFM() const {
208 return hasBFE();
209 }
210
Matt Arsenault60425062014-06-10 19:18:28 +0000211 bool hasBCNT(unsigned Size) const {
212 if (Size == 32)
213 return (getGeneration() >= EVERGREEN);
214
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000215 if (Size == 64)
216 return (getGeneration() >= SOUTHERN_ISLANDS);
217
218 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000219 }
220
Tom Stellard50122a52014-04-07 19:45:41 +0000221 bool hasMulU24() const {
222 return (getGeneration() >= EVERGREEN);
223 }
224
225 bool hasMulI24() const {
226 return (getGeneration() >= SOUTHERN_ISLANDS ||
227 hasCaymanISA());
228 }
229
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000230 bool hasFFBL() const {
231 return (getGeneration() >= EVERGREEN);
232 }
233
234 bool hasFFBH() const {
235 return (getGeneration() >= EVERGREEN);
236 }
237
Jan Vesely808fff52015-04-30 17:15:56 +0000238 bool hasCARRY() const {
239 return (getGeneration() >= EVERGREEN);
240 }
241
242 bool hasBORROW() const {
243 return (getGeneration() >= EVERGREEN);
244 }
245
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000246 bool hasCaymanISA() const {
247 return CaymanISA;
248 }
249
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000250 bool isPromoteAllocaEnabled() const {
251 return EnablePromoteAlloca;
252 }
253
Matt Arsenault706f9302015-07-06 16:01:58 +0000254 bool unsafeDSOffsetFoldingEnabled() const {
255 return EnableUnsafeDSOffsetFolding;
256 }
257
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000258 bool dumpCode() const {
259 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000260 }
261
Wei Ding3cb2a1e2016-10-19 22:34:49 +0000262 bool enableIEEEBit(const MachineFunction &MF) const {
263 return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
264 }
265
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000266 /// Return the amount of LDS that can be used that will not restrict the
267 /// occupancy lower than WaveCount.
268 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount) const;
269
270 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
271 /// the given LDS memory size is the only constraint.
272 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes) const;
273
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000274 bool hasFP16Denormals() const {
275 return FP16Denormals;
276 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000277
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000278 bool hasFP32Denormals() const {
279 return FP32Denormals;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000280 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000281
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000282 bool hasFP64Denormals() const {
283 return FP64Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000284 }
285
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000286 bool hasFPExceptions() const {
287 return FPExceptions;
Marek Olsak4d00dd22015-03-09 15:48:09 +0000288 }
289
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000290 bool useFlatForGlobal() const {
291 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000292 }
293
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000294 bool hasUnalignedBufferAccess() const {
295 return UnalignedBufferAccess;
296 }
297
Tom Stellard64a9d082016-10-14 18:10:39 +0000298 bool hasUnalignedScratchAccess() const {
299 return UnalignedScratchAccess;
300 }
301
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000302 bool isXNACKEnabled() const {
303 return EnableXNACK;
304 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000305
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000306 bool isAmdCodeObjectV2() const {
307 return isAmdHsaOS() || isMesa3DOS();
308 }
309
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000310 /// \brief Returns the offset in bytes from the start of the input buffer
311 /// of the first explicit kernel argument.
312 unsigned getExplicitKernelArgOffset() const {
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000313 return isAmdCodeObjectV2() ? 0 : 36;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000314 }
315
Tom Stellardb2869eb2016-09-09 19:28:00 +0000316 unsigned getAlignmentForImplicitArgPtr() const {
317 return isAmdHsaOS() ? 8 : 4;
318 }
319
Tom Stellarde88bbc32016-09-23 01:33:26 +0000320 unsigned getImplicitArgNumBytes() const {
321 if (isMesa3DOS())
322 return 16;
323 if (isAmdHsaOS() && isOpenCLEnv())
324 return 32;
325 return 0;
326 }
327
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000328 unsigned getStackAlignment() const {
329 // Scratch is allocated in 256 dword per wave blocks.
330 return 4 * 256 / getWavefrontSize();
331 }
Tom Stellard347ac792015-06-26 21:15:07 +0000332
Craig Topper5656db42014-04-29 07:57:24 +0000333 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000334 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000335 }
336
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000337 bool enableSubRegLiveness() const override {
338 return true;
339 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000340
341 /// \returns Number of execution units per compute unit supported by the
342 /// subtarget.
343 unsigned getEUsPerCU() const {
344 return 4;
345 }
346
347 /// \returns Maximum number of work groups per compute unit supported by the
348 /// subtarget and limited by given flat work group size.
349 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
350 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
351 return 8;
352 return getWavesPerWorkGroup(FlatWorkGroupSize) == 1 ? 40 : 16;
353 }
354
355 /// \returns Maximum number of waves per compute unit supported by the
356 /// subtarget without any kind of limitation.
357 unsigned getMaxWavesPerCU() const {
358 return getMaxWavesPerEU() * getEUsPerCU();
359 }
360
361 /// \returns Maximum number of waves per compute unit supported by the
362 /// subtarget and limited by given flat work group size.
363 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
364 return getWavesPerWorkGroup(FlatWorkGroupSize);
365 }
366
367 /// \returns Minimum number of waves per execution unit supported by the
368 /// subtarget.
369 unsigned getMinWavesPerEU() const {
370 return 1;
371 }
372
373 /// \returns Maximum number of waves per execution unit supported by the
374 /// subtarget without any kind of limitation.
375 unsigned getMaxWavesPerEU() const {
376 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
377 return 8;
378 // FIXME: Need to take scratch memory into account.
379 return 10;
380 }
381
382 /// \returns Maximum number of waves per execution unit supported by the
383 /// subtarget and limited by given flat work group size.
384 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
385 return alignTo(getMaxWavesPerCU(FlatWorkGroupSize), getEUsPerCU()) /
386 getEUsPerCU();
387 }
388
389 /// \returns Minimum flat work group size supported by the subtarget.
390 unsigned getMinFlatWorkGroupSize() const {
391 return 1;
392 }
393
394 /// \returns Maximum flat work group size supported by the subtarget.
395 unsigned getMaxFlatWorkGroupSize() const {
396 return 2048;
397 }
398
399 /// \returns Number of waves per work group given the flat work group size.
400 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
401 return alignTo(FlatWorkGroupSize, getWavefrontSize()) / getWavefrontSize();
402 }
403
404 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
405 /// for function \p F, or minimum/maximum flat work group sizes explicitly
406 /// requested using "amdgpu-flat-work-group-size" attribute attached to
407 /// function \p F.
408 ///
409 /// \returns Subtarget's default values if explicitly requested values cannot
410 /// be converted to integer, or violate subtarget's specifications.
411 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
412
413 /// \returns Subtarget's default pair of minimum/maximum number of waves per
414 /// execution unit for function \p F, or minimum/maximum number of waves per
415 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
416 /// attached to function \p F.
417 ///
418 /// \returns Subtarget's default values if explicitly requested values cannot
419 /// be converted to integer, violate subtarget's specifications, or are not
420 /// compatible with minimum/maximum number of waves limited by flat work group
421 /// size, register usage, and/or lds usage.
422 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000423};
424
425class R600Subtarget final : public AMDGPUSubtarget {
426private:
427 R600InstrInfo InstrInfo;
428 R600FrameLowering FrameLowering;
429 R600TargetLowering TLInfo;
430
431public:
432 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
433 const TargetMachine &TM);
434
435 const R600InstrInfo *getInstrInfo() const override {
436 return &InstrInfo;
437 }
438
439 const R600FrameLowering *getFrameLowering() const override {
440 return &FrameLowering;
441 }
442
443 const R600TargetLowering *getTargetLowering() const override {
444 return &TLInfo;
445 }
446
447 const R600RegisterInfo *getRegisterInfo() const override {
448 return &InstrInfo.getRegisterInfo();
449 }
450
451 bool hasCFAluBug() const {
452 return CFALUBug;
453 }
454
455 bool hasVertexCache() const {
456 return HasVertexCache;
457 }
458
459 short getTexVTXClauseSize() const {
460 return TexVTXClauseSize;
461 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000462};
463
464class SISubtarget final : public AMDGPUSubtarget {
465public:
466 enum {
Marek Olsak355a8642016-08-05 21:23:29 +0000467 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
468 // doesn't spill SGPRs as much as when 80 is set.
469 FIXED_SGPR_COUNT_FOR_INIT_BUG = 96
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000470 };
471
472private:
473 SIInstrInfo InstrInfo;
474 SIFrameLowering FrameLowering;
475 SITargetLowering TLInfo;
476 std::unique_ptr<GISelAccessor> GISel;
477
478public:
479 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
480 const TargetMachine &TM);
481
482 const SIInstrInfo *getInstrInfo() const override {
483 return &InstrInfo;
484 }
485
486 const SIFrameLowering *getFrameLowering() const override {
487 return &FrameLowering;
488 }
489
490 const SITargetLowering *getTargetLowering() const override {
491 return &TLInfo;
492 }
493
494 const CallLowering *getCallLowering() const override {
495 assert(GISel && "Access to GlobalISel APIs not set");
496 return GISel->getCallLowering();
497 }
498
499 const SIRegisterInfo *getRegisterInfo() const override {
500 return &InstrInfo.getRegisterInfo();
501 }
502
503 void setGISelAccessor(GISelAccessor &GISel) {
504 this->GISel.reset(&GISel);
505 }
506
Tom Stellard83f0bce2015-01-29 16:55:25 +0000507 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000508 unsigned NumRegionInstrs) const override;
509
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000510 bool isVGPRSpillingEnabled(const Function& F) const;
511
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000512 unsigned getMaxNumUserSGPRs() const {
513 return 16;
514 }
515
516 bool hasFlatAddressSpace() const {
517 return FlatAddressSpace;
518 }
519
520 bool hasSMemRealTime() const {
521 return HasSMemRealTime;
522 }
523
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000524 bool hasMovrel() const {
525 return HasMovrel;
526 }
527
528 bool hasVGPRIndexMode() const {
529 return HasVGPRIndexMode;
530 }
531
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000532 bool hasScalarCompareEq64() const {
533 return getGeneration() >= VOLCANIC_ISLANDS;
534 }
535
Matt Arsenault7b647552016-10-28 21:55:15 +0000536 bool hasScalarStores() const {
537 return HasScalarStores;
538 }
539
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000540 bool hasInv2PiInlineImm() const {
541 return HasInv2PiInlineImm;
542 }
543
Tom Stellardde008d32016-01-21 04:28:34 +0000544 bool enableSIScheduler() const {
545 return EnableSIScheduler;
546 }
547
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000548 bool debuggerSupported() const {
549 return debuggerInsertNops() && debuggerReserveRegs() &&
550 debuggerEmitPrologue();
551 }
552
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000553 bool debuggerInsertNops() const {
554 return DebuggerInsertNops;
555 }
556
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000557 bool debuggerReserveRegs() const {
558 return DebuggerReserveRegs;
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000559 }
560
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000561 bool debuggerEmitPrologue() const {
562 return DebuggerEmitPrologue;
563 }
564
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000565 bool loadStoreOptEnabled() const {
566 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000567 }
568
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000569 bool hasSGPRInitBug() const {
570 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000571 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000572
Tom Stellardb133fbb2016-10-27 23:05:31 +0000573 bool has12DWordStoreHazard() const {
574 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
575 }
576
Tom Stellarde88bbc32016-09-23 01:33:26 +0000577 unsigned getKernArgSegmentSize(unsigned ExplictArgBytes) const;
578
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000579 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
580 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
581
582 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
583 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000584
585 /// \returns True if waitcnt instruction is needed before barrier instruction,
586 /// false otherwise.
587 bool needWaitcntBeforeBarrier() const {
588 return true;
589 }
Matt Arsenault4eae3012016-10-28 20:31:47 +0000590
591 unsigned getMaxNumSGPRs() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000592};
593
594} // End namespace llvm
595
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000596#endif