xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/GCNSubtarget.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1e8d8bef9SDimitry Andric //=====-- GCNSubtarget.h - Define GCN Subtarget for AMDGPU ------*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //==-----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric //
9e8d8bef9SDimitry Andric /// \file
10e8d8bef9SDimitry Andric /// AMD GCN specific subclass of TargetSubtarget.
11e8d8bef9SDimitry Andric //
12e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
13e8d8bef9SDimitry Andric 
14e8d8bef9SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
15e8d8bef9SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric #include "AMDGPUCallLowering.h"
18e8d8bef9SDimitry Andric #include "AMDGPUSubtarget.h"
19e8d8bef9SDimitry Andric #include "SIFrameLowering.h"
20e8d8bef9SDimitry Andric #include "SIISelLowering.h"
21e8d8bef9SDimitry Andric #include "SIInstrInfo.h"
22e8d8bef9SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
23e8d8bef9SDimitry Andric 
24e8d8bef9SDimitry Andric #define GET_SUBTARGETINFO_HEADER
25e8d8bef9SDimitry Andric #include "AMDGPUGenSubtargetInfo.inc"
26e8d8bef9SDimitry Andric 
27e8d8bef9SDimitry Andric namespace llvm {
28e8d8bef9SDimitry Andric 
29e8d8bef9SDimitry Andric class GCNTargetMachine;
30e8d8bef9SDimitry Andric 
31e8d8bef9SDimitry Andric class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
32e8d8bef9SDimitry Andric                            public AMDGPUSubtarget {
33e8d8bef9SDimitry Andric 
34e8d8bef9SDimitry Andric   using AMDGPUSubtarget::getMaxWavesPerEU;
35e8d8bef9SDimitry Andric 
36e8d8bef9SDimitry Andric public:
37fe6060f1SDimitry Andric   // Following 2 enums are documented at:
38fe6060f1SDimitry Andric   //   - https://llvm.org/docs/AMDGPUUsage.html#trap-handler-abi
39fe6060f1SDimitry Andric   enum class TrapHandlerAbi {
40fe6060f1SDimitry Andric     NONE   = 0x00,
41fe6060f1SDimitry Andric     AMDHSA = 0x01,
42e8d8bef9SDimitry Andric   };
43e8d8bef9SDimitry Andric 
44fe6060f1SDimitry Andric   enum class TrapID {
45fe6060f1SDimitry Andric     LLVMAMDHSATrap      = 0x02,
46fe6060f1SDimitry Andric     LLVMAMDHSADebugTrap = 0x03,
47e8d8bef9SDimitry Andric   };
48e8d8bef9SDimitry Andric 
49e8d8bef9SDimitry Andric private:
50e8d8bef9SDimitry Andric   /// GlobalISel related APIs.
51e8d8bef9SDimitry Andric   std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
52e8d8bef9SDimitry Andric   std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
53e8d8bef9SDimitry Andric   std::unique_ptr<InstructionSelector> InstSelector;
54e8d8bef9SDimitry Andric   std::unique_ptr<LegalizerInfo> Legalizer;
55e8d8bef9SDimitry Andric   std::unique_ptr<RegisterBankInfo> RegBankInfo;
56e8d8bef9SDimitry Andric 
57e8d8bef9SDimitry Andric protected:
58e8d8bef9SDimitry Andric   // Basic subtarget description.
59e8d8bef9SDimitry Andric   Triple TargetTriple;
60e8d8bef9SDimitry Andric   AMDGPU::IsaInfo::AMDGPUTargetID TargetID;
61e8d8bef9SDimitry Andric   unsigned Gen;
62e8d8bef9SDimitry Andric   InstrItineraryData InstrItins;
63e8d8bef9SDimitry Andric   int LDSBankCount;
64e8d8bef9SDimitry Andric   unsigned MaxPrivateElementSize;
65e8d8bef9SDimitry Andric 
66e8d8bef9SDimitry Andric   // Possibly statically set by tablegen, but may want to be overridden.
67e8d8bef9SDimitry Andric   bool FastFMAF32;
68e8d8bef9SDimitry Andric   bool FastDenormalF32;
69e8d8bef9SDimitry Andric   bool HalfRate64Ops;
70fe6060f1SDimitry Andric   bool FullRate64Ops;
71e8d8bef9SDimitry Andric 
72e8d8bef9SDimitry Andric   // Dynamically set bits that enable features.
73e8d8bef9SDimitry Andric   bool FlatForGlobal;
74e8d8bef9SDimitry Andric   bool AutoWaitcntBeforeBarrier;
75e8d8bef9SDimitry Andric   bool UnalignedScratchAccess;
76e8d8bef9SDimitry Andric   bool UnalignedAccessMode;
77e8d8bef9SDimitry Andric   bool HasApertureRegs;
78e8d8bef9SDimitry Andric   bool SupportsXNACK;
79e8d8bef9SDimitry Andric 
80e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
81e8d8bef9SDimitry Andric   // for XNACK.
82e8d8bef9SDimitry Andric   bool EnableXNACK;
83e8d8bef9SDimitry Andric 
84fe6060f1SDimitry Andric   bool EnableTgSplit;
85e8d8bef9SDimitry Andric   bool EnableCuMode;
86e8d8bef9SDimitry Andric   bool TrapHandler;
87e8d8bef9SDimitry Andric 
88e8d8bef9SDimitry Andric   // Used as options.
89e8d8bef9SDimitry Andric   bool EnableLoadStoreOpt;
90e8d8bef9SDimitry Andric   bool EnableUnsafeDSOffsetFolding;
91e8d8bef9SDimitry Andric   bool EnableSIScheduler;
92e8d8bef9SDimitry Andric   bool EnableDS128;
93e8d8bef9SDimitry Andric   bool EnablePRTStrictNull;
94e8d8bef9SDimitry Andric   bool DumpCode;
95e8d8bef9SDimitry Andric 
96e8d8bef9SDimitry Andric   // Subtarget statically properties set by tablegen
97e8d8bef9SDimitry Andric   bool FP64;
98e8d8bef9SDimitry Andric   bool FMA;
99e8d8bef9SDimitry Andric   bool MIMG_R128;
100e8d8bef9SDimitry Andric   bool CIInsts;
101e8d8bef9SDimitry Andric   bool GFX8Insts;
102e8d8bef9SDimitry Andric   bool GFX9Insts;
103fe6060f1SDimitry Andric   bool GFX90AInsts;
104e8d8bef9SDimitry Andric   bool GFX10Insts;
105e8d8bef9SDimitry Andric   bool GFX10_3Insts;
106e8d8bef9SDimitry Andric   bool GFX7GFX8GFX9Insts;
107e8d8bef9SDimitry Andric   bool SGPRInitBug;
108fe6060f1SDimitry Andric   bool NegativeScratchOffsetBug;
109fe6060f1SDimitry Andric   bool NegativeUnalignedScratchOffsetBug;
110e8d8bef9SDimitry Andric   bool HasSMemRealTime;
111e8d8bef9SDimitry Andric   bool HasIntClamp;
112e8d8bef9SDimitry Andric   bool HasFmaMixInsts;
113e8d8bef9SDimitry Andric   bool HasMovrel;
114e8d8bef9SDimitry Andric   bool HasVGPRIndexMode;
115e8d8bef9SDimitry Andric   bool HasScalarStores;
116e8d8bef9SDimitry Andric   bool HasScalarAtomics;
117e8d8bef9SDimitry Andric   bool HasSDWAOmod;
118e8d8bef9SDimitry Andric   bool HasSDWAScalar;
119e8d8bef9SDimitry Andric   bool HasSDWASdst;
120e8d8bef9SDimitry Andric   bool HasSDWAMac;
121e8d8bef9SDimitry Andric   bool HasSDWAOutModsVOPC;
122e8d8bef9SDimitry Andric   bool HasDPP;
123e8d8bef9SDimitry Andric   bool HasDPP8;
124fe6060f1SDimitry Andric   bool Has64BitDPP;
125fe6060f1SDimitry Andric   bool HasPackedFP32Ops;
126fe6060f1SDimitry Andric   bool HasExtendedImageInsts;
127e8d8bef9SDimitry Andric   bool HasR128A16;
128e8d8bef9SDimitry Andric   bool HasGFX10A16;
129e8d8bef9SDimitry Andric   bool HasG16;
130e8d8bef9SDimitry Andric   bool HasNSAEncoding;
131fe6060f1SDimitry Andric   unsigned NSAMaxSize;
132fe6060f1SDimitry Andric   bool GFX10_AEncoding;
133e8d8bef9SDimitry Andric   bool GFX10_BEncoding;
134e8d8bef9SDimitry Andric   bool HasDLInsts;
135e8d8bef9SDimitry Andric   bool HasDot1Insts;
136e8d8bef9SDimitry Andric   bool HasDot2Insts;
137e8d8bef9SDimitry Andric   bool HasDot3Insts;
138e8d8bef9SDimitry Andric   bool HasDot4Insts;
139e8d8bef9SDimitry Andric   bool HasDot5Insts;
140e8d8bef9SDimitry Andric   bool HasDot6Insts;
141fe6060f1SDimitry Andric   bool HasDot7Insts;
142e8d8bef9SDimitry Andric   bool HasMAIInsts;
143e8d8bef9SDimitry Andric   bool HasPkFmacF16Inst;
144e8d8bef9SDimitry Andric   bool HasAtomicFaddInsts;
145e8d8bef9SDimitry Andric   bool SupportsSRAMECC;
146e8d8bef9SDimitry Andric 
147e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
148e8d8bef9SDimitry Andric   // for SRAMECC.
149e8d8bef9SDimitry Andric   bool EnableSRAMECC;
150e8d8bef9SDimitry Andric 
151e8d8bef9SDimitry Andric   bool HasNoSdstCMPX;
152e8d8bef9SDimitry Andric   bool HasVscnt;
153e8d8bef9SDimitry Andric   bool HasGetWaveIdInst;
154e8d8bef9SDimitry Andric   bool HasSMemTimeInst;
155fe6060f1SDimitry Andric   bool HasShaderCyclesRegister;
156e8d8bef9SDimitry Andric   bool HasRegisterBanking;
157e8d8bef9SDimitry Andric   bool HasVOP3Literal;
158e8d8bef9SDimitry Andric   bool HasNoDataDepHazard;
159e8d8bef9SDimitry Andric   bool FlatAddressSpace;
160e8d8bef9SDimitry Andric   bool FlatInstOffsets;
161e8d8bef9SDimitry Andric   bool FlatGlobalInsts;
162e8d8bef9SDimitry Andric   bool FlatScratchInsts;
163e8d8bef9SDimitry Andric   bool ScalarFlatScratchInsts;
164fe6060f1SDimitry Andric   bool HasArchitectedFlatScratch;
165e8d8bef9SDimitry Andric   bool AddNoCarryInsts;
166e8d8bef9SDimitry Andric   bool HasUnpackedD16VMem;
167e8d8bef9SDimitry Andric   bool LDSMisalignedBug;
168e8d8bef9SDimitry Andric   bool HasMFMAInlineLiteralBug;
169e8d8bef9SDimitry Andric   bool UnalignedBufferAccess;
170e8d8bef9SDimitry Andric   bool UnalignedDSAccess;
171fe6060f1SDimitry Andric   bool HasPackedTID;
172e8d8bef9SDimitry Andric   bool ScalarizeGlobal;
173e8d8bef9SDimitry Andric 
174e8d8bef9SDimitry Andric   bool HasVcmpxPermlaneHazard;
175e8d8bef9SDimitry Andric   bool HasVMEMtoScalarWriteHazard;
176e8d8bef9SDimitry Andric   bool HasSMEMtoVectorWriteHazard;
177e8d8bef9SDimitry Andric   bool HasInstFwdPrefetchBug;
178e8d8bef9SDimitry Andric   bool HasVcmpxExecWARHazard;
179e8d8bef9SDimitry Andric   bool HasLdsBranchVmemWARHazard;
180e8d8bef9SDimitry Andric   bool HasNSAtoVMEMBug;
181fe6060f1SDimitry Andric   bool HasNSAClauseBug;
182e8d8bef9SDimitry Andric   bool HasOffset3fBug;
183e8d8bef9SDimitry Andric   bool HasFlatSegmentOffsetBug;
184e8d8bef9SDimitry Andric   bool HasImageStoreD16Bug;
185e8d8bef9SDimitry Andric   bool HasImageGather4D16Bug;
186e8d8bef9SDimitry Andric 
187e8d8bef9SDimitry Andric   // Dummy feature to use for assembler in tablegen.
188e8d8bef9SDimitry Andric   bool FeatureDisable;
189e8d8bef9SDimitry Andric 
190e8d8bef9SDimitry Andric   SelectionDAGTargetInfo TSInfo;
191e8d8bef9SDimitry Andric private:
192e8d8bef9SDimitry Andric   SIInstrInfo InstrInfo;
193e8d8bef9SDimitry Andric   SITargetLowering TLInfo;
194e8d8bef9SDimitry Andric   SIFrameLowering FrameLowering;
195e8d8bef9SDimitry Andric 
196e8d8bef9SDimitry Andric public:
197e8d8bef9SDimitry Andric   // See COMPUTE_TMPRING_SIZE.WAVESIZE, 13-bit field in units of 256-dword.
198e8d8bef9SDimitry Andric   static const unsigned MaxWaveScratchSize = (256 * 4) * ((1 << 13) - 1);
199e8d8bef9SDimitry Andric 
200e8d8bef9SDimitry Andric   GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
201e8d8bef9SDimitry Andric                const GCNTargetMachine &TM);
202e8d8bef9SDimitry Andric   ~GCNSubtarget() override;
203e8d8bef9SDimitry Andric 
204e8d8bef9SDimitry Andric   GCNSubtarget &initializeSubtargetDependencies(const Triple &TT,
205e8d8bef9SDimitry Andric                                                    StringRef GPU, StringRef FS);
206e8d8bef9SDimitry Andric 
207e8d8bef9SDimitry Andric   const SIInstrInfo *getInstrInfo() const override {
208e8d8bef9SDimitry Andric     return &InstrInfo;
209e8d8bef9SDimitry Andric   }
210e8d8bef9SDimitry Andric 
211e8d8bef9SDimitry Andric   const SIFrameLowering *getFrameLowering() const override {
212e8d8bef9SDimitry Andric     return &FrameLowering;
213e8d8bef9SDimitry Andric   }
214e8d8bef9SDimitry Andric 
215e8d8bef9SDimitry Andric   const SITargetLowering *getTargetLowering() const override {
216e8d8bef9SDimitry Andric     return &TLInfo;
217e8d8bef9SDimitry Andric   }
218e8d8bef9SDimitry Andric 
219e8d8bef9SDimitry Andric   const SIRegisterInfo *getRegisterInfo() const override {
220e8d8bef9SDimitry Andric     return &InstrInfo.getRegisterInfo();
221e8d8bef9SDimitry Andric   }
222e8d8bef9SDimitry Andric 
223e8d8bef9SDimitry Andric   const CallLowering *getCallLowering() const override {
224e8d8bef9SDimitry Andric     return CallLoweringInfo.get();
225e8d8bef9SDimitry Andric   }
226e8d8bef9SDimitry Andric 
227e8d8bef9SDimitry Andric   const InlineAsmLowering *getInlineAsmLowering() const override {
228e8d8bef9SDimitry Andric     return InlineAsmLoweringInfo.get();
229e8d8bef9SDimitry Andric   }
230e8d8bef9SDimitry Andric 
231e8d8bef9SDimitry Andric   InstructionSelector *getInstructionSelector() const override {
232e8d8bef9SDimitry Andric     return InstSelector.get();
233e8d8bef9SDimitry Andric   }
234e8d8bef9SDimitry Andric 
235e8d8bef9SDimitry Andric   const LegalizerInfo *getLegalizerInfo() const override {
236e8d8bef9SDimitry Andric     return Legalizer.get();
237e8d8bef9SDimitry Andric   }
238e8d8bef9SDimitry Andric 
239e8d8bef9SDimitry Andric   const RegisterBankInfo *getRegBankInfo() const override {
240e8d8bef9SDimitry Andric     return RegBankInfo.get();
241e8d8bef9SDimitry Andric   }
242e8d8bef9SDimitry Andric 
243fe6060f1SDimitry Andric   const AMDGPU::IsaInfo::AMDGPUTargetID &getTargetID() const {
244fe6060f1SDimitry Andric     return TargetID;
245fe6060f1SDimitry Andric   }
246fe6060f1SDimitry Andric 
247e8d8bef9SDimitry Andric   // Nothing implemented, just prevent crashes on use.
248e8d8bef9SDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
249e8d8bef9SDimitry Andric     return &TSInfo;
250e8d8bef9SDimitry Andric   }
251e8d8bef9SDimitry Andric 
252e8d8bef9SDimitry Andric   const InstrItineraryData *getInstrItineraryData() const override {
253e8d8bef9SDimitry Andric     return &InstrItins;
254e8d8bef9SDimitry Andric   }
255e8d8bef9SDimitry Andric 
256e8d8bef9SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
257e8d8bef9SDimitry Andric 
258e8d8bef9SDimitry Andric   Generation getGeneration() const {
259e8d8bef9SDimitry Andric     return (Generation)Gen;
260e8d8bef9SDimitry Andric   }
261e8d8bef9SDimitry Andric 
262*349cc55cSDimitry Andric   /// Return the number of high bits known to be zero for a frame index.
263e8d8bef9SDimitry Andric   unsigned getKnownHighZeroBitsForFrameIndex() const {
264e8d8bef9SDimitry Andric     return countLeadingZeros(MaxWaveScratchSize) + getWavefrontSizeLog2();
265e8d8bef9SDimitry Andric   }
266e8d8bef9SDimitry Andric 
267e8d8bef9SDimitry Andric   int getLDSBankCount() const {
268e8d8bef9SDimitry Andric     return LDSBankCount;
269e8d8bef9SDimitry Andric   }
270e8d8bef9SDimitry Andric 
271e8d8bef9SDimitry Andric   unsigned getMaxPrivateElementSize(bool ForBufferRSrc = false) const {
272e8d8bef9SDimitry Andric     return (ForBufferRSrc || !enableFlatScratch()) ? MaxPrivateElementSize : 16;
273e8d8bef9SDimitry Andric   }
274e8d8bef9SDimitry Andric 
275e8d8bef9SDimitry Andric   unsigned getConstantBusLimit(unsigned Opcode) const;
276e8d8bef9SDimitry Andric 
277fe6060f1SDimitry Andric   /// Returns if the result of this instruction with a 16-bit result returned in
278fe6060f1SDimitry Andric   /// a 32-bit register implicitly zeroes the high 16-bits, rather than preserve
279fe6060f1SDimitry Andric   /// the original value.
280fe6060f1SDimitry Andric   bool zeroesHigh16BitsOfDest(unsigned Opcode) const;
281fe6060f1SDimitry Andric 
282e8d8bef9SDimitry Andric   bool hasIntClamp() const {
283e8d8bef9SDimitry Andric     return HasIntClamp;
284e8d8bef9SDimitry Andric   }
285e8d8bef9SDimitry Andric 
286e8d8bef9SDimitry Andric   bool hasFP64() const {
287e8d8bef9SDimitry Andric     return FP64;
288e8d8bef9SDimitry Andric   }
289e8d8bef9SDimitry Andric 
290e8d8bef9SDimitry Andric   bool hasMIMG_R128() const {
291e8d8bef9SDimitry Andric     return MIMG_R128;
292e8d8bef9SDimitry Andric   }
293e8d8bef9SDimitry Andric 
294e8d8bef9SDimitry Andric   bool hasHWFP64() const {
295e8d8bef9SDimitry Andric     return FP64;
296e8d8bef9SDimitry Andric   }
297e8d8bef9SDimitry Andric 
298e8d8bef9SDimitry Andric   bool hasFastFMAF32() const {
299e8d8bef9SDimitry Andric     return FastFMAF32;
300e8d8bef9SDimitry Andric   }
301e8d8bef9SDimitry Andric 
302e8d8bef9SDimitry Andric   bool hasHalfRate64Ops() const {
303e8d8bef9SDimitry Andric     return HalfRate64Ops;
304e8d8bef9SDimitry Andric   }
305e8d8bef9SDimitry Andric 
306fe6060f1SDimitry Andric   bool hasFullRate64Ops() const {
307fe6060f1SDimitry Andric     return FullRate64Ops;
308fe6060f1SDimitry Andric   }
309fe6060f1SDimitry Andric 
310e8d8bef9SDimitry Andric   bool hasAddr64() const {
311e8d8bef9SDimitry Andric     return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS);
312e8d8bef9SDimitry Andric   }
313e8d8bef9SDimitry Andric 
314e8d8bef9SDimitry Andric   bool hasFlat() const {
315e8d8bef9SDimitry Andric     return (getGeneration() > AMDGPUSubtarget::SOUTHERN_ISLANDS);
316e8d8bef9SDimitry Andric   }
317e8d8bef9SDimitry Andric 
318e8d8bef9SDimitry Andric   // Return true if the target only has the reverse operand versions of VALU
319e8d8bef9SDimitry Andric   // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
320e8d8bef9SDimitry Andric   bool hasOnlyRevVALUShifts() const {
321e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
322e8d8bef9SDimitry Andric   }
323e8d8bef9SDimitry Andric 
324e8d8bef9SDimitry Andric   bool hasFractBug() const {
325e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
326e8d8bef9SDimitry Andric   }
327e8d8bef9SDimitry Andric 
328e8d8bef9SDimitry Andric   bool hasBFE() const {
329e8d8bef9SDimitry Andric     return true;
330e8d8bef9SDimitry Andric   }
331e8d8bef9SDimitry Andric 
332e8d8bef9SDimitry Andric   bool hasBFI() const {
333e8d8bef9SDimitry Andric     return true;
334e8d8bef9SDimitry Andric   }
335e8d8bef9SDimitry Andric 
336e8d8bef9SDimitry Andric   bool hasBFM() const {
337e8d8bef9SDimitry Andric     return hasBFE();
338e8d8bef9SDimitry Andric   }
339e8d8bef9SDimitry Andric 
340e8d8bef9SDimitry Andric   bool hasBCNT(unsigned Size) const {
341e8d8bef9SDimitry Andric     return true;
342e8d8bef9SDimitry Andric   }
343e8d8bef9SDimitry Andric 
344e8d8bef9SDimitry Andric   bool hasFFBL() const {
345e8d8bef9SDimitry Andric     return true;
346e8d8bef9SDimitry Andric   }
347e8d8bef9SDimitry Andric 
348e8d8bef9SDimitry Andric   bool hasFFBH() const {
349e8d8bef9SDimitry Andric     return true;
350e8d8bef9SDimitry Andric   }
351e8d8bef9SDimitry Andric 
352e8d8bef9SDimitry Andric   bool hasMed3_16() const {
353e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
354e8d8bef9SDimitry Andric   }
355e8d8bef9SDimitry Andric 
356e8d8bef9SDimitry Andric   bool hasMin3Max3_16() const {
357e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
358e8d8bef9SDimitry Andric   }
359e8d8bef9SDimitry Andric 
360e8d8bef9SDimitry Andric   bool hasFmaMixInsts() const {
361e8d8bef9SDimitry Andric     return HasFmaMixInsts;
362e8d8bef9SDimitry Andric   }
363e8d8bef9SDimitry Andric 
364e8d8bef9SDimitry Andric   bool hasCARRY() const {
365e8d8bef9SDimitry Andric     return true;
366e8d8bef9SDimitry Andric   }
367e8d8bef9SDimitry Andric 
368e8d8bef9SDimitry Andric   bool hasFMA() const {
369e8d8bef9SDimitry Andric     return FMA;
370e8d8bef9SDimitry Andric   }
371e8d8bef9SDimitry Andric 
372e8d8bef9SDimitry Andric   bool hasSwap() const {
373e8d8bef9SDimitry Andric     return GFX9Insts;
374e8d8bef9SDimitry Andric   }
375e8d8bef9SDimitry Andric 
376e8d8bef9SDimitry Andric   bool hasScalarPackInsts() const {
377e8d8bef9SDimitry Andric     return GFX9Insts;
378e8d8bef9SDimitry Andric   }
379e8d8bef9SDimitry Andric 
380e8d8bef9SDimitry Andric   bool hasScalarMulHiInsts() const {
381e8d8bef9SDimitry Andric     return GFX9Insts;
382e8d8bef9SDimitry Andric   }
383e8d8bef9SDimitry Andric 
384e8d8bef9SDimitry Andric   TrapHandlerAbi getTrapHandlerAbi() const {
385fe6060f1SDimitry Andric     return isAmdHsaOS() ? TrapHandlerAbi::AMDHSA : TrapHandlerAbi::NONE;
386fe6060f1SDimitry Andric   }
387fe6060f1SDimitry Andric 
388fe6060f1SDimitry Andric   bool supportsGetDoorbellID() const {
389fe6060f1SDimitry Andric     // The S_GETREG DOORBELL_ID is supported by all GFX9 onward targets.
390fe6060f1SDimitry Andric     return getGeneration() >= GFX9;
391e8d8bef9SDimitry Andric   }
392e8d8bef9SDimitry Andric 
393e8d8bef9SDimitry Andric   /// True if the offset field of DS instructions works as expected. On SI, the
394e8d8bef9SDimitry Andric   /// offset uses a 16-bit adder and does not always wrap properly.
395e8d8bef9SDimitry Andric   bool hasUsableDSOffset() const {
396e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
397e8d8bef9SDimitry Andric   }
398e8d8bef9SDimitry Andric 
399e8d8bef9SDimitry Andric   bool unsafeDSOffsetFoldingEnabled() const {
400e8d8bef9SDimitry Andric     return EnableUnsafeDSOffsetFolding;
401e8d8bef9SDimitry Andric   }
402e8d8bef9SDimitry Andric 
403e8d8bef9SDimitry Andric   /// Condition output from div_scale is usable.
404e8d8bef9SDimitry Andric   bool hasUsableDivScaleConditionOutput() const {
405e8d8bef9SDimitry Andric     return getGeneration() != SOUTHERN_ISLANDS;
406e8d8bef9SDimitry Andric   }
407e8d8bef9SDimitry Andric 
408e8d8bef9SDimitry Andric   /// Extra wait hazard is needed in some cases before
409e8d8bef9SDimitry Andric   /// s_cbranch_vccnz/s_cbranch_vccz.
410e8d8bef9SDimitry Andric   bool hasReadVCCZBug() const {
411e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS;
412e8d8bef9SDimitry Andric   }
413e8d8bef9SDimitry Andric 
414e8d8bef9SDimitry Andric   /// Writes to VCC_LO/VCC_HI update the VCCZ flag.
415e8d8bef9SDimitry Andric   bool partialVCCWritesUpdateVCCZ() const {
416e8d8bef9SDimitry Andric     return getGeneration() >= GFX10;
417e8d8bef9SDimitry Andric   }
418e8d8bef9SDimitry Andric 
419e8d8bef9SDimitry Andric   /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
420e8d8bef9SDimitry Andric   /// was written by a VALU instruction.
421e8d8bef9SDimitry Andric   bool hasSMRDReadVALUDefHazard() const {
422e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
423e8d8bef9SDimitry Andric   }
424e8d8bef9SDimitry Andric 
425e8d8bef9SDimitry Andric   /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
426e8d8bef9SDimitry Andric   /// SGPR was written by a VALU Instruction.
427e8d8bef9SDimitry Andric   bool hasVMEMReadSGPRVALUDefHazard() const {
428e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
429e8d8bef9SDimitry Andric   }
430e8d8bef9SDimitry Andric 
431e8d8bef9SDimitry Andric   bool hasRFEHazards() const {
432e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
433e8d8bef9SDimitry Andric   }
434e8d8bef9SDimitry Andric 
435e8d8bef9SDimitry Andric   /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
436e8d8bef9SDimitry Andric   unsigned getSetRegWaitStates() const {
437e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS ? 1 : 2;
438e8d8bef9SDimitry Andric   }
439e8d8bef9SDimitry Andric 
440e8d8bef9SDimitry Andric   bool dumpCode() const {
441e8d8bef9SDimitry Andric     return DumpCode;
442e8d8bef9SDimitry Andric   }
443e8d8bef9SDimitry Andric 
444e8d8bef9SDimitry Andric   /// Return the amount of LDS that can be used that will not restrict the
445e8d8bef9SDimitry Andric   /// occupancy lower than WaveCount.
446e8d8bef9SDimitry Andric   unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
447e8d8bef9SDimitry Andric                                            const Function &) const;
448e8d8bef9SDimitry Andric 
449e8d8bef9SDimitry Andric   bool supportsMinMaxDenormModes() const {
450e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
451e8d8bef9SDimitry Andric   }
452e8d8bef9SDimitry Andric 
453e8d8bef9SDimitry Andric   /// \returns If target supports S_DENORM_MODE.
454e8d8bef9SDimitry Andric   bool hasDenormModeInst() const {
455e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX10;
456e8d8bef9SDimitry Andric   }
457e8d8bef9SDimitry Andric 
458e8d8bef9SDimitry Andric   bool useFlatForGlobal() const {
459e8d8bef9SDimitry Andric     return FlatForGlobal;
460e8d8bef9SDimitry Andric   }
461e8d8bef9SDimitry Andric 
462e8d8bef9SDimitry Andric   /// \returns If target supports ds_read/write_b128 and user enables generation
463e8d8bef9SDimitry Andric   /// of ds_read/write_b128.
464e8d8bef9SDimitry Andric   bool useDS128() const {
465e8d8bef9SDimitry Andric     return CIInsts && EnableDS128;
466e8d8bef9SDimitry Andric   }
467e8d8bef9SDimitry Andric 
468e8d8bef9SDimitry Andric   /// \return If target supports ds_read/write_b96/128.
469e8d8bef9SDimitry Andric   bool hasDS96AndDS128() const {
470e8d8bef9SDimitry Andric     return CIInsts;
471e8d8bef9SDimitry Andric   }
472e8d8bef9SDimitry Andric 
473e8d8bef9SDimitry Andric   /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
474e8d8bef9SDimitry Andric   bool haveRoundOpsF64() const {
475e8d8bef9SDimitry Andric     return CIInsts;
476e8d8bef9SDimitry Andric   }
477e8d8bef9SDimitry Andric 
478e8d8bef9SDimitry Andric   /// \returns If MUBUF instructions always perform range checking, even for
479e8d8bef9SDimitry Andric   /// buffer resources used for private memory access.
480e8d8bef9SDimitry Andric   bool privateMemoryResourceIsRangeChecked() const {
481e8d8bef9SDimitry Andric     return getGeneration() < AMDGPUSubtarget::GFX9;
482e8d8bef9SDimitry Andric   }
483e8d8bef9SDimitry Andric 
484e8d8bef9SDimitry Andric   /// \returns If target requires PRT Struct NULL support (zero result registers
485e8d8bef9SDimitry Andric   /// for sparse texture support).
486e8d8bef9SDimitry Andric   bool usePRTStrictNull() const {
487e8d8bef9SDimitry Andric     return EnablePRTStrictNull;
488e8d8bef9SDimitry Andric   }
489e8d8bef9SDimitry Andric 
490e8d8bef9SDimitry Andric   bool hasAutoWaitcntBeforeBarrier() const {
491e8d8bef9SDimitry Andric     return AutoWaitcntBeforeBarrier;
492e8d8bef9SDimitry Andric   }
493e8d8bef9SDimitry Andric 
494e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccess() const {
495e8d8bef9SDimitry Andric     return UnalignedBufferAccess;
496e8d8bef9SDimitry Andric   }
497e8d8bef9SDimitry Andric 
498e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccessEnabled() const {
499e8d8bef9SDimitry Andric     return UnalignedBufferAccess && UnalignedAccessMode;
500e8d8bef9SDimitry Andric   }
501e8d8bef9SDimitry Andric 
502e8d8bef9SDimitry Andric   bool hasUnalignedDSAccess() const {
503e8d8bef9SDimitry Andric     return UnalignedDSAccess;
504e8d8bef9SDimitry Andric   }
505e8d8bef9SDimitry Andric 
506e8d8bef9SDimitry Andric   bool hasUnalignedDSAccessEnabled() const {
507e8d8bef9SDimitry Andric     return UnalignedDSAccess && UnalignedAccessMode;
508e8d8bef9SDimitry Andric   }
509e8d8bef9SDimitry Andric 
510e8d8bef9SDimitry Andric   bool hasUnalignedScratchAccess() const {
511e8d8bef9SDimitry Andric     return UnalignedScratchAccess;
512e8d8bef9SDimitry Andric   }
513e8d8bef9SDimitry Andric 
514e8d8bef9SDimitry Andric   bool hasUnalignedAccessMode() const {
515e8d8bef9SDimitry Andric     return UnalignedAccessMode;
516e8d8bef9SDimitry Andric   }
517e8d8bef9SDimitry Andric 
518e8d8bef9SDimitry Andric   bool hasApertureRegs() const {
519e8d8bef9SDimitry Andric     return HasApertureRegs;
520e8d8bef9SDimitry Andric   }
521e8d8bef9SDimitry Andric 
522e8d8bef9SDimitry Andric   bool isTrapHandlerEnabled() const {
523e8d8bef9SDimitry Andric     return TrapHandler;
524e8d8bef9SDimitry Andric   }
525e8d8bef9SDimitry Andric 
526e8d8bef9SDimitry Andric   bool isXNACKEnabled() const {
527e8d8bef9SDimitry Andric     return TargetID.isXnackOnOrAny();
528e8d8bef9SDimitry Andric   }
529e8d8bef9SDimitry Andric 
530fe6060f1SDimitry Andric   bool isTgSplitEnabled() const {
531fe6060f1SDimitry Andric     return EnableTgSplit;
532fe6060f1SDimitry Andric   }
533fe6060f1SDimitry Andric 
534e8d8bef9SDimitry Andric   bool isCuModeEnabled() const {
535e8d8bef9SDimitry Andric     return EnableCuMode;
536e8d8bef9SDimitry Andric   }
537e8d8bef9SDimitry Andric 
538e8d8bef9SDimitry Andric   bool hasFlatAddressSpace() const {
539e8d8bef9SDimitry Andric     return FlatAddressSpace;
540e8d8bef9SDimitry Andric   }
541e8d8bef9SDimitry Andric 
542e8d8bef9SDimitry Andric   bool hasFlatScrRegister() const {
543e8d8bef9SDimitry Andric     return hasFlatAddressSpace();
544e8d8bef9SDimitry Andric   }
545e8d8bef9SDimitry Andric 
546e8d8bef9SDimitry Andric   bool hasFlatInstOffsets() const {
547e8d8bef9SDimitry Andric     return FlatInstOffsets;
548e8d8bef9SDimitry Andric   }
549e8d8bef9SDimitry Andric 
550e8d8bef9SDimitry Andric   bool hasFlatGlobalInsts() const {
551e8d8bef9SDimitry Andric     return FlatGlobalInsts;
552e8d8bef9SDimitry Andric   }
553e8d8bef9SDimitry Andric 
554e8d8bef9SDimitry Andric   bool hasFlatScratchInsts() const {
555e8d8bef9SDimitry Andric     return FlatScratchInsts;
556e8d8bef9SDimitry Andric   }
557e8d8bef9SDimitry Andric 
558e8d8bef9SDimitry Andric   // Check if target supports ST addressing mode with FLAT scratch instructions.
559e8d8bef9SDimitry Andric   // The ST addressing mode means no registers are used, either VGPR or SGPR,
560e8d8bef9SDimitry Andric   // but only immediate offset is swizzled and added to the FLAT scratch base.
561e8d8bef9SDimitry Andric   bool hasFlatScratchSTMode() const {
562e8d8bef9SDimitry Andric     return hasFlatScratchInsts() && hasGFX10_3Insts();
563e8d8bef9SDimitry Andric   }
564e8d8bef9SDimitry Andric 
565e8d8bef9SDimitry Andric   bool hasScalarFlatScratchInsts() const {
566e8d8bef9SDimitry Andric     return ScalarFlatScratchInsts;
567e8d8bef9SDimitry Andric   }
568e8d8bef9SDimitry Andric 
569e8d8bef9SDimitry Andric   bool hasGlobalAddTidInsts() const {
570e8d8bef9SDimitry Andric     return GFX10_BEncoding;
571e8d8bef9SDimitry Andric   }
572e8d8bef9SDimitry Andric 
573e8d8bef9SDimitry Andric   bool hasAtomicCSub() const {
574e8d8bef9SDimitry Andric     return GFX10_BEncoding;
575e8d8bef9SDimitry Andric   }
576e8d8bef9SDimitry Andric 
577e8d8bef9SDimitry Andric   bool hasMultiDwordFlatScratchAddressing() const {
578e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
579e8d8bef9SDimitry Andric   }
580e8d8bef9SDimitry Andric 
581e8d8bef9SDimitry Andric   bool hasFlatSegmentOffsetBug() const {
582e8d8bef9SDimitry Andric     return HasFlatSegmentOffsetBug;
583e8d8bef9SDimitry Andric   }
584e8d8bef9SDimitry Andric 
585e8d8bef9SDimitry Andric   bool hasFlatLgkmVMemCountInOrder() const {
586e8d8bef9SDimitry Andric     return getGeneration() > GFX9;
587e8d8bef9SDimitry Andric   }
588e8d8bef9SDimitry Andric 
589e8d8bef9SDimitry Andric   bool hasD16LoadStore() const {
590e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
591e8d8bef9SDimitry Andric   }
592e8d8bef9SDimitry Andric 
593e8d8bef9SDimitry Andric   bool d16PreservesUnusedBits() const {
594e8d8bef9SDimitry Andric     return hasD16LoadStore() && !TargetID.isSramEccOnOrAny();
595e8d8bef9SDimitry Andric   }
596e8d8bef9SDimitry Andric 
597e8d8bef9SDimitry Andric   bool hasD16Images() const {
598e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
599e8d8bef9SDimitry Andric   }
600e8d8bef9SDimitry Andric 
601e8d8bef9SDimitry Andric   /// Return if most LDS instructions have an m0 use that require m0 to be
602*349cc55cSDimitry Andric   /// initialized.
603e8d8bef9SDimitry Andric   bool ldsRequiresM0Init() const {
604e8d8bef9SDimitry Andric     return getGeneration() < GFX9;
605e8d8bef9SDimitry Andric   }
606e8d8bef9SDimitry Andric 
607e8d8bef9SDimitry Andric   // True if the hardware rewinds and replays GWS operations if a wave is
608e8d8bef9SDimitry Andric   // preempted.
609e8d8bef9SDimitry Andric   //
610e8d8bef9SDimitry Andric   // If this is false, a GWS operation requires testing if a nack set the
611e8d8bef9SDimitry Andric   // MEM_VIOL bit, and repeating if so.
612e8d8bef9SDimitry Andric   bool hasGWSAutoReplay() const {
613e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
614e8d8bef9SDimitry Andric   }
615e8d8bef9SDimitry Andric 
616e8d8bef9SDimitry Andric   /// \returns if target has ds_gws_sema_release_all instruction.
617e8d8bef9SDimitry Andric   bool hasGWSSemaReleaseAll() const {
618e8d8bef9SDimitry Andric     return CIInsts;
619e8d8bef9SDimitry Andric   }
620e8d8bef9SDimitry Andric 
621e8d8bef9SDimitry Andric   /// \returns true if the target has integer add/sub instructions that do not
622e8d8bef9SDimitry Andric   /// produce a carry-out. This includes v_add_[iu]32, v_sub_[iu]32,
623e8d8bef9SDimitry Andric   /// v_add_[iu]16, and v_sub_[iu]16, all of which support the clamp modifier
624e8d8bef9SDimitry Andric   /// for saturation.
625e8d8bef9SDimitry Andric   bool hasAddNoCarry() const {
626e8d8bef9SDimitry Andric     return AddNoCarryInsts;
627e8d8bef9SDimitry Andric   }
628e8d8bef9SDimitry Andric 
629e8d8bef9SDimitry Andric   bool hasUnpackedD16VMem() const {
630e8d8bef9SDimitry Andric     return HasUnpackedD16VMem;
631e8d8bef9SDimitry Andric   }
632e8d8bef9SDimitry Andric 
633e8d8bef9SDimitry Andric   // Covers VS/PS/CS graphics shaders
634e8d8bef9SDimitry Andric   bool isMesaGfxShader(const Function &F) const {
635e8d8bef9SDimitry Andric     return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
636e8d8bef9SDimitry Andric   }
637e8d8bef9SDimitry Andric 
638e8d8bef9SDimitry Andric   bool hasMad64_32() const {
639e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
640e8d8bef9SDimitry Andric   }
641e8d8bef9SDimitry Andric 
642e8d8bef9SDimitry Andric   bool hasSDWAOmod() const {
643e8d8bef9SDimitry Andric     return HasSDWAOmod;
644e8d8bef9SDimitry Andric   }
645e8d8bef9SDimitry Andric 
646e8d8bef9SDimitry Andric   bool hasSDWAScalar() const {
647e8d8bef9SDimitry Andric     return HasSDWAScalar;
648e8d8bef9SDimitry Andric   }
649e8d8bef9SDimitry Andric 
650e8d8bef9SDimitry Andric   bool hasSDWASdst() const {
651e8d8bef9SDimitry Andric     return HasSDWASdst;
652e8d8bef9SDimitry Andric   }
653e8d8bef9SDimitry Andric 
654e8d8bef9SDimitry Andric   bool hasSDWAMac() const {
655e8d8bef9SDimitry Andric     return HasSDWAMac;
656e8d8bef9SDimitry Andric   }
657e8d8bef9SDimitry Andric 
658e8d8bef9SDimitry Andric   bool hasSDWAOutModsVOPC() const {
659e8d8bef9SDimitry Andric     return HasSDWAOutModsVOPC;
660e8d8bef9SDimitry Andric   }
661e8d8bef9SDimitry Andric 
662e8d8bef9SDimitry Andric   bool hasDLInsts() const {
663e8d8bef9SDimitry Andric     return HasDLInsts;
664e8d8bef9SDimitry Andric   }
665e8d8bef9SDimitry Andric 
666e8d8bef9SDimitry Andric   bool hasDot1Insts() const {
667e8d8bef9SDimitry Andric     return HasDot1Insts;
668e8d8bef9SDimitry Andric   }
669e8d8bef9SDimitry Andric 
670e8d8bef9SDimitry Andric   bool hasDot2Insts() const {
671e8d8bef9SDimitry Andric     return HasDot2Insts;
672e8d8bef9SDimitry Andric   }
673e8d8bef9SDimitry Andric 
674e8d8bef9SDimitry Andric   bool hasDot3Insts() const {
675e8d8bef9SDimitry Andric     return HasDot3Insts;
676e8d8bef9SDimitry Andric   }
677e8d8bef9SDimitry Andric 
678e8d8bef9SDimitry Andric   bool hasDot4Insts() const {
679e8d8bef9SDimitry Andric     return HasDot4Insts;
680e8d8bef9SDimitry Andric   }
681e8d8bef9SDimitry Andric 
682e8d8bef9SDimitry Andric   bool hasDot5Insts() const {
683e8d8bef9SDimitry Andric     return HasDot5Insts;
684e8d8bef9SDimitry Andric   }
685e8d8bef9SDimitry Andric 
686e8d8bef9SDimitry Andric   bool hasDot6Insts() const {
687e8d8bef9SDimitry Andric     return HasDot6Insts;
688e8d8bef9SDimitry Andric   }
689e8d8bef9SDimitry Andric 
690fe6060f1SDimitry Andric   bool hasDot7Insts() const {
691fe6060f1SDimitry Andric     return HasDot7Insts;
692fe6060f1SDimitry Andric   }
693fe6060f1SDimitry Andric 
694e8d8bef9SDimitry Andric   bool hasMAIInsts() const {
695e8d8bef9SDimitry Andric     return HasMAIInsts;
696e8d8bef9SDimitry Andric   }
697e8d8bef9SDimitry Andric 
698e8d8bef9SDimitry Andric   bool hasPkFmacF16Inst() const {
699e8d8bef9SDimitry Andric     return HasPkFmacF16Inst;
700e8d8bef9SDimitry Andric   }
701e8d8bef9SDimitry Andric 
702e8d8bef9SDimitry Andric   bool hasAtomicFaddInsts() const {
703e8d8bef9SDimitry Andric     return HasAtomicFaddInsts;
704e8d8bef9SDimitry Andric   }
705e8d8bef9SDimitry Andric 
706e8d8bef9SDimitry Andric   bool hasNoSdstCMPX() const {
707e8d8bef9SDimitry Andric     return HasNoSdstCMPX;
708e8d8bef9SDimitry Andric   }
709e8d8bef9SDimitry Andric 
710e8d8bef9SDimitry Andric   bool hasVscnt() const {
711e8d8bef9SDimitry Andric     return HasVscnt;
712e8d8bef9SDimitry Andric   }
713e8d8bef9SDimitry Andric 
714e8d8bef9SDimitry Andric   bool hasGetWaveIdInst() const {
715e8d8bef9SDimitry Andric     return HasGetWaveIdInst;
716e8d8bef9SDimitry Andric   }
717e8d8bef9SDimitry Andric 
718e8d8bef9SDimitry Andric   bool hasSMemTimeInst() const {
719e8d8bef9SDimitry Andric     return HasSMemTimeInst;
720e8d8bef9SDimitry Andric   }
721e8d8bef9SDimitry Andric 
722fe6060f1SDimitry Andric   bool hasShaderCyclesRegister() const {
723fe6060f1SDimitry Andric     return HasShaderCyclesRegister;
724fe6060f1SDimitry Andric   }
725fe6060f1SDimitry Andric 
726e8d8bef9SDimitry Andric   bool hasRegisterBanking() const {
727e8d8bef9SDimitry Andric     return HasRegisterBanking;
728e8d8bef9SDimitry Andric   }
729e8d8bef9SDimitry Andric 
730e8d8bef9SDimitry Andric   bool hasVOP3Literal() const {
731e8d8bef9SDimitry Andric     return HasVOP3Literal;
732e8d8bef9SDimitry Andric   }
733e8d8bef9SDimitry Andric 
734e8d8bef9SDimitry Andric   bool hasNoDataDepHazard() const {
735e8d8bef9SDimitry Andric     return HasNoDataDepHazard;
736e8d8bef9SDimitry Andric   }
737e8d8bef9SDimitry Andric 
738e8d8bef9SDimitry Andric   bool vmemWriteNeedsExpWaitcnt() const {
739e8d8bef9SDimitry Andric     return getGeneration() < SEA_ISLANDS;
740e8d8bef9SDimitry Andric   }
741e8d8bef9SDimitry Andric 
742e8d8bef9SDimitry Andric   // Scratch is allocated in 256 dword per wave blocks for the entire
743*349cc55cSDimitry Andric   // wavefront. When viewed from the perspective of an arbitrary workitem, this
744e8d8bef9SDimitry Andric   // is 4-byte aligned.
745e8d8bef9SDimitry Andric   //
746e8d8bef9SDimitry Andric   // Only 4-byte alignment is really needed to access anything. Transformations
747e8d8bef9SDimitry Andric   // on the pointer value itself may rely on the alignment / known low bits of
748e8d8bef9SDimitry Andric   // the pointer. Set this to something above the minimum to avoid needing
749e8d8bef9SDimitry Andric   // dynamic realignment in common cases.
750e8d8bef9SDimitry Andric   Align getStackAlignment() const { return Align(16); }
751e8d8bef9SDimitry Andric 
752e8d8bef9SDimitry Andric   bool enableMachineScheduler() const override {
753e8d8bef9SDimitry Andric     return true;
754e8d8bef9SDimitry Andric   }
755e8d8bef9SDimitry Andric 
756e8d8bef9SDimitry Andric   bool useAA() const override;
757e8d8bef9SDimitry Andric 
758e8d8bef9SDimitry Andric   bool enableSubRegLiveness() const override {
759e8d8bef9SDimitry Andric     return true;
760e8d8bef9SDimitry Andric   }
761e8d8bef9SDimitry Andric 
762e8d8bef9SDimitry Andric   void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; }
763e8d8bef9SDimitry Andric   bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; }
764e8d8bef9SDimitry Andric 
765e8d8bef9SDimitry Andric   // static wrappers
766e8d8bef9SDimitry Andric   static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
767e8d8bef9SDimitry Andric 
768e8d8bef9SDimitry Andric   // XXX - Why is this here if it isn't in the default pass set?
769e8d8bef9SDimitry Andric   bool enableEarlyIfConversion() const override {
770e8d8bef9SDimitry Andric     return true;
771e8d8bef9SDimitry Andric   }
772e8d8bef9SDimitry Andric 
773e8d8bef9SDimitry Andric   bool enableFlatScratch() const;
774e8d8bef9SDimitry Andric 
775e8d8bef9SDimitry Andric   void overrideSchedPolicy(MachineSchedPolicy &Policy,
776e8d8bef9SDimitry Andric                            unsigned NumRegionInstrs) const override;
777e8d8bef9SDimitry Andric 
778e8d8bef9SDimitry Andric   unsigned getMaxNumUserSGPRs() const {
779e8d8bef9SDimitry Andric     return 16;
780e8d8bef9SDimitry Andric   }
781e8d8bef9SDimitry Andric 
782e8d8bef9SDimitry Andric   bool hasSMemRealTime() const {
783e8d8bef9SDimitry Andric     return HasSMemRealTime;
784e8d8bef9SDimitry Andric   }
785e8d8bef9SDimitry Andric 
786e8d8bef9SDimitry Andric   bool hasMovrel() const {
787e8d8bef9SDimitry Andric     return HasMovrel;
788e8d8bef9SDimitry Andric   }
789e8d8bef9SDimitry Andric 
790e8d8bef9SDimitry Andric   bool hasVGPRIndexMode() const {
791e8d8bef9SDimitry Andric     return HasVGPRIndexMode;
792e8d8bef9SDimitry Andric   }
793e8d8bef9SDimitry Andric 
794e8d8bef9SDimitry Andric   bool useVGPRIndexMode() const;
795e8d8bef9SDimitry Andric 
796e8d8bef9SDimitry Andric   bool hasScalarCompareEq64() const {
797e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
798e8d8bef9SDimitry Andric   }
799e8d8bef9SDimitry Andric 
800e8d8bef9SDimitry Andric   bool hasScalarStores() const {
801e8d8bef9SDimitry Andric     return HasScalarStores;
802e8d8bef9SDimitry Andric   }
803e8d8bef9SDimitry Andric 
804e8d8bef9SDimitry Andric   bool hasScalarAtomics() const {
805e8d8bef9SDimitry Andric     return HasScalarAtomics;
806e8d8bef9SDimitry Andric   }
807e8d8bef9SDimitry Andric 
808*349cc55cSDimitry Andric   bool hasLDSFPAtomicAdd() const { return GFX8Insts; }
809e8d8bef9SDimitry Andric 
810fe6060f1SDimitry Andric   /// \returns true if the subtarget has the v_permlanex16_b32 instruction.
811fe6060f1SDimitry Andric   bool hasPermLaneX16() const { return getGeneration() >= GFX10; }
812fe6060f1SDimitry Andric 
813e8d8bef9SDimitry Andric   bool hasDPP() const {
814e8d8bef9SDimitry Andric     return HasDPP;
815e8d8bef9SDimitry Andric   }
816e8d8bef9SDimitry Andric 
817e8d8bef9SDimitry Andric   bool hasDPPBroadcasts() const {
818e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
819e8d8bef9SDimitry Andric   }
820e8d8bef9SDimitry Andric 
821e8d8bef9SDimitry Andric   bool hasDPPWavefrontShifts() const {
822e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
823e8d8bef9SDimitry Andric   }
824e8d8bef9SDimitry Andric 
825e8d8bef9SDimitry Andric   bool hasDPP8() const {
826e8d8bef9SDimitry Andric     return HasDPP8;
827e8d8bef9SDimitry Andric   }
828e8d8bef9SDimitry Andric 
829fe6060f1SDimitry Andric   bool has64BitDPP() const {
830fe6060f1SDimitry Andric     return Has64BitDPP;
831fe6060f1SDimitry Andric   }
832fe6060f1SDimitry Andric 
833fe6060f1SDimitry Andric   bool hasPackedFP32Ops() const {
834fe6060f1SDimitry Andric     return HasPackedFP32Ops;
835fe6060f1SDimitry Andric   }
836fe6060f1SDimitry Andric 
837fe6060f1SDimitry Andric   bool hasFmaakFmamkF32Insts() const {
838fe6060f1SDimitry Andric     return getGeneration() >= GFX10;
839fe6060f1SDimitry Andric   }
840fe6060f1SDimitry Andric 
841fe6060f1SDimitry Andric   bool hasExtendedImageInsts() const {
842fe6060f1SDimitry Andric     return HasExtendedImageInsts;
843fe6060f1SDimitry Andric   }
844fe6060f1SDimitry Andric 
845e8d8bef9SDimitry Andric   bool hasR128A16() const {
846e8d8bef9SDimitry Andric     return HasR128A16;
847e8d8bef9SDimitry Andric   }
848e8d8bef9SDimitry Andric 
849e8d8bef9SDimitry Andric   bool hasGFX10A16() const {
850e8d8bef9SDimitry Andric     return HasGFX10A16;
851e8d8bef9SDimitry Andric   }
852e8d8bef9SDimitry Andric 
853e8d8bef9SDimitry Andric   bool hasA16() const { return hasR128A16() || hasGFX10A16(); }
854e8d8bef9SDimitry Andric 
855e8d8bef9SDimitry Andric   bool hasG16() const { return HasG16; }
856e8d8bef9SDimitry Andric 
857e8d8bef9SDimitry Andric   bool hasOffset3fBug() const {
858e8d8bef9SDimitry Andric     return HasOffset3fBug;
859e8d8bef9SDimitry Andric   }
860e8d8bef9SDimitry Andric 
861e8d8bef9SDimitry Andric   bool hasImageStoreD16Bug() const { return HasImageStoreD16Bug; }
862e8d8bef9SDimitry Andric 
863e8d8bef9SDimitry Andric   bool hasImageGather4D16Bug() const { return HasImageGather4D16Bug; }
864e8d8bef9SDimitry Andric 
865e8d8bef9SDimitry Andric   bool hasNSAEncoding() const { return HasNSAEncoding; }
866e8d8bef9SDimitry Andric 
867fe6060f1SDimitry Andric   unsigned getNSAMaxSize() const { return NSAMaxSize; }
868fe6060f1SDimitry Andric 
869fe6060f1SDimitry Andric   bool hasGFX10_AEncoding() const {
870fe6060f1SDimitry Andric     return GFX10_AEncoding;
871fe6060f1SDimitry Andric   }
872fe6060f1SDimitry Andric 
873e8d8bef9SDimitry Andric   bool hasGFX10_BEncoding() const {
874e8d8bef9SDimitry Andric     return GFX10_BEncoding;
875e8d8bef9SDimitry Andric   }
876e8d8bef9SDimitry Andric 
877e8d8bef9SDimitry Andric   bool hasGFX10_3Insts() const {
878e8d8bef9SDimitry Andric     return GFX10_3Insts;
879e8d8bef9SDimitry Andric   }
880e8d8bef9SDimitry Andric 
881e8d8bef9SDimitry Andric   bool hasMadF16() const;
882e8d8bef9SDimitry Andric 
883e8d8bef9SDimitry Andric   bool enableSIScheduler() const {
884e8d8bef9SDimitry Andric     return EnableSIScheduler;
885e8d8bef9SDimitry Andric   }
886e8d8bef9SDimitry Andric 
887e8d8bef9SDimitry Andric   bool loadStoreOptEnabled() const {
888e8d8bef9SDimitry Andric     return EnableLoadStoreOpt;
889e8d8bef9SDimitry Andric   }
890e8d8bef9SDimitry Andric 
891e8d8bef9SDimitry Andric   bool hasSGPRInitBug() const {
892e8d8bef9SDimitry Andric     return SGPRInitBug;
893e8d8bef9SDimitry Andric   }
894e8d8bef9SDimitry Andric 
895fe6060f1SDimitry Andric   bool hasNegativeScratchOffsetBug() const { return NegativeScratchOffsetBug; }
896fe6060f1SDimitry Andric 
897fe6060f1SDimitry Andric   bool hasNegativeUnalignedScratchOffsetBug() const {
898fe6060f1SDimitry Andric     return NegativeUnalignedScratchOffsetBug;
899fe6060f1SDimitry Andric   }
900fe6060f1SDimitry Andric 
901e8d8bef9SDimitry Andric   bool hasMFMAInlineLiteralBug() const {
902e8d8bef9SDimitry Andric     return HasMFMAInlineLiteralBug;
903e8d8bef9SDimitry Andric   }
904e8d8bef9SDimitry Andric 
905e8d8bef9SDimitry Andric   bool has12DWordStoreHazard() const {
906e8d8bef9SDimitry Andric     return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
907e8d8bef9SDimitry Andric   }
908e8d8bef9SDimitry Andric 
909e8d8bef9SDimitry Andric   // \returns true if the subtarget supports DWORDX3 load/store instructions.
910e8d8bef9SDimitry Andric   bool hasDwordx3LoadStores() const {
911e8d8bef9SDimitry Andric     return CIInsts;
912e8d8bef9SDimitry Andric   }
913e8d8bef9SDimitry Andric 
914e8d8bef9SDimitry Andric   bool hasReadM0MovRelInterpHazard() const {
915e8d8bef9SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
916e8d8bef9SDimitry Andric   }
917e8d8bef9SDimitry Andric 
918e8d8bef9SDimitry Andric   bool hasReadM0SendMsgHazard() const {
919e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&
920e8d8bef9SDimitry Andric            getGeneration() <= AMDGPUSubtarget::GFX9;
921e8d8bef9SDimitry Andric   }
922e8d8bef9SDimitry Andric 
923e8d8bef9SDimitry Andric   bool hasVcmpxPermlaneHazard() const {
924e8d8bef9SDimitry Andric     return HasVcmpxPermlaneHazard;
925e8d8bef9SDimitry Andric   }
926e8d8bef9SDimitry Andric 
927e8d8bef9SDimitry Andric   bool hasVMEMtoScalarWriteHazard() const {
928e8d8bef9SDimitry Andric     return HasVMEMtoScalarWriteHazard;
929e8d8bef9SDimitry Andric   }
930e8d8bef9SDimitry Andric 
931e8d8bef9SDimitry Andric   bool hasSMEMtoVectorWriteHazard() const {
932e8d8bef9SDimitry Andric     return HasSMEMtoVectorWriteHazard;
933e8d8bef9SDimitry Andric   }
934e8d8bef9SDimitry Andric 
935e8d8bef9SDimitry Andric   bool hasLDSMisalignedBug() const {
936e8d8bef9SDimitry Andric     return LDSMisalignedBug && !EnableCuMode;
937e8d8bef9SDimitry Andric   }
938e8d8bef9SDimitry Andric 
939e8d8bef9SDimitry Andric   bool hasInstFwdPrefetchBug() const {
940e8d8bef9SDimitry Andric     return HasInstFwdPrefetchBug;
941e8d8bef9SDimitry Andric   }
942e8d8bef9SDimitry Andric 
943e8d8bef9SDimitry Andric   bool hasVcmpxExecWARHazard() const {
944e8d8bef9SDimitry Andric     return HasVcmpxExecWARHazard;
945e8d8bef9SDimitry Andric   }
946e8d8bef9SDimitry Andric 
947e8d8bef9SDimitry Andric   bool hasLdsBranchVmemWARHazard() const {
948e8d8bef9SDimitry Andric     return HasLdsBranchVmemWARHazard;
949e8d8bef9SDimitry Andric   }
950e8d8bef9SDimitry Andric 
951e8d8bef9SDimitry Andric   bool hasNSAtoVMEMBug() const {
952e8d8bef9SDimitry Andric     return HasNSAtoVMEMBug;
953e8d8bef9SDimitry Andric   }
954e8d8bef9SDimitry Andric 
955fe6060f1SDimitry Andric   bool hasNSAClauseBug() const { return HasNSAClauseBug; }
956fe6060f1SDimitry Andric 
957e8d8bef9SDimitry Andric   bool hasHardClauses() const { return getGeneration() >= GFX10; }
958e8d8bef9SDimitry Andric 
959fe6060f1SDimitry Andric   bool hasGFX90AInsts() const { return GFX90AInsts; }
960fe6060f1SDimitry Andric 
961fe6060f1SDimitry Andric   /// Return if operations acting on VGPR tuples require even alignment.
962fe6060f1SDimitry Andric   bool needsAlignedVGPRs() const { return GFX90AInsts; }
963fe6060f1SDimitry Andric 
964fe6060f1SDimitry Andric   bool hasPackedTID() const { return HasPackedTID; }
965fe6060f1SDimitry Andric 
966e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
967e8d8bef9SDimitry Andric   /// SGPRs
968e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
969e8d8bef9SDimitry Andric 
970e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
971e8d8bef9SDimitry Andric   /// VGPRs
972e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
973e8d8bef9SDimitry Andric 
974e8d8bef9SDimitry Andric   /// Return occupancy for the given function. Used LDS and a number of
975e8d8bef9SDimitry Andric   /// registers if provided.
976e8d8bef9SDimitry Andric   /// Note, occupancy can be affected by the scratch allocation as well, but
977e8d8bef9SDimitry Andric   /// we do not have enough information to compute it.
978e8d8bef9SDimitry Andric   unsigned computeOccupancy(const Function &F, unsigned LDSSize = 0,
979e8d8bef9SDimitry Andric                             unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const;
980e8d8bef9SDimitry Andric 
981e8d8bef9SDimitry Andric   /// \returns true if the flat_scratch register should be initialized with the
982e8d8bef9SDimitry Andric   /// pointer to the wave's scratch memory rather than a size and offset.
983e8d8bef9SDimitry Andric   bool flatScratchIsPointer() const {
984e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
985e8d8bef9SDimitry Andric   }
986e8d8bef9SDimitry Andric 
987fe6060f1SDimitry Andric   /// \returns true if the flat_scratch register is initialized by the HW.
988fe6060f1SDimitry Andric   /// In this case it is readonly.
989fe6060f1SDimitry Andric   bool flatScratchIsArchitected() const { return HasArchitectedFlatScratch; }
990fe6060f1SDimitry Andric 
991e8d8bef9SDimitry Andric   /// \returns true if the machine has merged shaders in which s0-s7 are
992e8d8bef9SDimitry Andric   /// reserved by the hardware and user SGPRs start at s8
993e8d8bef9SDimitry Andric   bool hasMergedShaders() const {
994e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
995e8d8bef9SDimitry Andric   }
996e8d8bef9SDimitry Andric 
997e8d8bef9SDimitry Andric   /// \returns SGPR allocation granularity supported by the subtarget.
998e8d8bef9SDimitry Andric   unsigned getSGPRAllocGranule() const {
999e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPRAllocGranule(this);
1000e8d8bef9SDimitry Andric   }
1001e8d8bef9SDimitry Andric 
1002e8d8bef9SDimitry Andric   /// \returns SGPR encoding granularity supported by the subtarget.
1003e8d8bef9SDimitry Andric   unsigned getSGPREncodingGranule() const {
1004e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPREncodingGranule(this);
1005e8d8bef9SDimitry Andric   }
1006e8d8bef9SDimitry Andric 
1007e8d8bef9SDimitry Andric   /// \returns Total number of SGPRs supported by the subtarget.
1008e8d8bef9SDimitry Andric   unsigned getTotalNumSGPRs() const {
1009e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumSGPRs(this);
1010e8d8bef9SDimitry Andric   }
1011e8d8bef9SDimitry Andric 
1012e8d8bef9SDimitry Andric   /// \returns Addressable number of SGPRs supported by the subtarget.
1013e8d8bef9SDimitry Andric   unsigned getAddressableNumSGPRs() const {
1014e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumSGPRs(this);
1015e8d8bef9SDimitry Andric   }
1016e8d8bef9SDimitry Andric 
1017e8d8bef9SDimitry Andric   /// \returns Minimum number of SGPRs that meets the given number of waves per
1018e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1019e8d8bef9SDimitry Andric   unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
1020e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU);
1021e8d8bef9SDimitry Andric   }
1022e8d8bef9SDimitry Andric 
1023e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets the given number of waves per
1024e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1025e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
1026e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable);
1027e8d8bef9SDimitry Andric   }
1028e8d8bef9SDimitry Andric 
1029fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs. This is common
1030fe6060f1SDimitry Andric   /// utility function called by MachineFunction and
1031fe6060f1SDimitry Andric   /// Function variants of getReservedNumSGPRs.
1032fe6060f1SDimitry Andric   unsigned getBaseReservedNumSGPRs(const bool HasFlatScratchInit) const;
1033fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given machine function \p MF.
1034e8d8bef9SDimitry Andric   unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
1035e8d8bef9SDimitry Andric 
1036fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given function \p F.
1037fe6060f1SDimitry Andric   unsigned getReservedNumSGPRs(const Function &F) const;
1038fe6060f1SDimitry Andric 
1039fe6060f1SDimitry Andric   /// \returns max num SGPRs. This is the common utility
1040fe6060f1SDimitry Andric   /// function called by MachineFunction and Function
1041fe6060f1SDimitry Andric   /// variants of getMaxNumSGPRs.
1042fe6060f1SDimitry Andric   unsigned getBaseMaxNumSGPRs(const Function &F,
1043fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU,
1044fe6060f1SDimitry Andric                               unsigned PreloadedSGPRs,
1045fe6060f1SDimitry Andric                               unsigned ReservedNumSGPRs) const;
1046fe6060f1SDimitry Andric 
1047e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1048e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of SGPRs explicitly
1049e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
1050e8d8bef9SDimitry Andric   ///
1051e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1052e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1053e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1054e8d8bef9SDimitry Andric   /// unit requirement.
1055e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
1056e8d8bef9SDimitry Andric 
1057fe6060f1SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1058fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of SGPRs explicitly
1059fe6060f1SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p F.
1060fe6060f1SDimitry Andric   ///
1061fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1062fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1063fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1064fe6060f1SDimitry Andric   /// unit requirement.
1065fe6060f1SDimitry Andric   unsigned getMaxNumSGPRs(const Function &F) const;
1066fe6060f1SDimitry Andric 
1067e8d8bef9SDimitry Andric   /// \returns VGPR allocation granularity supported by the subtarget.
1068e8d8bef9SDimitry Andric   unsigned getVGPRAllocGranule() const {
1069e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPRAllocGranule(this);
1070e8d8bef9SDimitry Andric   }
1071e8d8bef9SDimitry Andric 
1072e8d8bef9SDimitry Andric   /// \returns VGPR encoding granularity supported by the subtarget.
1073e8d8bef9SDimitry Andric   unsigned getVGPREncodingGranule() const {
1074e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPREncodingGranule(this);
1075e8d8bef9SDimitry Andric   }
1076e8d8bef9SDimitry Andric 
1077e8d8bef9SDimitry Andric   /// \returns Total number of VGPRs supported by the subtarget.
1078e8d8bef9SDimitry Andric   unsigned getTotalNumVGPRs() const {
1079e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumVGPRs(this);
1080e8d8bef9SDimitry Andric   }
1081e8d8bef9SDimitry Andric 
1082e8d8bef9SDimitry Andric   /// \returns Addressable number of VGPRs supported by the subtarget.
1083e8d8bef9SDimitry Andric   unsigned getAddressableNumVGPRs() const {
1084e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumVGPRs(this);
1085e8d8bef9SDimitry Andric   }
1086e8d8bef9SDimitry Andric 
1087e8d8bef9SDimitry Andric   /// \returns Minimum number of VGPRs that meets given number of waves per
1088e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1089e8d8bef9SDimitry Andric   unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
1090e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU);
1091e8d8bef9SDimitry Andric   }
1092e8d8bef9SDimitry Andric 
1093e8d8bef9SDimitry Andric   /// \returns Maximum number of VGPRs that meets given number of waves per
1094e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1095e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
1096e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU);
1097e8d8bef9SDimitry Andric   }
1098e8d8bef9SDimitry Andric 
1099fe6060f1SDimitry Andric   /// \returns max num VGPRs. This is the common utility function
1100fe6060f1SDimitry Andric   /// called by MachineFunction and Function variants of getMaxNumVGPRs.
1101fe6060f1SDimitry Andric   unsigned getBaseMaxNumVGPRs(const Function &F,
1102fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU) const;
1103fe6060f1SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1104fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of VGPRs explicitly
1105fe6060f1SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p F.
1106fe6060f1SDimitry Andric   ///
1107fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1108fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1109fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1110fe6060f1SDimitry Andric   /// unit requirement.
1111fe6060f1SDimitry Andric   unsigned getMaxNumVGPRs(const Function &F) const;
1112fe6060f1SDimitry Andric 
1113e8d8bef9SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1114e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of VGPRs explicitly
1115e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
1116e8d8bef9SDimitry Andric   ///
1117e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1118e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1119e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1120e8d8bef9SDimitry Andric   /// unit requirement.
1121e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
1122e8d8bef9SDimitry Andric 
1123e8d8bef9SDimitry Andric   void getPostRAMutations(
1124e8d8bef9SDimitry Andric       std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
1125e8d8bef9SDimitry Andric       const override;
1126e8d8bef9SDimitry Andric 
1127*349cc55cSDimitry Andric   std::unique_ptr<ScheduleDAGMutation>
1128*349cc55cSDimitry Andric   createFillMFMAShadowMutation(const TargetInstrInfo *TII) const;
1129*349cc55cSDimitry Andric 
1130e8d8bef9SDimitry Andric   bool isWave32() const {
1131e8d8bef9SDimitry Andric     return getWavefrontSize() == 32;
1132e8d8bef9SDimitry Andric   }
1133e8d8bef9SDimitry Andric 
1134e8d8bef9SDimitry Andric   bool isWave64() const {
1135e8d8bef9SDimitry Andric     return getWavefrontSize() == 64;
1136e8d8bef9SDimitry Andric   }
1137e8d8bef9SDimitry Andric 
1138e8d8bef9SDimitry Andric   const TargetRegisterClass *getBoolRC() const {
1139e8d8bef9SDimitry Andric     return getRegisterInfo()->getBoolRC();
1140e8d8bef9SDimitry Andric   }
1141e8d8bef9SDimitry Andric 
1142e8d8bef9SDimitry Andric   /// \returns Maximum number of work groups per compute unit supported by the
1143e8d8bef9SDimitry Andric   /// subtarget and limited by given \p FlatWorkGroupSize.
1144e8d8bef9SDimitry Andric   unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1145e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1146e8d8bef9SDimitry Andric   }
1147e8d8bef9SDimitry Andric 
1148e8d8bef9SDimitry Andric   /// \returns Minimum flat work group size supported by the subtarget.
1149e8d8bef9SDimitry Andric   unsigned getMinFlatWorkGroupSize() const override {
1150e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1151e8d8bef9SDimitry Andric   }
1152e8d8bef9SDimitry Andric 
1153e8d8bef9SDimitry Andric   /// \returns Maximum flat work group size supported by the subtarget.
1154e8d8bef9SDimitry Andric   unsigned getMaxFlatWorkGroupSize() const override {
1155e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1156e8d8bef9SDimitry Andric   }
1157e8d8bef9SDimitry Andric 
1158e8d8bef9SDimitry Andric   /// \returns Number of waves per execution unit required to support the given
1159e8d8bef9SDimitry Andric   /// \p FlatWorkGroupSize.
1160e8d8bef9SDimitry Andric   unsigned
1161e8d8bef9SDimitry Andric   getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
1162e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(this, FlatWorkGroupSize);
1163e8d8bef9SDimitry Andric   }
1164e8d8bef9SDimitry Andric 
1165e8d8bef9SDimitry Andric   /// \returns Minimum number of waves per execution unit supported by the
1166e8d8bef9SDimitry Andric   /// subtarget.
1167e8d8bef9SDimitry Andric   unsigned getMinWavesPerEU() const override {
1168e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1169e8d8bef9SDimitry Andric   }
1170e8d8bef9SDimitry Andric 
1171e8d8bef9SDimitry Andric   void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
1172e8d8bef9SDimitry Andric                              SDep &Dep) const override;
1173e8d8bef9SDimitry Andric };
1174e8d8bef9SDimitry Andric 
1175e8d8bef9SDimitry Andric } // end namespace llvm
1176e8d8bef9SDimitry Andric 
1177e8d8bef9SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
1178