blob: 939d13763dffbdf4cef68fb9359e4eb9d86ccec7 [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;
Alexander Timofeev18009562016-12-08 17:28:47 +0000117 bool ScalarizeGlobal;
Tom Stellard75aadc22012-12-11 21:25:42 +0000118
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000119 // Dummy feature to use for assembler in tablegen.
120 bool FeatureDisable;
121
Tom Stellard75aadc22012-12-11 21:25:42 +0000122 InstrItineraryData InstrItins;
Matt Arsenault56684d42016-08-11 17:31:42 +0000123 SelectionDAGTargetInfo TSInfo;
Tom Stellard75aadc22012-12-11 21:25:42 +0000124
125public:
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000126 AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
127 const TargetMachine &TM);
128 virtual ~AMDGPUSubtarget();
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000129 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
130 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000131
Matt Arsenaultf9245b72016-07-22 17:01:25 +0000132 const AMDGPUInstrInfo *getInstrInfo() const override = 0;
133 const AMDGPUFrameLowering *getFrameLowering() const override = 0;
134 const AMDGPUTargetLowering *getTargetLowering() const override = 0;
135 const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
Tom Stellard000c5af2016-04-14 19:09:28 +0000136
Eric Christopherd9134482014-08-04 21:25:23 +0000137 const InstrItineraryData *getInstrItineraryData() const override {
138 return &InstrItins;
139 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000140
Matt Arsenault56684d42016-08-11 17:31:42 +0000141 // Nothing implemented, just prevent crashes on use.
142 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
143 return &TSInfo;
144 }
145
Craig Topperee7b0f32014-04-30 05:53:27 +0000146 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000147
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000148 bool isAmdHsaOS() const {
149 return TargetTriple.getOS() == Triple::AMDHSA;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000150 }
151
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000152 bool isMesa3DOS() const {
153 return TargetTriple.getOS() == Triple::Mesa3D;
154 }
155
Tom Stellarde88bbc32016-09-23 01:33:26 +0000156 bool isOpenCLEnv() const {
157 return TargetTriple.getEnvironment() == Triple::OpenCL;
158 }
159
Matt Arsenaultd782d052014-06-27 17:57:00 +0000160 Generation getGeneration() const {
161 return Gen;
162 }
163
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000164 unsigned getWavefrontSize() const {
165 return WavefrontSize;
166 }
167
168 int getLocalMemorySize() const {
169 return LocalMemorySize;
170 }
171
172 int getLDSBankCount() const {
173 return LDSBankCount;
174 }
175
176 unsigned getMaxPrivateElementSize() const {
177 return MaxPrivateElementSize;
178 }
179
Konstantin Zhuravlyovd971a112016-11-01 17:49:33 +0000180 bool has16BitInsts() const {
181 return Has16BitInsts;
182 }
183
Matt Arsenaultd782d052014-06-27 17:57:00 +0000184 bool hasHWFP64() const {
185 return FP64;
186 }
187
Matt Arsenaultb035a572015-01-29 19:34:25 +0000188 bool hasFastFMAF32() const {
189 return FastFMAF32;
190 }
191
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000192 bool hasHalfRate64Ops() const {
193 return HalfRate64Ops;
194 }
195
Matt Arsenault88701812016-06-09 23:42:48 +0000196 bool hasAddr64() const {
197 return (getGeneration() < VOLCANIC_ISLANDS);
198 }
199
Matt Arsenaultfae02982014-03-17 18:58:11 +0000200 bool hasBFE() const {
201 return (getGeneration() >= EVERGREEN);
202 }
203
Matt Arsenault6e439652014-06-10 19:00:20 +0000204 bool hasBFI() const {
205 return (getGeneration() >= EVERGREEN);
206 }
207
Matt Arsenaultfae02982014-03-17 18:58:11 +0000208 bool hasBFM() const {
209 return hasBFE();
210 }
211
Matt Arsenault60425062014-06-10 19:18:28 +0000212 bool hasBCNT(unsigned Size) const {
213 if (Size == 32)
214 return (getGeneration() >= EVERGREEN);
215
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000216 if (Size == 64)
217 return (getGeneration() >= SOUTHERN_ISLANDS);
218
219 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000220 }
221
Tom Stellard50122a52014-04-07 19:45:41 +0000222 bool hasMulU24() const {
223 return (getGeneration() >= EVERGREEN);
224 }
225
226 bool hasMulI24() const {
227 return (getGeneration() >= SOUTHERN_ISLANDS ||
228 hasCaymanISA());
229 }
230
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000231 bool hasFFBL() const {
232 return (getGeneration() >= EVERGREEN);
233 }
234
235 bool hasFFBH() const {
236 return (getGeneration() >= EVERGREEN);
237 }
238
Jan Vesely808fff52015-04-30 17:15:56 +0000239 bool hasCARRY() const {
240 return (getGeneration() >= EVERGREEN);
241 }
242
243 bool hasBORROW() const {
244 return (getGeneration() >= EVERGREEN);
245 }
246
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000247 bool hasCaymanISA() const {
248 return CaymanISA;
249 }
250
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000251 bool isPromoteAllocaEnabled() const {
252 return EnablePromoteAlloca;
253 }
254
Matt Arsenault706f9302015-07-06 16:01:58 +0000255 bool unsafeDSOffsetFoldingEnabled() const {
256 return EnableUnsafeDSOffsetFolding;
257 }
258
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000259 bool dumpCode() const {
260 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000261 }
262
Wei Ding3cb2a1e2016-10-19 22:34:49 +0000263 bool enableIEEEBit(const MachineFunction &MF) const {
264 return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
265 }
266
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000267 /// Return the amount of LDS that can be used that will not restrict the
268 /// occupancy lower than WaveCount.
269 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount) const;
270
271 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
272 /// the given LDS memory size is the only constraint.
273 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes) const;
274
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000275 bool hasFP16Denormals() const {
276 return FP16Denormals;
277 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000278
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000279 bool hasFP32Denormals() const {
280 return FP32Denormals;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000281 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000282
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000283 bool hasFP64Denormals() const {
284 return FP64Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000285 }
286
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000287 bool hasFPExceptions() const {
288 return FPExceptions;
Marek Olsak4d00dd22015-03-09 15:48:09 +0000289 }
290
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000291 bool useFlatForGlobal() const {
292 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000293 }
294
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000295 bool hasUnalignedBufferAccess() const {
296 return UnalignedBufferAccess;
297 }
298
Tom Stellard64a9d082016-10-14 18:10:39 +0000299 bool hasUnalignedScratchAccess() const {
300 return UnalignedScratchAccess;
301 }
302
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000303 bool isXNACKEnabled() const {
304 return EnableXNACK;
305 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000306
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000307 bool isAmdCodeObjectV2() const {
308 return isAmdHsaOS() || isMesa3DOS();
309 }
310
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000311 /// \brief Returns the offset in bytes from the start of the input buffer
312 /// of the first explicit kernel argument.
313 unsigned getExplicitKernelArgOffset() const {
Tom Stellard0b76fc4c2016-09-16 21:34:26 +0000314 return isAmdCodeObjectV2() ? 0 : 36;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000315 }
316
Tom Stellardb2869eb2016-09-09 19:28:00 +0000317 unsigned getAlignmentForImplicitArgPtr() const {
318 return isAmdHsaOS() ? 8 : 4;
319 }
320
Tom Stellarde88bbc32016-09-23 01:33:26 +0000321 unsigned getImplicitArgNumBytes() const {
322 if (isMesa3DOS())
323 return 16;
324 if (isAmdHsaOS() && isOpenCLEnv())
325 return 32;
326 return 0;
327 }
328
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000329 unsigned getStackAlignment() const {
330 // Scratch is allocated in 256 dword per wave blocks.
331 return 4 * 256 / getWavefrontSize();
332 }
Tom Stellard347ac792015-06-26 21:15:07 +0000333
Craig Topper5656db42014-04-29 07:57:24 +0000334 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000335 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000336 }
337
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000338 bool enableSubRegLiveness() const override {
339 return true;
340 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000341
342 /// \returns Number of execution units per compute unit supported by the
343 /// subtarget.
344 unsigned getEUsPerCU() const {
345 return 4;
346 }
347
348 /// \returns Maximum number of work groups per compute unit supported by the
349 /// subtarget and limited by given flat work group size.
350 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
351 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
352 return 8;
353 return getWavesPerWorkGroup(FlatWorkGroupSize) == 1 ? 40 : 16;
354 }
355
356 /// \returns Maximum number of waves per compute unit supported by the
357 /// subtarget without any kind of limitation.
358 unsigned getMaxWavesPerCU() const {
359 return getMaxWavesPerEU() * getEUsPerCU();
360 }
361
362 /// \returns Maximum number of waves per compute unit supported by the
363 /// subtarget and limited by given flat work group size.
364 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
365 return getWavesPerWorkGroup(FlatWorkGroupSize);
366 }
367
368 /// \returns Minimum number of waves per execution unit supported by the
369 /// subtarget.
370 unsigned getMinWavesPerEU() const {
371 return 1;
372 }
373
374 /// \returns Maximum number of waves per execution unit supported by the
375 /// subtarget without any kind of limitation.
376 unsigned getMaxWavesPerEU() const {
377 if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
378 return 8;
379 // FIXME: Need to take scratch memory into account.
380 return 10;
381 }
382
383 /// \returns Maximum number of waves per execution unit supported by the
384 /// subtarget and limited by given flat work group size.
385 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
386 return alignTo(getMaxWavesPerCU(FlatWorkGroupSize), getEUsPerCU()) /
387 getEUsPerCU();
388 }
389
390 /// \returns Minimum flat work group size supported by the subtarget.
391 unsigned getMinFlatWorkGroupSize() const {
392 return 1;
393 }
394
395 /// \returns Maximum flat work group size supported by the subtarget.
396 unsigned getMaxFlatWorkGroupSize() const {
397 return 2048;
398 }
399
400 /// \returns Number of waves per work group given the flat work group size.
401 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
402 return alignTo(FlatWorkGroupSize, getWavefrontSize()) / getWavefrontSize();
403 }
404
Alexander Timofeev18009562016-12-08 17:28:47 +0000405 void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b;}
406 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal;}
407
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000408 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
409 /// for function \p F, or minimum/maximum flat work group sizes explicitly
410 /// requested using "amdgpu-flat-work-group-size" attribute attached to
411 /// function \p F.
412 ///
413 /// \returns Subtarget's default values if explicitly requested values cannot
414 /// be converted to integer, or violate subtarget's specifications.
415 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
416
417 /// \returns Subtarget's default pair of minimum/maximum number of waves per
418 /// execution unit for function \p F, or minimum/maximum number of waves per
419 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
420 /// attached to function \p F.
421 ///
422 /// \returns Subtarget's default values if explicitly requested values cannot
423 /// be converted to integer, violate subtarget's specifications, or are not
424 /// compatible with minimum/maximum number of waves limited by flat work group
425 /// size, register usage, and/or lds usage.
426 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000427};
428
429class R600Subtarget final : public AMDGPUSubtarget {
430private:
431 R600InstrInfo InstrInfo;
432 R600FrameLowering FrameLowering;
433 R600TargetLowering TLInfo;
434
435public:
436 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
437 const TargetMachine &TM);
438
439 const R600InstrInfo *getInstrInfo() const override {
440 return &InstrInfo;
441 }
442
443 const R600FrameLowering *getFrameLowering() const override {
444 return &FrameLowering;
445 }
446
447 const R600TargetLowering *getTargetLowering() const override {
448 return &TLInfo;
449 }
450
451 const R600RegisterInfo *getRegisterInfo() const override {
452 return &InstrInfo.getRegisterInfo();
453 }
454
455 bool hasCFAluBug() const {
456 return CFALUBug;
457 }
458
459 bool hasVertexCache() const {
460 return HasVertexCache;
461 }
462
463 short getTexVTXClauseSize() const {
464 return TexVTXClauseSize;
465 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000466};
467
468class SISubtarget final : public AMDGPUSubtarget {
469public:
470 enum {
Marek Olsak355a8642016-08-05 21:23:29 +0000471 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
472 // doesn't spill SGPRs as much as when 80 is set.
473 FIXED_SGPR_COUNT_FOR_INIT_BUG = 96
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000474 };
475
476private:
477 SIInstrInfo InstrInfo;
478 SIFrameLowering FrameLowering;
479 SITargetLowering TLInfo;
480 std::unique_ptr<GISelAccessor> GISel;
481
482public:
483 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
484 const TargetMachine &TM);
485
486 const SIInstrInfo *getInstrInfo() const override {
487 return &InstrInfo;
488 }
489
490 const SIFrameLowering *getFrameLowering() const override {
491 return &FrameLowering;
492 }
493
494 const SITargetLowering *getTargetLowering() const override {
495 return &TLInfo;
496 }
497
498 const CallLowering *getCallLowering() const override {
499 assert(GISel && "Access to GlobalISel APIs not set");
500 return GISel->getCallLowering();
501 }
502
503 const SIRegisterInfo *getRegisterInfo() const override {
504 return &InstrInfo.getRegisterInfo();
505 }
506
507 void setGISelAccessor(GISelAccessor &GISel) {
508 this->GISel.reset(&GISel);
509 }
510
Tom Stellard83f0bce2015-01-29 16:55:25 +0000511 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000512 unsigned NumRegionInstrs) const override;
513
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000514 bool isVGPRSpillingEnabled(const Function& F) const;
515
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000516 unsigned getMaxNumUserSGPRs() const {
517 return 16;
518 }
519
520 bool hasFlatAddressSpace() const {
521 return FlatAddressSpace;
522 }
523
524 bool hasSMemRealTime() const {
525 return HasSMemRealTime;
526 }
527
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000528 bool hasMovrel() const {
529 return HasMovrel;
530 }
531
532 bool hasVGPRIndexMode() const {
533 return HasVGPRIndexMode;
534 }
535
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000536 bool hasScalarCompareEq64() const {
537 return getGeneration() >= VOLCANIC_ISLANDS;
538 }
539
Matt Arsenault7b647552016-10-28 21:55:15 +0000540 bool hasScalarStores() const {
541 return HasScalarStores;
542 }
543
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000544 bool hasInv2PiInlineImm() const {
545 return HasInv2PiInlineImm;
546 }
547
Tom Stellardde008d32016-01-21 04:28:34 +0000548 bool enableSIScheduler() const {
549 return EnableSIScheduler;
550 }
551
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000552 bool debuggerSupported() const {
553 return debuggerInsertNops() && debuggerReserveRegs() &&
554 debuggerEmitPrologue();
555 }
556
Konstantin Zhuravlyov8c273ad2016-04-18 16:28:23 +0000557 bool debuggerInsertNops() const {
558 return DebuggerInsertNops;
559 }
560
Konstantin Zhuravlyov29ddd2b2016-05-24 18:37:18 +0000561 bool debuggerReserveRegs() const {
562 return DebuggerReserveRegs;
Konstantin Zhuravlyov1d99c4d2016-04-26 15:43:14 +0000563 }
564
Konstantin Zhuravlyovf2f3d142016-06-25 03:11:28 +0000565 bool debuggerEmitPrologue() const {
566 return DebuggerEmitPrologue;
567 }
568
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000569 bool loadStoreOptEnabled() const {
570 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +0000571 }
572
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000573 bool hasSGPRInitBug() const {
574 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +0000575 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000576
Tom Stellardb133fbb2016-10-27 23:05:31 +0000577 bool has12DWordStoreHazard() const {
578 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
579 }
580
Tom Stellarde88bbc32016-09-23 01:33:26 +0000581 unsigned getKernArgSegmentSize(unsigned ExplictArgBytes) const;
582
Tom Stellard0d23ebe2016-08-29 19:42:52 +0000583 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
584 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
585
586 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
587 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +0000588
589 /// \returns True if waitcnt instruction is needed before barrier instruction,
590 /// false otherwise.
591 bool needWaitcntBeforeBarrier() const {
592 return true;
593 }
Matt Arsenault4eae3012016-10-28 20:31:47 +0000594
595 unsigned getMaxNumSGPRs() const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000596};
597
598} // End namespace llvm
599
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000600#endif