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