]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r308421, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / AMDGPUSubtarget.h
1 //=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
2 //
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
15 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
17
18 #include "AMDGPU.h"
19 #include "R600FrameLowering.h"
20 #include "R600ISelLowering.h"
21 #include "R600InstrInfo.h"
22 #include "SIFrameLowering.h"
23 #include "SIISelLowering.h"
24 #include "SIInstrInfo.h"
25 #include "SIMachineFunctionInfo.h"
26 #include "Utils/AMDGPUBaseInfo.h"
27 #include "llvm/ADT/Triple.h"
28 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
29 #include "llvm/CodeGen/MachineFunction.h"
30 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
31 #include "llvm/MC/MCInstrItineraries.h"
32 #include "llvm/Support/MathExtras.h"
33 #include <cassert>
34 #include <cstdint>
35 #include <memory>
36 #include <utility>
37
38 #define GET_SUBTARGETINFO_HEADER
39 #include "AMDGPUGenSubtargetInfo.inc"
40
41 namespace llvm {
42
43 class StringRef;
44
45 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
46 public:
47   enum Generation {
48     R600 = 0,
49     R700,
50     EVERGREEN,
51     NORTHERN_ISLANDS,
52     SOUTHERN_ISLANDS,
53     SEA_ISLANDS,
54     VOLCANIC_ISLANDS,
55     GFX9,
56   };
57
58   enum {
59     ISAVersion0_0_0,
60     ISAVersion6_0_0,
61     ISAVersion6_0_1,
62     ISAVersion7_0_0,
63     ISAVersion7_0_1,
64     ISAVersion7_0_2,
65     ISAVersion7_0_3,
66     ISAVersion8_0_0,
67     ISAVersion8_0_1,
68     ISAVersion8_0_2,
69     ISAVersion8_0_3,
70     ISAVersion8_0_4,
71     ISAVersion8_1_0,
72     ISAVersion9_0_0,
73     ISAVersion9_0_1,
74     ISAVersion9_0_2,
75     ISAVersion9_0_3
76   };
77
78   enum TrapHandlerAbi {
79     TrapHandlerAbiNone = 0,
80     TrapHandlerAbiHsa = 1
81   };
82
83   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
92   };
93
94   enum TrapRegValues {
95     LLVMTrapHandlerRegValue = 1
96   };
97
98 protected:
99   // Basic subtarget description.
100   Triple TargetTriple;
101   Generation Gen;
102   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.
109   bool FastFMAF32;
110   bool HalfRate64Ops;
111
112   // Dynamially set bits that enable features.
113   bool FP32Denormals;
114   bool FP64FP16Denormals;
115   bool FPExceptions;
116   bool DX10Clamp;
117   bool FlatForGlobal;
118   bool AutoWaitcntBeforeBarrier;
119   bool UnalignedScratchAccess;
120   bool UnalignedBufferAccess;
121   bool HasApertureRegs;
122   bool EnableXNACK;
123   bool TrapHandler;
124   bool DebuggerInsertNops;
125   bool DebuggerReserveRegs;
126   bool DebuggerEmitPrologue;
127
128   // Used as options.
129   bool EnableVGPRSpilling;
130   bool EnablePromoteAlloca;
131   bool EnableLoadStoreOpt;
132   bool EnableUnsafeDSOffsetFolding;
133   bool EnableSIScheduler;
134   bool DumpCode;
135
136   // Subtarget statically properties set by tablegen
137   bool FP64;
138   bool IsGCN;
139   bool GCN1Encoding;
140   bool GCN3Encoding;
141   bool CIInsts;
142   bool GFX9Insts;
143   bool SGPRInitBug;
144   bool HasSMemRealTime;
145   bool Has16BitInsts;
146   bool HasVOP3PInsts;
147   bool HasMovrel;
148   bool HasVGPRIndexMode;
149   bool HasScalarStores;
150   bool HasInv2PiInlineImm;
151   bool HasSDWA;
152   bool HasSDWAOmod;
153   bool HasSDWAScalar;
154   bool HasSDWASdst;
155   bool HasSDWAMac;
156   bool HasSDWAOutModsVOPC;
157   bool HasDPP;
158   bool FlatAddressSpace;
159   bool FlatInstOffsets;
160   bool FlatGlobalInsts;
161   bool FlatScratchInsts;
162   bool R600ALUInst;
163   bool CaymanISA;
164   bool CFALUBug;
165   bool HasVertexCache;
166   short TexVTXClauseSize;
167   bool ScalarizeGlobal;
168
169   // Dummy feature to use for assembler in tablegen.
170   bool FeatureDisable;
171
172   InstrItineraryData InstrItins;
173   SelectionDAGTargetInfo TSInfo;
174   AMDGPUAS AS;
175
176 public:
177   AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
178                   const TargetMachine &TM);
179   ~AMDGPUSubtarget() override;
180
181   AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
182                                                    StringRef GPU, StringRef FS);
183
184   const AMDGPUInstrInfo *getInstrInfo() const override = 0;
185   const AMDGPUFrameLowering *getFrameLowering() const override = 0;
186   const AMDGPUTargetLowering *getTargetLowering() const override = 0;
187   const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
188
189   const InstrItineraryData *getInstrItineraryData() const override {
190     return &InstrItins;
191   }
192
193   // Nothing implemented, just prevent crashes on use.
194   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
195     return &TSInfo;
196   }
197
198   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
199
200   bool isAmdHsaOS() const {
201     return TargetTriple.getOS() == Triple::AMDHSA;
202   }
203
204   bool isMesa3DOS() const {
205     return TargetTriple.getOS() == Triple::Mesa3D;
206   }
207
208   bool isOpenCLEnv() const {
209     return TargetTriple.getEnvironment() == Triple::OpenCL ||
210            TargetTriple.getEnvironmentName() == "amdgizcl";
211   }
212
213   Generation getGeneration() const {
214     return Gen;
215   }
216
217   unsigned getWavefrontSize() const {
218     return WavefrontSize;
219   }
220
221   int getLocalMemorySize() const {
222     return LocalMemorySize;
223   }
224
225   int getLDSBankCount() const {
226     return LDSBankCount;
227   }
228
229   unsigned getMaxPrivateElementSize() const {
230     return MaxPrivateElementSize;
231   }
232
233   AMDGPUAS getAMDGPUAS() const {
234     return AS;
235   }
236
237   bool has16BitInsts() const {
238     return Has16BitInsts;
239   }
240
241   bool hasVOP3PInsts() const {
242     return HasVOP3PInsts;
243   }
244
245   bool hasHWFP64() const {
246     return FP64;
247   }
248
249   bool hasFastFMAF32() const {
250     return FastFMAF32;
251   }
252
253   bool hasHalfRate64Ops() const {
254     return HalfRate64Ops;
255   }
256
257   bool hasAddr64() const {
258     return (getGeneration() < VOLCANIC_ISLANDS);
259   }
260
261   bool hasBFE() const {
262     return (getGeneration() >= EVERGREEN);
263   }
264
265   bool hasBFI() const {
266     return (getGeneration() >= EVERGREEN);
267   }
268
269   bool hasBFM() const {
270     return hasBFE();
271   }
272
273   bool hasBCNT(unsigned Size) const {
274     if (Size == 32)
275       return (getGeneration() >= EVERGREEN);
276
277     if (Size == 64)
278       return (getGeneration() >= SOUTHERN_ISLANDS);
279
280     return false;
281   }
282
283   bool hasMulU24() const {
284     return (getGeneration() >= EVERGREEN);
285   }
286
287   bool hasMulI24() const {
288     return (getGeneration() >= SOUTHERN_ISLANDS ||
289             hasCaymanISA());
290   }
291
292   bool hasFFBL() const {
293     return (getGeneration() >= EVERGREEN);
294   }
295
296   bool hasFFBH() const {
297     return (getGeneration() >= EVERGREEN);
298   }
299
300   bool hasMed3_16() const {
301     return getGeneration() >= GFX9;
302   }
303
304   bool hasMin3Max3_16() const {
305     return getGeneration() >= GFX9;
306   }
307
308   bool hasCARRY() const {
309     return (getGeneration() >= EVERGREEN);
310   }
311
312   bool hasBORROW() const {
313     return (getGeneration() >= EVERGREEN);
314   }
315
316   bool hasCaymanISA() const {
317     return CaymanISA;
318   }
319
320   TrapHandlerAbi getTrapHandlerAbi() const {
321     return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
322   }
323
324   bool isPromoteAllocaEnabled() const {
325     return EnablePromoteAlloca;
326   }
327
328   bool unsafeDSOffsetFoldingEnabled() const {
329     return EnableUnsafeDSOffsetFolding;
330   }
331
332   bool dumpCode() const {
333     return DumpCode;
334   }
335
336   /// Return the amount of LDS that can be used that will not restrict the
337   /// occupancy lower than WaveCount.
338   unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
339                                            const Function &) const;
340
341   /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
342   /// the given LDS memory size is the only constraint.
343   unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
344
345   unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const {
346     const auto *MFI = MF.getInfo<SIMachineFunctionInfo>();
347     return getOccupancyWithLocalMemSize(MFI->getLDSSize(), *MF.getFunction());
348   }
349
350   bool hasFP16Denormals() const {
351     return FP64FP16Denormals;
352   }
353
354   bool hasFP32Denormals() const {
355     return FP32Denormals;
356   }
357
358   bool hasFP64Denormals() const {
359     return FP64FP16Denormals;
360   }
361
362   bool supportsMinMaxDenormModes() const {
363     return getGeneration() >= AMDGPUSubtarget::GFX9;
364   }
365
366   bool hasFPExceptions() const {
367     return FPExceptions;
368   }
369
370   bool enableDX10Clamp() const {
371     return DX10Clamp;
372   }
373
374   bool enableIEEEBit(const MachineFunction &MF) const {
375     return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
376   }
377
378   bool useFlatForGlobal() const {
379     return FlatForGlobal;
380   }
381
382   bool hasAutoWaitcntBeforeBarrier() const {
383     return AutoWaitcntBeforeBarrier;
384   }
385
386   bool hasUnalignedBufferAccess() const {
387     return UnalignedBufferAccess;
388   }
389
390   bool hasUnalignedScratchAccess() const {
391     return UnalignedScratchAccess;
392   }
393
394   bool hasApertureRegs() const {
395    return HasApertureRegs;
396   }
397
398   bool isTrapHandlerEnabled() const {
399     return TrapHandler;
400   }
401
402   bool isXNACKEnabled() const {
403     return EnableXNACK;
404   }
405
406   bool hasFlatAddressSpace() const {
407     return FlatAddressSpace;
408   }
409
410   bool hasFlatInstOffsets() const {
411     return FlatInstOffsets;
412   }
413
414   bool hasFlatGlobalInsts() const {
415     return FlatGlobalInsts;
416   }
417
418   bool hasFlatScratchInsts() const {
419     return FlatScratchInsts;
420   }
421
422   bool isMesaKernel(const MachineFunction &MF) const {
423     return isMesa3DOS() && !AMDGPU::isShader(MF.getFunction()->getCallingConv());
424   }
425
426   // Covers VS/PS/CS graphics shaders
427   bool isMesaGfxShader(const MachineFunction &MF) const {
428     return isMesa3DOS() && AMDGPU::isShader(MF.getFunction()->getCallingConv());
429   }
430
431   bool isAmdCodeObjectV2(const MachineFunction &MF) const {
432     return isAmdHsaOS() || isMesaKernel(MF);
433   }
434
435   bool hasFminFmaxLegacy() const {
436     return getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS;
437   }
438
439   bool hasSDWA() const {
440     return HasSDWA;
441   }
442
443   bool hasSDWAOmod() const {
444     return HasSDWAOmod;
445   }
446
447   bool hasSDWAScalar() const {
448     return HasSDWAScalar;
449   }
450
451   bool hasSDWASdst() const {
452     return HasSDWASdst;
453   }
454
455   bool hasSDWAMac() const {
456     return HasSDWAMac;
457   }
458
459   bool hasSDWAOutModsVOPC() const {
460     return HasSDWAOutModsVOPC;
461   }
462
463   /// \brief Returns the offset in bytes from the start of the input buffer
464   ///        of the first explicit kernel argument.
465   unsigned getExplicitKernelArgOffset(const MachineFunction &MF) const {
466     return isAmdCodeObjectV2(MF) ? 0 : 36;
467   }
468
469   unsigned getAlignmentForImplicitArgPtr() const {
470     return isAmdHsaOS() ? 8 : 4;
471   }
472
473   unsigned getImplicitArgNumBytes(const MachineFunction &MF) const {
474     if (isMesaKernel(MF))
475       return 16;
476     if (isAmdHsaOS() && isOpenCLEnv())
477       return 32;
478     return 0;
479   }
480
481   // Scratch is allocated in 256 dword per wave blocks for the entire
482   // wavefront. When viewed from the perspecive of an arbitrary workitem, this
483   // is 4-byte aligned.
484   unsigned getStackAlignment() const {
485     return 4;
486   }
487
488   bool enableMachineScheduler() const override {
489     return true;
490   }
491
492   bool enableSubRegLiveness() const override {
493     return true;
494   }
495
496   void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b;}
497   bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal;}
498
499   /// \returns Number of execution units per compute unit supported by the
500   /// subtarget.
501   unsigned getEUsPerCU() const {
502     return AMDGPU::IsaInfo::getEUsPerCU(getFeatureBits());
503   }
504
505   /// \returns Maximum number of work groups per compute unit supported by the
506   /// subtarget and limited by given \p FlatWorkGroupSize.
507   unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
508     return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(getFeatureBits(),
509                                                   FlatWorkGroupSize);
510   }
511
512   /// \returns Maximum number of waves per compute unit supported by the
513   /// subtarget without any kind of limitation.
514   unsigned getMaxWavesPerCU() const {
515     return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits());
516   }
517
518   /// \returns Maximum number of waves per compute unit supported by the
519   /// subtarget and limited by given \p FlatWorkGroupSize.
520   unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
521     return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits(),
522                                              FlatWorkGroupSize);
523   }
524
525   /// \returns Minimum number of waves per execution unit supported by the
526   /// subtarget.
527   unsigned getMinWavesPerEU() const {
528     return AMDGPU::IsaInfo::getMinWavesPerEU(getFeatureBits());
529   }
530
531   /// \returns Maximum number of waves per execution unit supported by the
532   /// subtarget without any kind of limitation.
533   unsigned getMaxWavesPerEU() const {
534     return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits());
535   }
536
537   /// \returns Maximum number of waves per execution unit supported by the
538   /// subtarget and limited by given \p FlatWorkGroupSize.
539   unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
540     return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits(),
541                                              FlatWorkGroupSize);
542   }
543
544   /// \returns Minimum flat work group size supported by the subtarget.
545   unsigned getMinFlatWorkGroupSize() const {
546     return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(getFeatureBits());
547   }
548
549   /// \returns Maximum flat work group size supported by the subtarget.
550   unsigned getMaxFlatWorkGroupSize() const {
551     return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(getFeatureBits());
552   }
553
554   /// \returns Number of waves per work group supported by the subtarget and
555   /// limited by given \p FlatWorkGroupSize.
556   unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
557     return AMDGPU::IsaInfo::getWavesPerWorkGroup(getFeatureBits(),
558                                                  FlatWorkGroupSize);
559   }
560
561   /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
562   /// for function \p F, or minimum/maximum flat work group sizes explicitly
563   /// requested using "amdgpu-flat-work-group-size" attribute attached to
564   /// function \p F.
565   ///
566   /// \returns Subtarget's default values if explicitly requested values cannot
567   /// be converted to integer, or violate subtarget's specifications.
568   std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
569
570   /// \returns Subtarget's default pair of minimum/maximum number of waves per
571   /// execution unit for function \p F, or minimum/maximum number of waves per
572   /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
573   /// attached to function \p F.
574   ///
575   /// \returns Subtarget's default values if explicitly requested values cannot
576   /// be converted to integer, violate subtarget's specifications, or are not
577   /// compatible with minimum/maximum number of waves limited by flat work group
578   /// size, register usage, and/or lds usage.
579   std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
580
581   /// Creates value range metadata on an workitemid.* inrinsic call or load.
582   bool makeLIDRangeMetadata(Instruction *I) const;
583 };
584
585 class R600Subtarget final : public AMDGPUSubtarget {
586 private:
587   R600InstrInfo InstrInfo;
588   R600FrameLowering FrameLowering;
589   R600TargetLowering TLInfo;
590
591 public:
592   R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
593                 const TargetMachine &TM);
594
595   const R600InstrInfo *getInstrInfo() const override {
596     return &InstrInfo;
597   }
598
599   const R600FrameLowering *getFrameLowering() const override {
600     return &FrameLowering;
601   }
602
603   const R600TargetLowering *getTargetLowering() const override {
604     return &TLInfo;
605   }
606
607   const R600RegisterInfo *getRegisterInfo() const override {
608     return &InstrInfo.getRegisterInfo();
609   }
610
611   bool hasCFAluBug() const {
612     return CFALUBug;
613   }
614
615   bool hasVertexCache() const {
616     return HasVertexCache;
617   }
618
619   short getTexVTXClauseSize() const {
620     return TexVTXClauseSize;
621   }
622 };
623
624 class SISubtarget final : public AMDGPUSubtarget {
625 private:
626   SIInstrInfo InstrInfo;
627   SIFrameLowering FrameLowering;
628   SITargetLowering TLInfo;
629   std::unique_ptr<GISelAccessor> GISel;
630
631 public:
632   SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
633               const TargetMachine &TM);
634
635   const SIInstrInfo *getInstrInfo() const override {
636     return &InstrInfo;
637   }
638
639   const SIFrameLowering *getFrameLowering() const override {
640     return &FrameLowering;
641   }
642
643   const SITargetLowering *getTargetLowering() const override {
644     return &TLInfo;
645   }
646
647   const CallLowering *getCallLowering() const override {
648     assert(GISel && "Access to GlobalISel APIs not set");
649     return GISel->getCallLowering();
650   }
651
652   const InstructionSelector *getInstructionSelector() const override {
653     assert(GISel && "Access to GlobalISel APIs not set");
654     return GISel->getInstructionSelector();
655   }
656
657   const LegalizerInfo *getLegalizerInfo() const override {
658     assert(GISel && "Access to GlobalISel APIs not set");
659     return GISel->getLegalizerInfo();
660   }
661
662   const RegisterBankInfo *getRegBankInfo() const override {
663     assert(GISel && "Access to GlobalISel APIs not set");
664     return GISel->getRegBankInfo();
665   }
666
667   const SIRegisterInfo *getRegisterInfo() const override {
668     return &InstrInfo.getRegisterInfo();
669   }
670
671   void setGISelAccessor(GISelAccessor &GISel) {
672     this->GISel.reset(&GISel);
673   }
674
675   // XXX - Why is this here if it isn't in the default pass set?
676   bool enableEarlyIfConversion() const override {
677     return true;
678   }
679
680   void overrideSchedPolicy(MachineSchedPolicy &Policy,
681                            unsigned NumRegionInstrs) const override;
682
683   bool isVGPRSpillingEnabled(const Function& F) const;
684
685   unsigned getMaxNumUserSGPRs() const {
686     return 16;
687   }
688
689   bool hasSMemRealTime() const {
690     return HasSMemRealTime;
691   }
692
693   bool hasMovrel() const {
694     return HasMovrel;
695   }
696
697   bool hasVGPRIndexMode() const {
698     return HasVGPRIndexMode;
699   }
700
701   bool useVGPRIndexMode(bool UserEnable) const {
702     return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
703   }
704
705   bool hasScalarCompareEq64() const {
706     return getGeneration() >= VOLCANIC_ISLANDS;
707   }
708
709   bool hasScalarStores() const {
710     return HasScalarStores;
711   }
712
713   bool hasInv2PiInlineImm() const {
714     return HasInv2PiInlineImm;
715   }
716
717   bool hasDPP() const {
718     return HasDPP;
719   }
720
721   bool enableSIScheduler() const {
722     return EnableSIScheduler;
723   }
724
725   bool debuggerSupported() const {
726     return debuggerInsertNops() && debuggerReserveRegs() &&
727       debuggerEmitPrologue();
728   }
729
730   bool debuggerInsertNops() const {
731     return DebuggerInsertNops;
732   }
733
734   bool debuggerReserveRegs() const {
735     return DebuggerReserveRegs;
736   }
737
738   bool debuggerEmitPrologue() const {
739     return DebuggerEmitPrologue;
740   }
741
742   bool loadStoreOptEnabled() const {
743     return EnableLoadStoreOpt;
744   }
745
746   bool hasSGPRInitBug() const {
747     return SGPRInitBug;
748   }
749
750   bool has12DWordStoreHazard() const {
751     return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
752   }
753
754   bool hasSMovFedHazard() const {
755     return getGeneration() >= AMDGPUSubtarget::GFX9;
756   }
757
758   bool hasReadM0Hazard() const {
759     return getGeneration() >= AMDGPUSubtarget::GFX9;
760   }
761
762   unsigned getKernArgSegmentSize(const MachineFunction &MF, unsigned ExplictArgBytes) const;
763
764   /// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
765   unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
766
767   /// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
768   unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
769
770   /// \returns true if the flat_scratch register should be initialized with the
771   /// pointer to the wave's scratch memory rather than a size and offset.
772   bool flatScratchIsPointer() const {
773     return getGeneration() >= GFX9;
774   }
775
776   /// \returns SGPR allocation granularity supported by the subtarget.
777   unsigned getSGPRAllocGranule() const {
778     return AMDGPU::IsaInfo::getSGPRAllocGranule(getFeatureBits());
779   }
780
781   /// \returns SGPR encoding granularity supported by the subtarget.
782   unsigned getSGPREncodingGranule() const {
783     return AMDGPU::IsaInfo::getSGPREncodingGranule(getFeatureBits());
784   }
785
786   /// \returns Total number of SGPRs supported by the subtarget.
787   unsigned getTotalNumSGPRs() const {
788     return AMDGPU::IsaInfo::getTotalNumSGPRs(getFeatureBits());
789   }
790
791   /// \returns Addressable number of SGPRs supported by the subtarget.
792   unsigned getAddressableNumSGPRs() const {
793     return AMDGPU::IsaInfo::getAddressableNumSGPRs(getFeatureBits());
794   }
795
796   /// \returns Minimum number of SGPRs that meets the given number of waves per
797   /// execution unit requirement supported by the subtarget.
798   unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
799     return AMDGPU::IsaInfo::getMinNumSGPRs(getFeatureBits(), WavesPerEU);
800   }
801
802   /// \returns Maximum number of SGPRs that meets the given number of waves per
803   /// execution unit requirement supported by the subtarget.
804   unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
805     return AMDGPU::IsaInfo::getMaxNumSGPRs(getFeatureBits(), WavesPerEU,
806                                            Addressable);
807   }
808
809   /// \returns Reserved number of SGPRs for given function \p MF.
810   unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
811
812   /// \returns Maximum number of SGPRs that meets number of waves per execution
813   /// unit requirement for function \p MF, or number of SGPRs explicitly
814   /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
815   ///
816   /// \returns Value that meets number of waves per execution unit requirement
817   /// if explicitly requested value cannot be converted to integer, violates
818   /// subtarget's specifications, or does not meet number of waves per execution
819   /// unit requirement.
820   unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
821
822   /// \returns VGPR allocation granularity supported by the subtarget.
823   unsigned getVGPRAllocGranule() const {
824     return AMDGPU::IsaInfo::getVGPRAllocGranule(getFeatureBits());
825   }
826
827   /// \returns VGPR encoding granularity supported by the subtarget.
828   unsigned getVGPREncodingGranule() const {
829     return AMDGPU::IsaInfo::getVGPREncodingGranule(getFeatureBits());
830   }
831
832   /// \returns Total number of VGPRs supported by the subtarget.
833   unsigned getTotalNumVGPRs() const {
834     return AMDGPU::IsaInfo::getTotalNumVGPRs(getFeatureBits());
835   }
836
837   /// \returns Addressable number of VGPRs supported by the subtarget.
838   unsigned getAddressableNumVGPRs() const {
839     return AMDGPU::IsaInfo::getAddressableNumVGPRs(getFeatureBits());
840   }
841
842   /// \returns Minimum number of VGPRs that meets given number of waves per
843   /// execution unit requirement supported by the subtarget.
844   unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
845     return AMDGPU::IsaInfo::getMinNumVGPRs(getFeatureBits(), WavesPerEU);
846   }
847
848   /// \returns Maximum number of VGPRs that meets given number of waves per
849   /// execution unit requirement supported by the subtarget.
850   unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
851     return AMDGPU::IsaInfo::getMaxNumVGPRs(getFeatureBits(), WavesPerEU);
852   }
853
854   /// \returns Reserved number of VGPRs for given function \p MF.
855   unsigned getReservedNumVGPRs(const MachineFunction &MF) const {
856     return debuggerReserveRegs() ? 4 : 0;
857   }
858
859   /// \returns Maximum number of VGPRs that meets number of waves per execution
860   /// unit requirement for function \p MF, or number of VGPRs explicitly
861   /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
862   ///
863   /// \returns Value that meets number of waves per execution unit requirement
864   /// if explicitly requested value cannot be converted to integer, violates
865   /// subtarget's specifications, or does not meet number of waves per execution
866   /// unit requirement.
867   unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
868 };
869
870 } // end namespace llvm
871
872 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H