xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/AMDGPU/GCNSubtarget.h (revision 1db9f3b21e39176dd5b67cf8ac378633b172463e)
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"
1806c3fb27SDimitry Andric #include "AMDGPURegisterBankInfo.h"
19e8d8bef9SDimitry Andric #include "AMDGPUSubtarget.h"
20e8d8bef9SDimitry Andric #include "SIFrameLowering.h"
21e8d8bef9SDimitry Andric #include "SIISelLowering.h"
22e8d8bef9SDimitry Andric #include "SIInstrInfo.h"
2306c3fb27SDimitry Andric #include "Utils/AMDGPUBaseInfo.h"
24e8d8bef9SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
255f757f3fSDimitry Andric #include "llvm/Support/ErrorHandling.h"
26e8d8bef9SDimitry Andric 
27e8d8bef9SDimitry Andric #define GET_SUBTARGETINFO_HEADER
28e8d8bef9SDimitry Andric #include "AMDGPUGenSubtargetInfo.inc"
29e8d8bef9SDimitry Andric 
30e8d8bef9SDimitry Andric namespace llvm {
31e8d8bef9SDimitry Andric 
32e8d8bef9SDimitry Andric class GCNTargetMachine;
33e8d8bef9SDimitry Andric 
34e8d8bef9SDimitry Andric class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
35e8d8bef9SDimitry Andric                            public AMDGPUSubtarget {
36bdd1243dSDimitry Andric public:
37e8d8bef9SDimitry Andric   using AMDGPUSubtarget::getMaxWavesPerEU;
38e8d8bef9SDimitry Andric 
39fe6060f1SDimitry Andric   // Following 2 enums are documented at:
40fe6060f1SDimitry Andric   //   - https://llvm.org/docs/AMDGPUUsage.html#trap-handler-abi
41fe6060f1SDimitry Andric   enum class TrapHandlerAbi {
42fe6060f1SDimitry Andric     NONE   = 0x00,
43fe6060f1SDimitry Andric     AMDHSA = 0x01,
44e8d8bef9SDimitry Andric   };
45e8d8bef9SDimitry Andric 
46fe6060f1SDimitry Andric   enum class TrapID {
47fe6060f1SDimitry Andric     LLVMAMDHSATrap      = 0x02,
48fe6060f1SDimitry Andric     LLVMAMDHSADebugTrap = 0x03,
49e8d8bef9SDimitry Andric   };
50e8d8bef9SDimitry Andric 
51e8d8bef9SDimitry Andric private:
52e8d8bef9SDimitry Andric   /// GlobalISel related APIs.
53e8d8bef9SDimitry Andric   std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
54e8d8bef9SDimitry Andric   std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
55e8d8bef9SDimitry Andric   std::unique_ptr<InstructionSelector> InstSelector;
56e8d8bef9SDimitry Andric   std::unique_ptr<LegalizerInfo> Legalizer;
5706c3fb27SDimitry Andric   std::unique_ptr<AMDGPURegisterBankInfo> RegBankInfo;
58e8d8bef9SDimitry Andric 
59e8d8bef9SDimitry Andric protected:
60e8d8bef9SDimitry Andric   // Basic subtarget description.
61e8d8bef9SDimitry Andric   Triple TargetTriple;
62e8d8bef9SDimitry Andric   AMDGPU::IsaInfo::AMDGPUTargetID TargetID;
6381ad6265SDimitry Andric   unsigned Gen = INVALID;
64e8d8bef9SDimitry Andric   InstrItineraryData InstrItins;
6581ad6265SDimitry Andric   int LDSBankCount = 0;
6681ad6265SDimitry Andric   unsigned MaxPrivateElementSize = 0;
67e8d8bef9SDimitry Andric 
68e8d8bef9SDimitry Andric   // Possibly statically set by tablegen, but may want to be overridden.
6981ad6265SDimitry Andric   bool FastDenormalF32 = false;
7081ad6265SDimitry Andric   bool HalfRate64Ops = false;
7181ad6265SDimitry Andric   bool FullRate64Ops = false;
72e8d8bef9SDimitry Andric 
73e8d8bef9SDimitry Andric   // Dynamically set bits that enable features.
7481ad6265SDimitry Andric   bool FlatForGlobal = false;
7581ad6265SDimitry Andric   bool AutoWaitcntBeforeBarrier = false;
76bdd1243dSDimitry Andric   bool BackOffBarrier = false;
7781ad6265SDimitry Andric   bool UnalignedScratchAccess = false;
7881ad6265SDimitry Andric   bool UnalignedAccessMode = false;
7981ad6265SDimitry Andric   bool HasApertureRegs = false;
8081ad6265SDimitry Andric   bool SupportsXNACK = false;
815f757f3fSDimitry Andric   bool KernargPreload = false;
82e8d8bef9SDimitry Andric 
83e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
84e8d8bef9SDimitry Andric   // for XNACK.
8581ad6265SDimitry Andric   bool EnableXNACK = false;
86e8d8bef9SDimitry Andric 
8781ad6265SDimitry Andric   bool EnableTgSplit = false;
8881ad6265SDimitry Andric   bool EnableCuMode = false;
8981ad6265SDimitry Andric   bool TrapHandler = false;
90e8d8bef9SDimitry Andric 
91e8d8bef9SDimitry Andric   // Used as options.
9281ad6265SDimitry Andric   bool EnableLoadStoreOpt = false;
9381ad6265SDimitry Andric   bool EnableUnsafeDSOffsetFolding = false;
9481ad6265SDimitry Andric   bool EnableSIScheduler = false;
9581ad6265SDimitry Andric   bool EnableDS128 = false;
9681ad6265SDimitry Andric   bool EnablePRTStrictNull = false;
9781ad6265SDimitry Andric   bool DumpCode = false;
98e8d8bef9SDimitry Andric 
99e8d8bef9SDimitry Andric   // Subtarget statically properties set by tablegen
10081ad6265SDimitry Andric   bool FP64 = false;
10181ad6265SDimitry Andric   bool FMA = false;
10281ad6265SDimitry Andric   bool MIMG_R128 = false;
10381ad6265SDimitry Andric   bool CIInsts = false;
10481ad6265SDimitry Andric   bool GFX8Insts = false;
10581ad6265SDimitry Andric   bool GFX9Insts = false;
10681ad6265SDimitry Andric   bool GFX90AInsts = false;
10781ad6265SDimitry Andric   bool GFX940Insts = false;
10881ad6265SDimitry Andric   bool GFX10Insts = false;
10981ad6265SDimitry Andric   bool GFX11Insts = false;
1105f757f3fSDimitry Andric   bool GFX12Insts = false;
11181ad6265SDimitry Andric   bool GFX10_3Insts = false;
11281ad6265SDimitry Andric   bool GFX7GFX8GFX9Insts = false;
11381ad6265SDimitry Andric   bool SGPRInitBug = false;
11481ad6265SDimitry Andric   bool UserSGPRInit16Bug = false;
11581ad6265SDimitry Andric   bool NegativeScratchOffsetBug = false;
11681ad6265SDimitry Andric   bool NegativeUnalignedScratchOffsetBug = false;
11781ad6265SDimitry Andric   bool HasSMemRealTime = false;
11881ad6265SDimitry Andric   bool HasIntClamp = false;
11981ad6265SDimitry Andric   bool HasFmaMixInsts = false;
12081ad6265SDimitry Andric   bool HasMovrel = false;
12181ad6265SDimitry Andric   bool HasVGPRIndexMode = false;
1225f757f3fSDimitry Andric   bool HasScalarDwordx3Loads = false;
12381ad6265SDimitry Andric   bool HasScalarStores = false;
12481ad6265SDimitry Andric   bool HasScalarAtomics = false;
12581ad6265SDimitry Andric   bool HasSDWAOmod = false;
12681ad6265SDimitry Andric   bool HasSDWAScalar = false;
12781ad6265SDimitry Andric   bool HasSDWASdst = false;
12881ad6265SDimitry Andric   bool HasSDWAMac = false;
12981ad6265SDimitry Andric   bool HasSDWAOutModsVOPC = false;
13081ad6265SDimitry Andric   bool HasDPP = false;
13181ad6265SDimitry Andric   bool HasDPP8 = false;
1325f757f3fSDimitry Andric   bool HasDPALU_DPP = false;
1335f757f3fSDimitry Andric   bool HasDPPSrc1SGPR = false;
13481ad6265SDimitry Andric   bool HasPackedFP32Ops = false;
13581ad6265SDimitry Andric   bool HasImageInsts = false;
13681ad6265SDimitry Andric   bool HasExtendedImageInsts = false;
13781ad6265SDimitry Andric   bool HasR128A16 = false;
138bdd1243dSDimitry Andric   bool HasA16 = false;
13981ad6265SDimitry Andric   bool HasG16 = false;
14081ad6265SDimitry Andric   bool HasNSAEncoding = false;
14106c3fb27SDimitry Andric   bool HasPartialNSAEncoding = false;
14281ad6265SDimitry Andric   bool GFX10_AEncoding = false;
14381ad6265SDimitry Andric   bool GFX10_BEncoding = false;
14481ad6265SDimitry Andric   bool HasDLInsts = false;
145bdd1243dSDimitry Andric   bool HasFmacF64Inst = false;
14681ad6265SDimitry Andric   bool HasDot1Insts = false;
14781ad6265SDimitry Andric   bool HasDot2Insts = false;
14881ad6265SDimitry Andric   bool HasDot3Insts = false;
14981ad6265SDimitry Andric   bool HasDot4Insts = false;
15081ad6265SDimitry Andric   bool HasDot5Insts = false;
15181ad6265SDimitry Andric   bool HasDot6Insts = false;
15281ad6265SDimitry Andric   bool HasDot7Insts = false;
15381ad6265SDimitry Andric   bool HasDot8Insts = false;
154bdd1243dSDimitry Andric   bool HasDot9Insts = false;
15506c3fb27SDimitry Andric   bool HasDot10Insts = false;
15681ad6265SDimitry Andric   bool HasMAIInsts = false;
157fcaf7f86SDimitry Andric   bool HasFP8Insts = false;
15881ad6265SDimitry Andric   bool HasPkFmacF16Inst = false;
15906c3fb27SDimitry Andric   bool HasAtomicDsPkAdd16Insts = false;
16006c3fb27SDimitry Andric   bool HasAtomicFlatPkAdd16Insts = false;
16181ad6265SDimitry Andric   bool HasAtomicFaddRtnInsts = false;
16281ad6265SDimitry Andric   bool HasAtomicFaddNoRtnInsts = false;
16306c3fb27SDimitry Andric   bool HasAtomicBufferGlobalPkAddF16NoRtnInsts = false;
16406c3fb27SDimitry Andric   bool HasAtomicBufferGlobalPkAddF16Insts = false;
1655f757f3fSDimitry Andric   bool HasAtomicCSubNoRtnInsts = false;
16606c3fb27SDimitry Andric   bool HasAtomicGlobalPkAddBF16Inst = false;
167bdd1243dSDimitry Andric   bool HasFlatAtomicFaddF32Inst = false;
16881ad6265SDimitry Andric   bool SupportsSRAMECC = false;
169e8d8bef9SDimitry Andric 
170e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
171e8d8bef9SDimitry Andric   // for SRAMECC.
17281ad6265SDimitry Andric   bool EnableSRAMECC = false;
173e8d8bef9SDimitry Andric 
17481ad6265SDimitry Andric   bool HasNoSdstCMPX = false;
17581ad6265SDimitry Andric   bool HasVscnt = false;
17681ad6265SDimitry Andric   bool HasGetWaveIdInst = false;
17781ad6265SDimitry Andric   bool HasSMemTimeInst = false;
17881ad6265SDimitry Andric   bool HasShaderCyclesRegister = false;
179*1db9f3b2SDimitry Andric   bool HasShaderCyclesHiLoRegisters = false;
18081ad6265SDimitry Andric   bool HasVOP3Literal = false;
18181ad6265SDimitry Andric   bool HasNoDataDepHazard = false;
18281ad6265SDimitry Andric   bool FlatAddressSpace = false;
18381ad6265SDimitry Andric   bool FlatInstOffsets = false;
18481ad6265SDimitry Andric   bool FlatGlobalInsts = false;
18581ad6265SDimitry Andric   bool FlatScratchInsts = false;
18681ad6265SDimitry Andric   bool ScalarFlatScratchInsts = false;
18781ad6265SDimitry Andric   bool HasArchitectedFlatScratch = false;
18881ad6265SDimitry Andric   bool EnableFlatScratch = false;
18906c3fb27SDimitry Andric   bool HasArchitectedSGPRs = false;
1905f757f3fSDimitry Andric   bool HasGDS = false;
1915f757f3fSDimitry Andric   bool HasGWS = false;
19281ad6265SDimitry Andric   bool AddNoCarryInsts = false;
19381ad6265SDimitry Andric   bool HasUnpackedD16VMem = false;
19481ad6265SDimitry Andric   bool LDSMisalignedBug = false;
19581ad6265SDimitry Andric   bool HasMFMAInlineLiteralBug = false;
19681ad6265SDimitry Andric   bool UnalignedBufferAccess = false;
19781ad6265SDimitry Andric   bool UnalignedDSAccess = false;
19881ad6265SDimitry Andric   bool HasPackedTID = false;
19981ad6265SDimitry Andric   bool ScalarizeGlobal = false;
2005f757f3fSDimitry Andric   bool HasSALUFloatInsts = false;
2015f757f3fSDimitry Andric   bool HasVGPRSingleUseHintInsts = false;
2025f757f3fSDimitry Andric   bool HasPseudoScalarTrans = false;
2035f757f3fSDimitry Andric   bool HasRestrictedSOffset = false;
204e8d8bef9SDimitry Andric 
20581ad6265SDimitry Andric   bool HasVcmpxPermlaneHazard = false;
20681ad6265SDimitry Andric   bool HasVMEMtoScalarWriteHazard = false;
20781ad6265SDimitry Andric   bool HasSMEMtoVectorWriteHazard = false;
20881ad6265SDimitry Andric   bool HasInstFwdPrefetchBug = false;
20981ad6265SDimitry Andric   bool HasVcmpxExecWARHazard = false;
21081ad6265SDimitry Andric   bool HasLdsBranchVmemWARHazard = false;
21181ad6265SDimitry Andric   bool HasNSAtoVMEMBug = false;
21281ad6265SDimitry Andric   bool HasNSAClauseBug = false;
21381ad6265SDimitry Andric   bool HasOffset3fBug = false;
21481ad6265SDimitry Andric   bool HasFlatSegmentOffsetBug = false;
21581ad6265SDimitry Andric   bool HasImageStoreD16Bug = false;
21681ad6265SDimitry Andric   bool HasImageGather4D16Bug = false;
2175f757f3fSDimitry Andric   bool HasMSAALoadDstSelBug = false;
218bdd1243dSDimitry Andric   bool HasGFX11FullVGPRs = false;
219bdd1243dSDimitry Andric   bool HasMADIntraFwdBug = false;
22081ad6265SDimitry Andric   bool HasVOPDInsts = false;
221bdd1243dSDimitry Andric   bool HasVALUTransUseHazard = false;
22206c3fb27SDimitry Andric   bool HasForceStoreSC0SC1 = false;
223e8d8bef9SDimitry Andric 
224e8d8bef9SDimitry Andric   // Dummy feature to use for assembler in tablegen.
22581ad6265SDimitry Andric   bool FeatureDisable = false;
226e8d8bef9SDimitry Andric 
227e8d8bef9SDimitry Andric   SelectionDAGTargetInfo TSInfo;
228e8d8bef9SDimitry Andric private:
229e8d8bef9SDimitry Andric   SIInstrInfo InstrInfo;
230e8d8bef9SDimitry Andric   SITargetLowering TLInfo;
231e8d8bef9SDimitry Andric   SIFrameLowering FrameLowering;
232e8d8bef9SDimitry Andric 
233e8d8bef9SDimitry Andric public:
234e8d8bef9SDimitry Andric   GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
235e8d8bef9SDimitry Andric                const GCNTargetMachine &TM);
236e8d8bef9SDimitry Andric   ~GCNSubtarget() override;
237e8d8bef9SDimitry Andric 
238e8d8bef9SDimitry Andric   GCNSubtarget &initializeSubtargetDependencies(const Triple &TT,
239e8d8bef9SDimitry Andric                                                    StringRef GPU, StringRef FS);
240e8d8bef9SDimitry Andric 
241e8d8bef9SDimitry Andric   const SIInstrInfo *getInstrInfo() const override {
242e8d8bef9SDimitry Andric     return &InstrInfo;
243e8d8bef9SDimitry Andric   }
244e8d8bef9SDimitry Andric 
245e8d8bef9SDimitry Andric   const SIFrameLowering *getFrameLowering() const override {
246e8d8bef9SDimitry Andric     return &FrameLowering;
247e8d8bef9SDimitry Andric   }
248e8d8bef9SDimitry Andric 
249e8d8bef9SDimitry Andric   const SITargetLowering *getTargetLowering() const override {
250e8d8bef9SDimitry Andric     return &TLInfo;
251e8d8bef9SDimitry Andric   }
252e8d8bef9SDimitry Andric 
253e8d8bef9SDimitry Andric   const SIRegisterInfo *getRegisterInfo() const override {
254e8d8bef9SDimitry Andric     return &InstrInfo.getRegisterInfo();
255e8d8bef9SDimitry Andric   }
256e8d8bef9SDimitry Andric 
257e8d8bef9SDimitry Andric   const CallLowering *getCallLowering() const override {
258e8d8bef9SDimitry Andric     return CallLoweringInfo.get();
259e8d8bef9SDimitry Andric   }
260e8d8bef9SDimitry Andric 
261e8d8bef9SDimitry Andric   const InlineAsmLowering *getInlineAsmLowering() const override {
262e8d8bef9SDimitry Andric     return InlineAsmLoweringInfo.get();
263e8d8bef9SDimitry Andric   }
264e8d8bef9SDimitry Andric 
265e8d8bef9SDimitry Andric   InstructionSelector *getInstructionSelector() const override {
266e8d8bef9SDimitry Andric     return InstSelector.get();
267e8d8bef9SDimitry Andric   }
268e8d8bef9SDimitry Andric 
269e8d8bef9SDimitry Andric   const LegalizerInfo *getLegalizerInfo() const override {
270e8d8bef9SDimitry Andric     return Legalizer.get();
271e8d8bef9SDimitry Andric   }
272e8d8bef9SDimitry Andric 
27306c3fb27SDimitry Andric   const AMDGPURegisterBankInfo *getRegBankInfo() const override {
274e8d8bef9SDimitry Andric     return RegBankInfo.get();
275e8d8bef9SDimitry Andric   }
276e8d8bef9SDimitry Andric 
277fe6060f1SDimitry Andric   const AMDGPU::IsaInfo::AMDGPUTargetID &getTargetID() const {
278fe6060f1SDimitry Andric     return TargetID;
279fe6060f1SDimitry Andric   }
280fe6060f1SDimitry Andric 
281e8d8bef9SDimitry Andric   // Nothing implemented, just prevent crashes on use.
282e8d8bef9SDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
283e8d8bef9SDimitry Andric     return &TSInfo;
284e8d8bef9SDimitry Andric   }
285e8d8bef9SDimitry Andric 
286e8d8bef9SDimitry Andric   const InstrItineraryData *getInstrItineraryData() const override {
287e8d8bef9SDimitry Andric     return &InstrItins;
288e8d8bef9SDimitry Andric   }
289e8d8bef9SDimitry Andric 
290e8d8bef9SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
291e8d8bef9SDimitry Andric 
292e8d8bef9SDimitry Andric   Generation getGeneration() const {
293e8d8bef9SDimitry Andric     return (Generation)Gen;
294e8d8bef9SDimitry Andric   }
295e8d8bef9SDimitry Andric 
29681ad6265SDimitry Andric   unsigned getMaxWaveScratchSize() const {
29781ad6265SDimitry Andric     // See COMPUTE_TMPRING_SIZE.WAVESIZE.
29881ad6265SDimitry Andric     if (getGeneration() < GFX11) {
29981ad6265SDimitry Andric       // 13-bit field in units of 256-dword.
30081ad6265SDimitry Andric       return (256 * 4) * ((1 << 13) - 1);
30181ad6265SDimitry Andric     }
30281ad6265SDimitry Andric     // 15-bit field in units of 64-dword.
30381ad6265SDimitry Andric     return (64 * 4) * ((1 << 15) - 1);
30481ad6265SDimitry Andric   }
30581ad6265SDimitry Andric 
306349cc55cSDimitry Andric   /// Return the number of high bits known to be zero for a frame index.
307e8d8bef9SDimitry Andric   unsigned getKnownHighZeroBitsForFrameIndex() const {
30806c3fb27SDimitry Andric     return llvm::countl_zero(getMaxWaveScratchSize()) + getWavefrontSizeLog2();
309e8d8bef9SDimitry Andric   }
310e8d8bef9SDimitry Andric 
311e8d8bef9SDimitry Andric   int getLDSBankCount() const {
312e8d8bef9SDimitry Andric     return LDSBankCount;
313e8d8bef9SDimitry Andric   }
314e8d8bef9SDimitry Andric 
315e8d8bef9SDimitry Andric   unsigned getMaxPrivateElementSize(bool ForBufferRSrc = false) const {
316e8d8bef9SDimitry Andric     return (ForBufferRSrc || !enableFlatScratch()) ? MaxPrivateElementSize : 16;
317e8d8bef9SDimitry Andric   }
318e8d8bef9SDimitry Andric 
319e8d8bef9SDimitry Andric   unsigned getConstantBusLimit(unsigned Opcode) const;
320e8d8bef9SDimitry Andric 
321fe6060f1SDimitry Andric   /// Returns if the result of this instruction with a 16-bit result returned in
322fe6060f1SDimitry Andric   /// a 32-bit register implicitly zeroes the high 16-bits, rather than preserve
323fe6060f1SDimitry Andric   /// the original value.
324fe6060f1SDimitry Andric   bool zeroesHigh16BitsOfDest(unsigned Opcode) const;
325fe6060f1SDimitry Andric 
326bdd1243dSDimitry Andric   bool supportsWGP() const { return getGeneration() >= GFX10; }
327bdd1243dSDimitry Andric 
328e8d8bef9SDimitry Andric   bool hasIntClamp() const {
329e8d8bef9SDimitry Andric     return HasIntClamp;
330e8d8bef9SDimitry Andric   }
331e8d8bef9SDimitry Andric 
332e8d8bef9SDimitry Andric   bool hasFP64() const {
333e8d8bef9SDimitry Andric     return FP64;
334e8d8bef9SDimitry Andric   }
335e8d8bef9SDimitry Andric 
336e8d8bef9SDimitry Andric   bool hasMIMG_R128() const {
337e8d8bef9SDimitry Andric     return MIMG_R128;
338e8d8bef9SDimitry Andric   }
339e8d8bef9SDimitry Andric 
340e8d8bef9SDimitry Andric   bool hasHWFP64() const {
341e8d8bef9SDimitry Andric     return FP64;
342e8d8bef9SDimitry Andric   }
343e8d8bef9SDimitry Andric 
344e8d8bef9SDimitry Andric   bool hasHalfRate64Ops() const {
345e8d8bef9SDimitry Andric     return HalfRate64Ops;
346e8d8bef9SDimitry Andric   }
347e8d8bef9SDimitry Andric 
348fe6060f1SDimitry Andric   bool hasFullRate64Ops() const {
349fe6060f1SDimitry Andric     return FullRate64Ops;
350fe6060f1SDimitry Andric   }
351fe6060f1SDimitry Andric 
352e8d8bef9SDimitry Andric   bool hasAddr64() const {
353e8d8bef9SDimitry Andric     return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS);
354e8d8bef9SDimitry Andric   }
355e8d8bef9SDimitry Andric 
356e8d8bef9SDimitry Andric   bool hasFlat() const {
357e8d8bef9SDimitry Andric     return (getGeneration() > AMDGPUSubtarget::SOUTHERN_ISLANDS);
358e8d8bef9SDimitry Andric   }
359e8d8bef9SDimitry Andric 
360e8d8bef9SDimitry Andric   // Return true if the target only has the reverse operand versions of VALU
361e8d8bef9SDimitry Andric   // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
362e8d8bef9SDimitry Andric   bool hasOnlyRevVALUShifts() const {
363e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
364e8d8bef9SDimitry Andric   }
365e8d8bef9SDimitry Andric 
366e8d8bef9SDimitry Andric   bool hasFractBug() const {
367e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
368e8d8bef9SDimitry Andric   }
369e8d8bef9SDimitry Andric 
370e8d8bef9SDimitry Andric   bool hasBFE() const {
371e8d8bef9SDimitry Andric     return true;
372e8d8bef9SDimitry Andric   }
373e8d8bef9SDimitry Andric 
374e8d8bef9SDimitry Andric   bool hasBFI() const {
375e8d8bef9SDimitry Andric     return true;
376e8d8bef9SDimitry Andric   }
377e8d8bef9SDimitry Andric 
378e8d8bef9SDimitry Andric   bool hasBFM() const {
379e8d8bef9SDimitry Andric     return hasBFE();
380e8d8bef9SDimitry Andric   }
381e8d8bef9SDimitry Andric 
382e8d8bef9SDimitry Andric   bool hasBCNT(unsigned Size) const {
383e8d8bef9SDimitry Andric     return true;
384e8d8bef9SDimitry Andric   }
385e8d8bef9SDimitry Andric 
386e8d8bef9SDimitry Andric   bool hasFFBL() const {
387e8d8bef9SDimitry Andric     return true;
388e8d8bef9SDimitry Andric   }
389e8d8bef9SDimitry Andric 
390e8d8bef9SDimitry Andric   bool hasFFBH() const {
391e8d8bef9SDimitry Andric     return true;
392e8d8bef9SDimitry Andric   }
393e8d8bef9SDimitry Andric 
394e8d8bef9SDimitry Andric   bool hasMed3_16() const {
395e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
396e8d8bef9SDimitry Andric   }
397e8d8bef9SDimitry Andric 
398e8d8bef9SDimitry Andric   bool hasMin3Max3_16() const {
399e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
400e8d8bef9SDimitry Andric   }
401e8d8bef9SDimitry Andric 
402e8d8bef9SDimitry Andric   bool hasFmaMixInsts() const {
403e8d8bef9SDimitry Andric     return HasFmaMixInsts;
404e8d8bef9SDimitry Andric   }
405e8d8bef9SDimitry Andric 
406e8d8bef9SDimitry Andric   bool hasCARRY() const {
407e8d8bef9SDimitry Andric     return true;
408e8d8bef9SDimitry Andric   }
409e8d8bef9SDimitry Andric 
410e8d8bef9SDimitry Andric   bool hasFMA() const {
411e8d8bef9SDimitry Andric     return FMA;
412e8d8bef9SDimitry Andric   }
413e8d8bef9SDimitry Andric 
414e8d8bef9SDimitry Andric   bool hasSwap() const {
415e8d8bef9SDimitry Andric     return GFX9Insts;
416e8d8bef9SDimitry Andric   }
417e8d8bef9SDimitry Andric 
418e8d8bef9SDimitry Andric   bool hasScalarPackInsts() const {
419e8d8bef9SDimitry Andric     return GFX9Insts;
420e8d8bef9SDimitry Andric   }
421e8d8bef9SDimitry Andric 
422e8d8bef9SDimitry Andric   bool hasScalarMulHiInsts() const {
423e8d8bef9SDimitry Andric     return GFX9Insts;
424e8d8bef9SDimitry Andric   }
425e8d8bef9SDimitry Andric 
426e8d8bef9SDimitry Andric   TrapHandlerAbi getTrapHandlerAbi() const {
427fe6060f1SDimitry Andric     return isAmdHsaOS() ? TrapHandlerAbi::AMDHSA : TrapHandlerAbi::NONE;
428fe6060f1SDimitry Andric   }
429fe6060f1SDimitry Andric 
430fe6060f1SDimitry Andric   bool supportsGetDoorbellID() const {
431fe6060f1SDimitry Andric     // The S_GETREG DOORBELL_ID is supported by all GFX9 onward targets.
432fe6060f1SDimitry Andric     return getGeneration() >= GFX9;
433e8d8bef9SDimitry Andric   }
434e8d8bef9SDimitry Andric 
435e8d8bef9SDimitry Andric   /// True if the offset field of DS instructions works as expected. On SI, the
436e8d8bef9SDimitry Andric   /// offset uses a 16-bit adder and does not always wrap properly.
437e8d8bef9SDimitry Andric   bool hasUsableDSOffset() const {
438e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
439e8d8bef9SDimitry Andric   }
440e8d8bef9SDimitry Andric 
441e8d8bef9SDimitry Andric   bool unsafeDSOffsetFoldingEnabled() const {
442e8d8bef9SDimitry Andric     return EnableUnsafeDSOffsetFolding;
443e8d8bef9SDimitry Andric   }
444e8d8bef9SDimitry Andric 
445e8d8bef9SDimitry Andric   /// Condition output from div_scale is usable.
446e8d8bef9SDimitry Andric   bool hasUsableDivScaleConditionOutput() const {
447e8d8bef9SDimitry Andric     return getGeneration() != SOUTHERN_ISLANDS;
448e8d8bef9SDimitry Andric   }
449e8d8bef9SDimitry Andric 
450e8d8bef9SDimitry Andric   /// Extra wait hazard is needed in some cases before
451e8d8bef9SDimitry Andric   /// s_cbranch_vccnz/s_cbranch_vccz.
452e8d8bef9SDimitry Andric   bool hasReadVCCZBug() const {
453e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS;
454e8d8bef9SDimitry Andric   }
455e8d8bef9SDimitry Andric 
456e8d8bef9SDimitry Andric   /// Writes to VCC_LO/VCC_HI update the VCCZ flag.
457e8d8bef9SDimitry Andric   bool partialVCCWritesUpdateVCCZ() const {
458e8d8bef9SDimitry Andric     return getGeneration() >= GFX10;
459e8d8bef9SDimitry Andric   }
460e8d8bef9SDimitry Andric 
461e8d8bef9SDimitry Andric   /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
462e8d8bef9SDimitry Andric   /// was written by a VALU instruction.
463e8d8bef9SDimitry Andric   bool hasSMRDReadVALUDefHazard() const {
464e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
465e8d8bef9SDimitry Andric   }
466e8d8bef9SDimitry Andric 
467e8d8bef9SDimitry Andric   /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
468e8d8bef9SDimitry Andric   /// SGPR was written by a VALU Instruction.
469e8d8bef9SDimitry Andric   bool hasVMEMReadSGPRVALUDefHazard() const {
470e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
471e8d8bef9SDimitry Andric   }
472e8d8bef9SDimitry Andric 
473e8d8bef9SDimitry Andric   bool hasRFEHazards() const {
474e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
475e8d8bef9SDimitry Andric   }
476e8d8bef9SDimitry Andric 
477e8d8bef9SDimitry Andric   /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
478e8d8bef9SDimitry Andric   unsigned getSetRegWaitStates() const {
479e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS ? 1 : 2;
480e8d8bef9SDimitry Andric   }
481e8d8bef9SDimitry Andric 
482e8d8bef9SDimitry Andric   bool dumpCode() const {
483e8d8bef9SDimitry Andric     return DumpCode;
484e8d8bef9SDimitry Andric   }
485e8d8bef9SDimitry Andric 
486e8d8bef9SDimitry Andric   /// Return the amount of LDS that can be used that will not restrict the
487e8d8bef9SDimitry Andric   /// occupancy lower than WaveCount.
488e8d8bef9SDimitry Andric   unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
489e8d8bef9SDimitry Andric                                            const Function &) const;
490e8d8bef9SDimitry Andric 
491e8d8bef9SDimitry Andric   bool supportsMinMaxDenormModes() const {
492e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
493e8d8bef9SDimitry Andric   }
494e8d8bef9SDimitry Andric 
495e8d8bef9SDimitry Andric   /// \returns If target supports S_DENORM_MODE.
496e8d8bef9SDimitry Andric   bool hasDenormModeInst() const {
497e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX10;
498e8d8bef9SDimitry Andric   }
499e8d8bef9SDimitry Andric 
500e8d8bef9SDimitry Andric   bool useFlatForGlobal() const {
501e8d8bef9SDimitry Andric     return FlatForGlobal;
502e8d8bef9SDimitry Andric   }
503e8d8bef9SDimitry Andric 
504e8d8bef9SDimitry Andric   /// \returns If target supports ds_read/write_b128 and user enables generation
505e8d8bef9SDimitry Andric   /// of ds_read/write_b128.
506e8d8bef9SDimitry Andric   bool useDS128() const {
507e8d8bef9SDimitry Andric     return CIInsts && EnableDS128;
508e8d8bef9SDimitry Andric   }
509e8d8bef9SDimitry Andric 
510e8d8bef9SDimitry Andric   /// \return If target supports ds_read/write_b96/128.
511e8d8bef9SDimitry Andric   bool hasDS96AndDS128() const {
512e8d8bef9SDimitry Andric     return CIInsts;
513e8d8bef9SDimitry Andric   }
514e8d8bef9SDimitry Andric 
515e8d8bef9SDimitry Andric   /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
516e8d8bef9SDimitry Andric   bool haveRoundOpsF64() const {
517e8d8bef9SDimitry Andric     return CIInsts;
518e8d8bef9SDimitry Andric   }
519e8d8bef9SDimitry Andric 
520e8d8bef9SDimitry Andric   /// \returns If MUBUF instructions always perform range checking, even for
521e8d8bef9SDimitry Andric   /// buffer resources used for private memory access.
522e8d8bef9SDimitry Andric   bool privateMemoryResourceIsRangeChecked() const {
523e8d8bef9SDimitry Andric     return getGeneration() < AMDGPUSubtarget::GFX9;
524e8d8bef9SDimitry Andric   }
525e8d8bef9SDimitry Andric 
526e8d8bef9SDimitry Andric   /// \returns If target requires PRT Struct NULL support (zero result registers
527e8d8bef9SDimitry Andric   /// for sparse texture support).
528e8d8bef9SDimitry Andric   bool usePRTStrictNull() const {
529e8d8bef9SDimitry Andric     return EnablePRTStrictNull;
530e8d8bef9SDimitry Andric   }
531e8d8bef9SDimitry Andric 
532e8d8bef9SDimitry Andric   bool hasAutoWaitcntBeforeBarrier() const {
533e8d8bef9SDimitry Andric     return AutoWaitcntBeforeBarrier;
534e8d8bef9SDimitry Andric   }
535e8d8bef9SDimitry Andric 
536bdd1243dSDimitry Andric   /// \returns true if the target supports backing off of s_barrier instructions
537bdd1243dSDimitry Andric   /// when an exception is raised.
538bdd1243dSDimitry Andric   bool supportsBackOffBarrier() const {
539bdd1243dSDimitry Andric     return BackOffBarrier;
540bdd1243dSDimitry Andric   }
541bdd1243dSDimitry Andric 
542e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccess() const {
543e8d8bef9SDimitry Andric     return UnalignedBufferAccess;
544e8d8bef9SDimitry Andric   }
545e8d8bef9SDimitry Andric 
546e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccessEnabled() const {
547e8d8bef9SDimitry Andric     return UnalignedBufferAccess && UnalignedAccessMode;
548e8d8bef9SDimitry Andric   }
549e8d8bef9SDimitry Andric 
550e8d8bef9SDimitry Andric   bool hasUnalignedDSAccess() const {
551e8d8bef9SDimitry Andric     return UnalignedDSAccess;
552e8d8bef9SDimitry Andric   }
553e8d8bef9SDimitry Andric 
554e8d8bef9SDimitry Andric   bool hasUnalignedDSAccessEnabled() const {
555e8d8bef9SDimitry Andric     return UnalignedDSAccess && UnalignedAccessMode;
556e8d8bef9SDimitry Andric   }
557e8d8bef9SDimitry Andric 
558e8d8bef9SDimitry Andric   bool hasUnalignedScratchAccess() const {
559e8d8bef9SDimitry Andric     return UnalignedScratchAccess;
560e8d8bef9SDimitry Andric   }
561e8d8bef9SDimitry Andric 
562e8d8bef9SDimitry Andric   bool hasUnalignedAccessMode() const {
563e8d8bef9SDimitry Andric     return UnalignedAccessMode;
564e8d8bef9SDimitry Andric   }
565e8d8bef9SDimitry Andric 
566e8d8bef9SDimitry Andric   bool hasApertureRegs() const {
567e8d8bef9SDimitry Andric     return HasApertureRegs;
568e8d8bef9SDimitry Andric   }
569e8d8bef9SDimitry Andric 
570e8d8bef9SDimitry Andric   bool isTrapHandlerEnabled() const {
571e8d8bef9SDimitry Andric     return TrapHandler;
572e8d8bef9SDimitry Andric   }
573e8d8bef9SDimitry Andric 
574e8d8bef9SDimitry Andric   bool isXNACKEnabled() const {
575e8d8bef9SDimitry Andric     return TargetID.isXnackOnOrAny();
576e8d8bef9SDimitry Andric   }
577e8d8bef9SDimitry Andric 
578fe6060f1SDimitry Andric   bool isTgSplitEnabled() const {
579fe6060f1SDimitry Andric     return EnableTgSplit;
580fe6060f1SDimitry Andric   }
581fe6060f1SDimitry Andric 
582e8d8bef9SDimitry Andric   bool isCuModeEnabled() const {
583e8d8bef9SDimitry Andric     return EnableCuMode;
584e8d8bef9SDimitry Andric   }
585e8d8bef9SDimitry Andric 
586e8d8bef9SDimitry Andric   bool hasFlatAddressSpace() const {
587e8d8bef9SDimitry Andric     return FlatAddressSpace;
588e8d8bef9SDimitry Andric   }
589e8d8bef9SDimitry Andric 
590e8d8bef9SDimitry Andric   bool hasFlatScrRegister() const {
591e8d8bef9SDimitry Andric     return hasFlatAddressSpace();
592e8d8bef9SDimitry Andric   }
593e8d8bef9SDimitry Andric 
594e8d8bef9SDimitry Andric   bool hasFlatInstOffsets() const {
595e8d8bef9SDimitry Andric     return FlatInstOffsets;
596e8d8bef9SDimitry Andric   }
597e8d8bef9SDimitry Andric 
598e8d8bef9SDimitry Andric   bool hasFlatGlobalInsts() const {
599e8d8bef9SDimitry Andric     return FlatGlobalInsts;
600e8d8bef9SDimitry Andric   }
601e8d8bef9SDimitry Andric 
602e8d8bef9SDimitry Andric   bool hasFlatScratchInsts() const {
603e8d8bef9SDimitry Andric     return FlatScratchInsts;
604e8d8bef9SDimitry Andric   }
605e8d8bef9SDimitry Andric 
606e8d8bef9SDimitry Andric   // Check if target supports ST addressing mode with FLAT scratch instructions.
607e8d8bef9SDimitry Andric   // The ST addressing mode means no registers are used, either VGPR or SGPR,
608e8d8bef9SDimitry Andric   // but only immediate offset is swizzled and added to the FLAT scratch base.
609e8d8bef9SDimitry Andric   bool hasFlatScratchSTMode() const {
61081ad6265SDimitry Andric     return hasFlatScratchInsts() && (hasGFX10_3Insts() || hasGFX940Insts());
611e8d8bef9SDimitry Andric   }
612e8d8bef9SDimitry Andric 
61381ad6265SDimitry Andric   bool hasFlatScratchSVSMode() const { return GFX940Insts || GFX11Insts; }
61481ad6265SDimitry Andric 
615e8d8bef9SDimitry Andric   bool hasScalarFlatScratchInsts() const {
616e8d8bef9SDimitry Andric     return ScalarFlatScratchInsts;
617e8d8bef9SDimitry Andric   }
618e8d8bef9SDimitry Andric 
61981ad6265SDimitry Andric   bool enableFlatScratch() const {
62081ad6265SDimitry Andric     return flatScratchIsArchitected() ||
62181ad6265SDimitry Andric            (EnableFlatScratch && hasFlatScratchInsts());
62281ad6265SDimitry Andric   }
62381ad6265SDimitry Andric 
624e8d8bef9SDimitry Andric   bool hasGlobalAddTidInsts() const {
625e8d8bef9SDimitry Andric     return GFX10_BEncoding;
626e8d8bef9SDimitry Andric   }
627e8d8bef9SDimitry Andric 
628e8d8bef9SDimitry Andric   bool hasAtomicCSub() const {
629e8d8bef9SDimitry Andric     return GFX10_BEncoding;
630e8d8bef9SDimitry Andric   }
631e8d8bef9SDimitry Andric 
632e8d8bef9SDimitry Andric   bool hasMultiDwordFlatScratchAddressing() const {
633e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
634e8d8bef9SDimitry Andric   }
635e8d8bef9SDimitry Andric 
636e8d8bef9SDimitry Andric   bool hasFlatSegmentOffsetBug() const {
637e8d8bef9SDimitry Andric     return HasFlatSegmentOffsetBug;
638e8d8bef9SDimitry Andric   }
639e8d8bef9SDimitry Andric 
640e8d8bef9SDimitry Andric   bool hasFlatLgkmVMemCountInOrder() const {
641e8d8bef9SDimitry Andric     return getGeneration() > GFX9;
642e8d8bef9SDimitry Andric   }
643e8d8bef9SDimitry Andric 
644e8d8bef9SDimitry Andric   bool hasD16LoadStore() const {
645e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
646e8d8bef9SDimitry Andric   }
647e8d8bef9SDimitry Andric 
648e8d8bef9SDimitry Andric   bool d16PreservesUnusedBits() const {
649e8d8bef9SDimitry Andric     return hasD16LoadStore() && !TargetID.isSramEccOnOrAny();
650e8d8bef9SDimitry Andric   }
651e8d8bef9SDimitry Andric 
652e8d8bef9SDimitry Andric   bool hasD16Images() const {
653e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
654e8d8bef9SDimitry Andric   }
655e8d8bef9SDimitry Andric 
656e8d8bef9SDimitry Andric   /// Return if most LDS instructions have an m0 use that require m0 to be
657349cc55cSDimitry Andric   /// initialized.
658e8d8bef9SDimitry Andric   bool ldsRequiresM0Init() const {
659e8d8bef9SDimitry Andric     return getGeneration() < GFX9;
660e8d8bef9SDimitry Andric   }
661e8d8bef9SDimitry Andric 
662e8d8bef9SDimitry Andric   // True if the hardware rewinds and replays GWS operations if a wave is
663e8d8bef9SDimitry Andric   // preempted.
664e8d8bef9SDimitry Andric   //
665e8d8bef9SDimitry Andric   // If this is false, a GWS operation requires testing if a nack set the
666e8d8bef9SDimitry Andric   // MEM_VIOL bit, and repeating if so.
667e8d8bef9SDimitry Andric   bool hasGWSAutoReplay() const {
668e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
669e8d8bef9SDimitry Andric   }
670e8d8bef9SDimitry Andric 
671e8d8bef9SDimitry Andric   /// \returns if target has ds_gws_sema_release_all instruction.
672e8d8bef9SDimitry Andric   bool hasGWSSemaReleaseAll() const {
673e8d8bef9SDimitry Andric     return CIInsts;
674e8d8bef9SDimitry Andric   }
675e8d8bef9SDimitry Andric 
676e8d8bef9SDimitry Andric   /// \returns true if the target has integer add/sub instructions that do not
677e8d8bef9SDimitry Andric   /// produce a carry-out. This includes v_add_[iu]32, v_sub_[iu]32,
678e8d8bef9SDimitry Andric   /// v_add_[iu]16, and v_sub_[iu]16, all of which support the clamp modifier
679e8d8bef9SDimitry Andric   /// for saturation.
680e8d8bef9SDimitry Andric   bool hasAddNoCarry() const {
681e8d8bef9SDimitry Andric     return AddNoCarryInsts;
682e8d8bef9SDimitry Andric   }
683e8d8bef9SDimitry Andric 
6845f757f3fSDimitry Andric   bool hasScalarAddSub64() const { return getGeneration() >= GFX12; }
6855f757f3fSDimitry Andric 
686*1db9f3b2SDimitry Andric   bool hasScalarSMulU64() const { return getGeneration() >= GFX12; }
687*1db9f3b2SDimitry Andric 
688e8d8bef9SDimitry Andric   bool hasUnpackedD16VMem() const {
689e8d8bef9SDimitry Andric     return HasUnpackedD16VMem;
690e8d8bef9SDimitry Andric   }
691e8d8bef9SDimitry Andric 
692e8d8bef9SDimitry Andric   // Covers VS/PS/CS graphics shaders
693e8d8bef9SDimitry Andric   bool isMesaGfxShader(const Function &F) const {
694e8d8bef9SDimitry Andric     return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
695e8d8bef9SDimitry Andric   }
696e8d8bef9SDimitry Andric 
697e8d8bef9SDimitry Andric   bool hasMad64_32() const {
698e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
699e8d8bef9SDimitry Andric   }
700e8d8bef9SDimitry Andric 
701e8d8bef9SDimitry Andric   bool hasSDWAOmod() const {
702e8d8bef9SDimitry Andric     return HasSDWAOmod;
703e8d8bef9SDimitry Andric   }
704e8d8bef9SDimitry Andric 
705e8d8bef9SDimitry Andric   bool hasSDWAScalar() const {
706e8d8bef9SDimitry Andric     return HasSDWAScalar;
707e8d8bef9SDimitry Andric   }
708e8d8bef9SDimitry Andric 
709e8d8bef9SDimitry Andric   bool hasSDWASdst() const {
710e8d8bef9SDimitry Andric     return HasSDWASdst;
711e8d8bef9SDimitry Andric   }
712e8d8bef9SDimitry Andric 
713e8d8bef9SDimitry Andric   bool hasSDWAMac() const {
714e8d8bef9SDimitry Andric     return HasSDWAMac;
715e8d8bef9SDimitry Andric   }
716e8d8bef9SDimitry Andric 
717e8d8bef9SDimitry Andric   bool hasSDWAOutModsVOPC() const {
718e8d8bef9SDimitry Andric     return HasSDWAOutModsVOPC;
719e8d8bef9SDimitry Andric   }
720e8d8bef9SDimitry Andric 
721e8d8bef9SDimitry Andric   bool hasDLInsts() const {
722e8d8bef9SDimitry Andric     return HasDLInsts;
723e8d8bef9SDimitry Andric   }
724e8d8bef9SDimitry Andric 
725bdd1243dSDimitry Andric   bool hasFmacF64Inst() const { return HasFmacF64Inst; }
726bdd1243dSDimitry Andric 
727e8d8bef9SDimitry Andric   bool hasDot1Insts() const {
728e8d8bef9SDimitry Andric     return HasDot1Insts;
729e8d8bef9SDimitry Andric   }
730e8d8bef9SDimitry Andric 
731e8d8bef9SDimitry Andric   bool hasDot2Insts() const {
732e8d8bef9SDimitry Andric     return HasDot2Insts;
733e8d8bef9SDimitry Andric   }
734e8d8bef9SDimitry Andric 
735e8d8bef9SDimitry Andric   bool hasDot3Insts() const {
736e8d8bef9SDimitry Andric     return HasDot3Insts;
737e8d8bef9SDimitry Andric   }
738e8d8bef9SDimitry Andric 
739e8d8bef9SDimitry Andric   bool hasDot4Insts() const {
740e8d8bef9SDimitry Andric     return HasDot4Insts;
741e8d8bef9SDimitry Andric   }
742e8d8bef9SDimitry Andric 
743e8d8bef9SDimitry Andric   bool hasDot5Insts() const {
744e8d8bef9SDimitry Andric     return HasDot5Insts;
745e8d8bef9SDimitry Andric   }
746e8d8bef9SDimitry Andric 
747e8d8bef9SDimitry Andric   bool hasDot6Insts() const {
748e8d8bef9SDimitry Andric     return HasDot6Insts;
749e8d8bef9SDimitry Andric   }
750e8d8bef9SDimitry Andric 
751fe6060f1SDimitry Andric   bool hasDot7Insts() const {
752fe6060f1SDimitry Andric     return HasDot7Insts;
753fe6060f1SDimitry Andric   }
754fe6060f1SDimitry Andric 
75581ad6265SDimitry Andric   bool hasDot8Insts() const {
75681ad6265SDimitry Andric     return HasDot8Insts;
75781ad6265SDimitry Andric   }
75881ad6265SDimitry Andric 
759bdd1243dSDimitry Andric   bool hasDot9Insts() const {
760bdd1243dSDimitry Andric     return HasDot9Insts;
761bdd1243dSDimitry Andric   }
762bdd1243dSDimitry Andric 
76306c3fb27SDimitry Andric   bool hasDot10Insts() const {
76406c3fb27SDimitry Andric     return HasDot10Insts;
76506c3fb27SDimitry Andric   }
76606c3fb27SDimitry Andric 
767e8d8bef9SDimitry Andric   bool hasMAIInsts() const {
768e8d8bef9SDimitry Andric     return HasMAIInsts;
769e8d8bef9SDimitry Andric   }
770e8d8bef9SDimitry Andric 
771fcaf7f86SDimitry Andric   bool hasFP8Insts() const {
772fcaf7f86SDimitry Andric     return HasFP8Insts;
773fcaf7f86SDimitry Andric   }
774fcaf7f86SDimitry Andric 
775e8d8bef9SDimitry Andric   bool hasPkFmacF16Inst() const {
776e8d8bef9SDimitry Andric     return HasPkFmacF16Inst;
777e8d8bef9SDimitry Andric   }
778e8d8bef9SDimitry Andric 
77906c3fb27SDimitry Andric   bool hasAtomicDsPkAdd16Insts() const { return HasAtomicDsPkAdd16Insts; }
78006c3fb27SDimitry Andric 
78106c3fb27SDimitry Andric   bool hasAtomicFlatPkAdd16Insts() const { return HasAtomicFlatPkAdd16Insts; }
78206c3fb27SDimitry Andric 
783e8d8bef9SDimitry Andric   bool hasAtomicFaddInsts() const {
78481ad6265SDimitry Andric     return HasAtomicFaddRtnInsts || HasAtomicFaddNoRtnInsts;
785e8d8bef9SDimitry Andric   }
786e8d8bef9SDimitry Andric 
78781ad6265SDimitry Andric   bool hasAtomicFaddRtnInsts() const { return HasAtomicFaddRtnInsts; }
78881ad6265SDimitry Andric 
78981ad6265SDimitry Andric   bool hasAtomicFaddNoRtnInsts() const { return HasAtomicFaddNoRtnInsts; }
79081ad6265SDimitry Andric 
79106c3fb27SDimitry Andric   bool hasAtomicBufferGlobalPkAddF16NoRtnInsts() const {
79206c3fb27SDimitry Andric     return HasAtomicBufferGlobalPkAddF16NoRtnInsts;
79306c3fb27SDimitry Andric   }
79406c3fb27SDimitry Andric 
79506c3fb27SDimitry Andric   bool hasAtomicBufferGlobalPkAddF16Insts() const {
79606c3fb27SDimitry Andric     return HasAtomicBufferGlobalPkAddF16Insts;
79706c3fb27SDimitry Andric   }
79806c3fb27SDimitry Andric 
79906c3fb27SDimitry Andric   bool hasAtomicGlobalPkAddBF16Inst() const {
80006c3fb27SDimitry Andric     return HasAtomicGlobalPkAddBF16Inst;
80106c3fb27SDimitry Andric   }
80281ad6265SDimitry Andric 
803bdd1243dSDimitry Andric   bool hasFlatAtomicFaddF32Inst() const { return HasFlatAtomicFaddF32Inst; }
804bdd1243dSDimitry Andric 
805e8d8bef9SDimitry Andric   bool hasNoSdstCMPX() const {
806e8d8bef9SDimitry Andric     return HasNoSdstCMPX;
807e8d8bef9SDimitry Andric   }
808e8d8bef9SDimitry Andric 
809e8d8bef9SDimitry Andric   bool hasVscnt() const {
810e8d8bef9SDimitry Andric     return HasVscnt;
811e8d8bef9SDimitry Andric   }
812e8d8bef9SDimitry Andric 
813e8d8bef9SDimitry Andric   bool hasGetWaveIdInst() const {
814e8d8bef9SDimitry Andric     return HasGetWaveIdInst;
815e8d8bef9SDimitry Andric   }
816e8d8bef9SDimitry Andric 
817e8d8bef9SDimitry Andric   bool hasSMemTimeInst() const {
818e8d8bef9SDimitry Andric     return HasSMemTimeInst;
819e8d8bef9SDimitry Andric   }
820e8d8bef9SDimitry Andric 
821fe6060f1SDimitry Andric   bool hasShaderCyclesRegister() const {
822fe6060f1SDimitry Andric     return HasShaderCyclesRegister;
823fe6060f1SDimitry Andric   }
824fe6060f1SDimitry Andric 
825*1db9f3b2SDimitry Andric   bool hasShaderCyclesHiLoRegisters() const {
826*1db9f3b2SDimitry Andric     return HasShaderCyclesHiLoRegisters;
827*1db9f3b2SDimitry Andric   }
828*1db9f3b2SDimitry Andric 
829e8d8bef9SDimitry Andric   bool hasVOP3Literal() const {
830e8d8bef9SDimitry Andric     return HasVOP3Literal;
831e8d8bef9SDimitry Andric   }
832e8d8bef9SDimitry Andric 
833e8d8bef9SDimitry Andric   bool hasNoDataDepHazard() const {
834e8d8bef9SDimitry Andric     return HasNoDataDepHazard;
835e8d8bef9SDimitry Andric   }
836e8d8bef9SDimitry Andric 
837e8d8bef9SDimitry Andric   bool vmemWriteNeedsExpWaitcnt() const {
838e8d8bef9SDimitry Andric     return getGeneration() < SEA_ISLANDS;
839e8d8bef9SDimitry Andric   }
840e8d8bef9SDimitry Andric 
841bdd1243dSDimitry Andric   bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
842bdd1243dSDimitry Andric 
8435f757f3fSDimitry Andric   bool hasPrefetch() const { return GFX12Insts; }
8445f757f3fSDimitry Andric 
8455f757f3fSDimitry Andric   // Has s_cmpk_* instructions.
8465f757f3fSDimitry Andric   bool hasSCmpK() const { return getGeneration() < GFX12; }
8475f757f3fSDimitry Andric 
848e8d8bef9SDimitry Andric   // Scratch is allocated in 256 dword per wave blocks for the entire
849349cc55cSDimitry Andric   // wavefront. When viewed from the perspective of an arbitrary workitem, this
850e8d8bef9SDimitry Andric   // is 4-byte aligned.
851e8d8bef9SDimitry Andric   //
852e8d8bef9SDimitry Andric   // Only 4-byte alignment is really needed to access anything. Transformations
853e8d8bef9SDimitry Andric   // on the pointer value itself may rely on the alignment / known low bits of
854e8d8bef9SDimitry Andric   // the pointer. Set this to something above the minimum to avoid needing
855e8d8bef9SDimitry Andric   // dynamic realignment in common cases.
856e8d8bef9SDimitry Andric   Align getStackAlignment() const { return Align(16); }
857e8d8bef9SDimitry Andric 
858e8d8bef9SDimitry Andric   bool enableMachineScheduler() const override {
859e8d8bef9SDimitry Andric     return true;
860e8d8bef9SDimitry Andric   }
861e8d8bef9SDimitry Andric 
862e8d8bef9SDimitry Andric   bool useAA() const override;
863e8d8bef9SDimitry Andric 
864e8d8bef9SDimitry Andric   bool enableSubRegLiveness() const override {
865e8d8bef9SDimitry Andric     return true;
866e8d8bef9SDimitry Andric   }
867e8d8bef9SDimitry Andric 
868e8d8bef9SDimitry Andric   void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; }
869e8d8bef9SDimitry Andric   bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; }
870e8d8bef9SDimitry Andric 
871e8d8bef9SDimitry Andric   // static wrappers
872e8d8bef9SDimitry Andric   static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
873e8d8bef9SDimitry Andric 
874e8d8bef9SDimitry Andric   // XXX - Why is this here if it isn't in the default pass set?
875e8d8bef9SDimitry Andric   bool enableEarlyIfConversion() const override {
876e8d8bef9SDimitry Andric     return true;
877e8d8bef9SDimitry Andric   }
878e8d8bef9SDimitry Andric 
879e8d8bef9SDimitry Andric   void overrideSchedPolicy(MachineSchedPolicy &Policy,
880e8d8bef9SDimitry Andric                            unsigned NumRegionInstrs) const override;
881e8d8bef9SDimitry Andric 
882e8d8bef9SDimitry Andric   unsigned getMaxNumUserSGPRs() const {
8835f757f3fSDimitry Andric     return AMDGPU::getMaxNumUserSGPRs(*this);
884e8d8bef9SDimitry Andric   }
885e8d8bef9SDimitry Andric 
886e8d8bef9SDimitry Andric   bool hasSMemRealTime() const {
887e8d8bef9SDimitry Andric     return HasSMemRealTime;
888e8d8bef9SDimitry Andric   }
889e8d8bef9SDimitry Andric 
890e8d8bef9SDimitry Andric   bool hasMovrel() const {
891e8d8bef9SDimitry Andric     return HasMovrel;
892e8d8bef9SDimitry Andric   }
893e8d8bef9SDimitry Andric 
894e8d8bef9SDimitry Andric   bool hasVGPRIndexMode() const {
895e8d8bef9SDimitry Andric     return HasVGPRIndexMode;
896e8d8bef9SDimitry Andric   }
897e8d8bef9SDimitry Andric 
898e8d8bef9SDimitry Andric   bool useVGPRIndexMode() const;
899e8d8bef9SDimitry Andric 
900e8d8bef9SDimitry Andric   bool hasScalarCompareEq64() const {
901e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
902e8d8bef9SDimitry Andric   }
903e8d8bef9SDimitry Andric 
9045f757f3fSDimitry Andric   bool hasScalarDwordx3Loads() const { return HasScalarDwordx3Loads; }
9055f757f3fSDimitry Andric 
906e8d8bef9SDimitry Andric   bool hasScalarStores() const {
907e8d8bef9SDimitry Andric     return HasScalarStores;
908e8d8bef9SDimitry Andric   }
909e8d8bef9SDimitry Andric 
910e8d8bef9SDimitry Andric   bool hasScalarAtomics() const {
911e8d8bef9SDimitry Andric     return HasScalarAtomics;
912e8d8bef9SDimitry Andric   }
913e8d8bef9SDimitry Andric 
914349cc55cSDimitry Andric   bool hasLDSFPAtomicAdd() const { return GFX8Insts; }
915e8d8bef9SDimitry Andric 
916fe6060f1SDimitry Andric   /// \returns true if the subtarget has the v_permlanex16_b32 instruction.
917fe6060f1SDimitry Andric   bool hasPermLaneX16() const { return getGeneration() >= GFX10; }
918fe6060f1SDimitry Andric 
91981ad6265SDimitry Andric   /// \returns true if the subtarget has the v_permlane64_b32 instruction.
92081ad6265SDimitry Andric   bool hasPermLane64() const { return getGeneration() >= GFX11; }
92181ad6265SDimitry Andric 
922e8d8bef9SDimitry Andric   bool hasDPP() const {
923e8d8bef9SDimitry Andric     return HasDPP;
924e8d8bef9SDimitry Andric   }
925e8d8bef9SDimitry Andric 
926e8d8bef9SDimitry Andric   bool hasDPPBroadcasts() const {
927e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
928e8d8bef9SDimitry Andric   }
929e8d8bef9SDimitry Andric 
930e8d8bef9SDimitry Andric   bool hasDPPWavefrontShifts() const {
931e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
932e8d8bef9SDimitry Andric   }
933e8d8bef9SDimitry Andric 
934e8d8bef9SDimitry Andric   bool hasDPP8() const {
935e8d8bef9SDimitry Andric     return HasDPP8;
936e8d8bef9SDimitry Andric   }
937e8d8bef9SDimitry Andric 
9385f757f3fSDimitry Andric   bool hasDPALU_DPP() const {
9395f757f3fSDimitry Andric     return HasDPALU_DPP;
940fe6060f1SDimitry Andric   }
941fe6060f1SDimitry Andric 
9425f757f3fSDimitry Andric   bool hasDPPSrc1SGPR() const { return HasDPPSrc1SGPR; }
9435f757f3fSDimitry Andric 
944fe6060f1SDimitry Andric   bool hasPackedFP32Ops() const {
945fe6060f1SDimitry Andric     return HasPackedFP32Ops;
946fe6060f1SDimitry Andric   }
947fe6060f1SDimitry Andric 
9485f757f3fSDimitry Andric   // Has V_PK_MOV_B32 opcode
9495f757f3fSDimitry Andric   bool hasPkMovB32() const {
9505f757f3fSDimitry Andric     return GFX90AInsts;
9515f757f3fSDimitry Andric   }
9525f757f3fSDimitry Andric 
953fe6060f1SDimitry Andric   bool hasFmaakFmamkF32Insts() const {
95481ad6265SDimitry Andric     return getGeneration() >= GFX10 || hasGFX940Insts();
95581ad6265SDimitry Andric   }
95681ad6265SDimitry Andric 
95781ad6265SDimitry Andric   bool hasImageInsts() const {
95881ad6265SDimitry Andric     return HasImageInsts;
959fe6060f1SDimitry Andric   }
960fe6060f1SDimitry Andric 
961fe6060f1SDimitry Andric   bool hasExtendedImageInsts() const {
962fe6060f1SDimitry Andric     return HasExtendedImageInsts;
963fe6060f1SDimitry Andric   }
964fe6060f1SDimitry Andric 
965e8d8bef9SDimitry Andric   bool hasR128A16() const {
966e8d8bef9SDimitry Andric     return HasR128A16;
967e8d8bef9SDimitry Andric   }
968e8d8bef9SDimitry Andric 
969bdd1243dSDimitry Andric   bool hasA16() const { return HasA16; }
970e8d8bef9SDimitry Andric 
971e8d8bef9SDimitry Andric   bool hasG16() const { return HasG16; }
972e8d8bef9SDimitry Andric 
973e8d8bef9SDimitry Andric   bool hasOffset3fBug() const {
974e8d8bef9SDimitry Andric     return HasOffset3fBug;
975e8d8bef9SDimitry Andric   }
976e8d8bef9SDimitry Andric 
977e8d8bef9SDimitry Andric   bool hasImageStoreD16Bug() const { return HasImageStoreD16Bug; }
978e8d8bef9SDimitry Andric 
979e8d8bef9SDimitry Andric   bool hasImageGather4D16Bug() const { return HasImageGather4D16Bug; }
980e8d8bef9SDimitry Andric 
981bdd1243dSDimitry Andric   bool hasMADIntraFwdBug() const { return HasMADIntraFwdBug; }
982bdd1243dSDimitry Andric 
9835f757f3fSDimitry Andric   bool hasMSAALoadDstSelBug() const { return HasMSAALoadDstSelBug; }
9845f757f3fSDimitry Andric 
985e8d8bef9SDimitry Andric   bool hasNSAEncoding() const { return HasNSAEncoding; }
986e8d8bef9SDimitry Andric 
98706c3fb27SDimitry Andric   bool hasPartialNSAEncoding() const { return HasPartialNSAEncoding; }
98806c3fb27SDimitry Andric 
9895f757f3fSDimitry Andric   unsigned getNSAMaxSize(bool HasSampler = false) const {
9905f757f3fSDimitry Andric     return AMDGPU::getNSAMaxSize(*this, HasSampler);
9915f757f3fSDimitry Andric   }
992fe6060f1SDimitry Andric 
993fe6060f1SDimitry Andric   bool hasGFX10_AEncoding() const {
994fe6060f1SDimitry Andric     return GFX10_AEncoding;
995fe6060f1SDimitry Andric   }
996fe6060f1SDimitry Andric 
997e8d8bef9SDimitry Andric   bool hasGFX10_BEncoding() const {
998e8d8bef9SDimitry Andric     return GFX10_BEncoding;
999e8d8bef9SDimitry Andric   }
1000e8d8bef9SDimitry Andric 
1001e8d8bef9SDimitry Andric   bool hasGFX10_3Insts() const {
1002e8d8bef9SDimitry Andric     return GFX10_3Insts;
1003e8d8bef9SDimitry Andric   }
1004e8d8bef9SDimitry Andric 
1005e8d8bef9SDimitry Andric   bool hasMadF16() const;
1006e8d8bef9SDimitry Andric 
100781ad6265SDimitry Andric   bool hasMovB64() const { return GFX940Insts; }
100881ad6265SDimitry Andric 
100981ad6265SDimitry Andric   bool hasLshlAddB64() const { return GFX940Insts; }
101081ad6265SDimitry Andric 
1011e8d8bef9SDimitry Andric   bool enableSIScheduler() const {
1012e8d8bef9SDimitry Andric     return EnableSIScheduler;
1013e8d8bef9SDimitry Andric   }
1014e8d8bef9SDimitry Andric 
1015e8d8bef9SDimitry Andric   bool loadStoreOptEnabled() const {
1016e8d8bef9SDimitry Andric     return EnableLoadStoreOpt;
1017e8d8bef9SDimitry Andric   }
1018e8d8bef9SDimitry Andric 
1019e8d8bef9SDimitry Andric   bool hasSGPRInitBug() const {
1020e8d8bef9SDimitry Andric     return SGPRInitBug;
1021e8d8bef9SDimitry Andric   }
1022e8d8bef9SDimitry Andric 
102381ad6265SDimitry Andric   bool hasUserSGPRInit16Bug() const {
1024fcaf7f86SDimitry Andric     return UserSGPRInit16Bug && isWave32();
102581ad6265SDimitry Andric   }
102681ad6265SDimitry Andric 
1027fe6060f1SDimitry Andric   bool hasNegativeScratchOffsetBug() const { return NegativeScratchOffsetBug; }
1028fe6060f1SDimitry Andric 
1029fe6060f1SDimitry Andric   bool hasNegativeUnalignedScratchOffsetBug() const {
1030fe6060f1SDimitry Andric     return NegativeUnalignedScratchOffsetBug;
1031fe6060f1SDimitry Andric   }
1032fe6060f1SDimitry Andric 
1033e8d8bef9SDimitry Andric   bool hasMFMAInlineLiteralBug() const {
1034e8d8bef9SDimitry Andric     return HasMFMAInlineLiteralBug;
1035e8d8bef9SDimitry Andric   }
1036e8d8bef9SDimitry Andric 
1037e8d8bef9SDimitry Andric   bool has12DWordStoreHazard() const {
1038e8d8bef9SDimitry Andric     return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
1039e8d8bef9SDimitry Andric   }
1040e8d8bef9SDimitry Andric 
1041e8d8bef9SDimitry Andric   // \returns true if the subtarget supports DWORDX3 load/store instructions.
1042e8d8bef9SDimitry Andric   bool hasDwordx3LoadStores() const {
1043e8d8bef9SDimitry Andric     return CIInsts;
1044e8d8bef9SDimitry Andric   }
1045e8d8bef9SDimitry Andric 
1046e8d8bef9SDimitry Andric   bool hasReadM0MovRelInterpHazard() const {
1047e8d8bef9SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
1048e8d8bef9SDimitry Andric   }
1049e8d8bef9SDimitry Andric 
1050e8d8bef9SDimitry Andric   bool hasReadM0SendMsgHazard() const {
1051e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&
1052e8d8bef9SDimitry Andric            getGeneration() <= AMDGPUSubtarget::GFX9;
1053e8d8bef9SDimitry Andric   }
1054e8d8bef9SDimitry Andric 
105581ad6265SDimitry Andric   bool hasReadM0LdsDmaHazard() const {
105681ad6265SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
105781ad6265SDimitry Andric   }
105881ad6265SDimitry Andric 
105981ad6265SDimitry Andric   bool hasReadM0LdsDirectHazard() const {
106081ad6265SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
106181ad6265SDimitry Andric   }
106281ad6265SDimitry Andric 
1063e8d8bef9SDimitry Andric   bool hasVcmpxPermlaneHazard() const {
1064e8d8bef9SDimitry Andric     return HasVcmpxPermlaneHazard;
1065e8d8bef9SDimitry Andric   }
1066e8d8bef9SDimitry Andric 
1067e8d8bef9SDimitry Andric   bool hasVMEMtoScalarWriteHazard() const {
1068e8d8bef9SDimitry Andric     return HasVMEMtoScalarWriteHazard;
1069e8d8bef9SDimitry Andric   }
1070e8d8bef9SDimitry Andric 
1071e8d8bef9SDimitry Andric   bool hasSMEMtoVectorWriteHazard() const {
1072e8d8bef9SDimitry Andric     return HasSMEMtoVectorWriteHazard;
1073e8d8bef9SDimitry Andric   }
1074e8d8bef9SDimitry Andric 
1075e8d8bef9SDimitry Andric   bool hasLDSMisalignedBug() const {
1076e8d8bef9SDimitry Andric     return LDSMisalignedBug && !EnableCuMode;
1077e8d8bef9SDimitry Andric   }
1078e8d8bef9SDimitry Andric 
1079e8d8bef9SDimitry Andric   bool hasInstFwdPrefetchBug() const {
1080e8d8bef9SDimitry Andric     return HasInstFwdPrefetchBug;
1081e8d8bef9SDimitry Andric   }
1082e8d8bef9SDimitry Andric 
1083e8d8bef9SDimitry Andric   bool hasVcmpxExecWARHazard() const {
1084e8d8bef9SDimitry Andric     return HasVcmpxExecWARHazard;
1085e8d8bef9SDimitry Andric   }
1086e8d8bef9SDimitry Andric 
1087e8d8bef9SDimitry Andric   bool hasLdsBranchVmemWARHazard() const {
1088e8d8bef9SDimitry Andric     return HasLdsBranchVmemWARHazard;
1089e8d8bef9SDimitry Andric   }
1090e8d8bef9SDimitry Andric 
1091bdd1243dSDimitry Andric   // Shift amount of a 64 bit shift cannot be a highest allocated register
1092bdd1243dSDimitry Andric   // if also at the end of the allocation block.
1093bdd1243dSDimitry Andric   bool hasShift64HighRegBug() const {
1094bdd1243dSDimitry Andric     return GFX90AInsts && !GFX940Insts;
1095bdd1243dSDimitry Andric   }
1096bdd1243dSDimitry Andric 
109781ad6265SDimitry Andric   // Has one cycle hazard on transcendental instruction feeding a
109881ad6265SDimitry Andric   // non transcendental VALU.
109981ad6265SDimitry Andric   bool hasTransForwardingHazard() const { return GFX940Insts; }
110081ad6265SDimitry Andric 
110181ad6265SDimitry Andric   // Has one cycle hazard on a VALU instruction partially writing dst with
110281ad6265SDimitry Andric   // a shift of result bits feeding another VALU instruction.
110381ad6265SDimitry Andric   bool hasDstSelForwardingHazard() const { return GFX940Insts; }
110481ad6265SDimitry Andric 
110581ad6265SDimitry Andric   // Cannot use op_sel with v_dot instructions.
1106*1db9f3b2SDimitry Andric   bool hasDOTOpSelHazard() const { return GFX940Insts || GFX11Insts; }
110781ad6265SDimitry Andric 
110881ad6265SDimitry Andric   // Does not have HW interlocs for VALU writing and then reading SGPRs.
110981ad6265SDimitry Andric   bool hasVDecCoExecHazard() const {
111081ad6265SDimitry Andric     return GFX940Insts;
111181ad6265SDimitry Andric   }
111281ad6265SDimitry Andric 
1113e8d8bef9SDimitry Andric   bool hasNSAtoVMEMBug() const {
1114e8d8bef9SDimitry Andric     return HasNSAtoVMEMBug;
1115e8d8bef9SDimitry Andric   }
1116e8d8bef9SDimitry Andric 
1117fe6060f1SDimitry Andric   bool hasNSAClauseBug() const { return HasNSAClauseBug; }
1118fe6060f1SDimitry Andric 
1119e8d8bef9SDimitry Andric   bool hasHardClauses() const { return getGeneration() >= GFX10; }
1120e8d8bef9SDimitry Andric 
1121fe6060f1SDimitry Andric   bool hasGFX90AInsts() const { return GFX90AInsts; }
1122fe6060f1SDimitry Andric 
1123bdd1243dSDimitry Andric   bool hasFPAtomicToDenormModeHazard() const {
1124bdd1243dSDimitry Andric     return getGeneration() == GFX10;
1125bdd1243dSDimitry Andric   }
1126bdd1243dSDimitry Andric 
112781ad6265SDimitry Andric   bool hasVOP3DPP() const { return getGeneration() >= GFX11; }
112881ad6265SDimitry Andric 
112981ad6265SDimitry Andric   bool hasLdsDirect() const { return getGeneration() >= GFX11; }
113081ad6265SDimitry Andric 
113181ad6265SDimitry Andric   bool hasVALUPartialForwardingHazard() const {
113281ad6265SDimitry Andric     return getGeneration() >= GFX11;
113381ad6265SDimitry Andric   }
113481ad6265SDimitry Andric 
1135bdd1243dSDimitry Andric   bool hasVALUTransUseHazard() const { return HasVALUTransUseHazard; }
1136bdd1243dSDimitry Andric 
113706c3fb27SDimitry Andric   bool hasForceStoreSC0SC1() const { return HasForceStoreSC0SC1; }
113806c3fb27SDimitry Andric 
1139bdd1243dSDimitry Andric   bool hasVALUMaskWriteHazard() const { return getGeneration() >= GFX11; }
114081ad6265SDimitry Andric 
1141fe6060f1SDimitry Andric   /// Return if operations acting on VGPR tuples require even alignment.
1142fe6060f1SDimitry Andric   bool needsAlignedVGPRs() const { return GFX90AInsts; }
1143fe6060f1SDimitry Andric 
114481ad6265SDimitry Andric   /// Return true if the target has the S_PACK_HL_B32_B16 instruction.
114581ad6265SDimitry Andric   bool hasSPackHL() const { return GFX11Insts; }
114681ad6265SDimitry Andric 
114781ad6265SDimitry Andric   /// Return true if the target's EXP instruction has the COMPR flag, which
114881ad6265SDimitry Andric   /// affects the meaning of the EN (enable) bits.
114981ad6265SDimitry Andric   bool hasCompressedExport() const { return !GFX11Insts; }
115081ad6265SDimitry Andric 
115181ad6265SDimitry Andric   /// Return true if the target's EXP instruction supports the NULL export
115281ad6265SDimitry Andric   /// target.
115381ad6265SDimitry Andric   bool hasNullExportTarget() const { return !GFX11Insts; }
115481ad6265SDimitry Andric 
1155bdd1243dSDimitry Andric   bool hasGFX11FullVGPRs() const { return HasGFX11FullVGPRs; }
1156bdd1243dSDimitry Andric 
115781ad6265SDimitry Andric   bool hasVOPDInsts() const { return HasVOPDInsts; }
115881ad6265SDimitry Andric 
115981ad6265SDimitry Andric   bool hasFlatScratchSVSSwizzleBug() const { return getGeneration() == GFX11; }
116081ad6265SDimitry Andric 
116181ad6265SDimitry Andric   /// Return true if the target has the S_DELAY_ALU instruction.
116281ad6265SDimitry Andric   bool hasDelayAlu() const { return GFX11Insts; }
116381ad6265SDimitry Andric 
1164fe6060f1SDimitry Andric   bool hasPackedTID() const { return HasPackedTID; }
1165fe6060f1SDimitry Andric 
116681ad6265SDimitry Andric   // GFX940 is a derivation to GFX90A. hasGFX940Insts() being true implies that
116781ad6265SDimitry Andric   // hasGFX90AInsts is also true.
116881ad6265SDimitry Andric   bool hasGFX940Insts() const { return GFX940Insts; }
116981ad6265SDimitry Andric 
11705f757f3fSDimitry Andric   bool hasSALUFloatInsts() const { return HasSALUFloatInsts; }
11715f757f3fSDimitry Andric 
11725f757f3fSDimitry Andric   bool hasVGPRSingleUseHintInsts() const { return HasVGPRSingleUseHintInsts; }
11735f757f3fSDimitry Andric 
11745f757f3fSDimitry Andric   bool hasPseudoScalarTrans() const { return HasPseudoScalarTrans; }
11755f757f3fSDimitry Andric 
11765f757f3fSDimitry Andric   bool hasRestrictedSOffset() const { return HasRestrictedSOffset; }
11775f757f3fSDimitry Andric 
1178e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
1179e8d8bef9SDimitry Andric   /// SGPRs
1180e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
1181e8d8bef9SDimitry Andric 
1182e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
1183e8d8bef9SDimitry Andric   /// VGPRs
1184e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
1185e8d8bef9SDimitry Andric 
1186e8d8bef9SDimitry Andric   /// Return occupancy for the given function. Used LDS and a number of
1187e8d8bef9SDimitry Andric   /// registers if provided.
1188e8d8bef9SDimitry Andric   /// Note, occupancy can be affected by the scratch allocation as well, but
1189e8d8bef9SDimitry Andric   /// we do not have enough information to compute it.
1190e8d8bef9SDimitry Andric   unsigned computeOccupancy(const Function &F, unsigned LDSSize = 0,
1191e8d8bef9SDimitry Andric                             unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const;
1192e8d8bef9SDimitry Andric 
1193e8d8bef9SDimitry Andric   /// \returns true if the flat_scratch register should be initialized with the
1194e8d8bef9SDimitry Andric   /// pointer to the wave's scratch memory rather than a size and offset.
1195e8d8bef9SDimitry Andric   bool flatScratchIsPointer() const {
1196e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
1197e8d8bef9SDimitry Andric   }
1198e8d8bef9SDimitry Andric 
1199fe6060f1SDimitry Andric   /// \returns true if the flat_scratch register is initialized by the HW.
1200fe6060f1SDimitry Andric   /// In this case it is readonly.
1201fe6060f1SDimitry Andric   bool flatScratchIsArchitected() const { return HasArchitectedFlatScratch; }
1202fe6060f1SDimitry Andric 
120306c3fb27SDimitry Andric   /// \returns true if the architected SGPRs are enabled.
120406c3fb27SDimitry Andric   bool hasArchitectedSGPRs() const { return HasArchitectedSGPRs; }
120506c3fb27SDimitry Andric 
12065f757f3fSDimitry Andric   /// \returns true if Global Data Share is supported.
12075f757f3fSDimitry Andric   bool hasGDS() const { return HasGDS; }
12085f757f3fSDimitry Andric 
12095f757f3fSDimitry Andric   /// \returns true if Global Wave Sync is supported.
12105f757f3fSDimitry Andric   bool hasGWS() const { return HasGWS; }
12115f757f3fSDimitry Andric 
1212e8d8bef9SDimitry Andric   /// \returns true if the machine has merged shaders in which s0-s7 are
1213e8d8bef9SDimitry Andric   /// reserved by the hardware and user SGPRs start at s8
1214e8d8bef9SDimitry Andric   bool hasMergedShaders() const {
1215e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
1216e8d8bef9SDimitry Andric   }
1217e8d8bef9SDimitry Andric 
121881ad6265SDimitry Andric   // \returns true if the target supports the pre-NGG legacy geometry path.
121981ad6265SDimitry Andric   bool hasLegacyGeometry() const { return getGeneration() < GFX11; }
122081ad6265SDimitry Andric 
12215f757f3fSDimitry Andric   // \returns true if preloading kernel arguments is supported.
12225f757f3fSDimitry Andric   bool hasKernargPreload() const { return KernargPreload; }
12235f757f3fSDimitry Andric 
12245f757f3fSDimitry Andric   // \returns true if we need to generate backwards compatible code when
12255f757f3fSDimitry Andric   // preloading kernel arguments.
12265f757f3fSDimitry Andric   bool needsKernargPreloadBackwardsCompatibility() const {
12275f757f3fSDimitry Andric     return hasKernargPreload() && !hasGFX940Insts();
12285f757f3fSDimitry Andric   }
12295f757f3fSDimitry Andric 
12305f757f3fSDimitry Andric   // \returns true if the target has split barriers feature
12315f757f3fSDimitry Andric   bool hasSplitBarriers() const { return getGeneration() >= GFX12; }
12325f757f3fSDimitry Andric 
12335f757f3fSDimitry Andric   // \returns true if FP8/BF8 VOP1 form of conversion to F32 is unreliable.
12345f757f3fSDimitry Andric   bool hasCvtFP8VOP1Bug() const { return true; }
12355f757f3fSDimitry Andric 
12365f757f3fSDimitry Andric   // \returns true if CSUB (a.k.a. SUB_CLAMP on GFX12) atomics support a
12375f757f3fSDimitry Andric   // no-return form.
12385f757f3fSDimitry Andric   bool hasAtomicCSubNoRtnInsts() const { return HasAtomicCSubNoRtnInsts; }
12395f757f3fSDimitry Andric 
12405f757f3fSDimitry Andric   // \returns true if the target has DX10_CLAMP kernel descriptor mode bit
12415f757f3fSDimitry Andric   bool hasDX10ClampMode() const { return getGeneration() < GFX12; }
12425f757f3fSDimitry Andric 
12435f757f3fSDimitry Andric   // \returns true if the target has IEEE kernel descriptor mode bit
12445f757f3fSDimitry Andric   bool hasIEEEMode() const { return getGeneration() < GFX12; }
12455f757f3fSDimitry Andric 
12465f757f3fSDimitry Andric   // \returns true if the target has IEEE fminimum/fmaximum instructions
12475f757f3fSDimitry Andric   bool hasIEEEMinMax() const { return getGeneration() >= GFX12; }
12485f757f3fSDimitry Andric 
12495f757f3fSDimitry Andric   // \returns true if the target has WG_RR_MODE kernel descriptor mode bit
12505f757f3fSDimitry Andric   bool hasRrWGMode() const { return getGeneration() >= GFX12; }
12515f757f3fSDimitry Andric 
1252e8d8bef9SDimitry Andric   /// \returns SGPR allocation granularity supported by the subtarget.
1253e8d8bef9SDimitry Andric   unsigned getSGPRAllocGranule() const {
1254e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPRAllocGranule(this);
1255e8d8bef9SDimitry Andric   }
1256e8d8bef9SDimitry Andric 
1257e8d8bef9SDimitry Andric   /// \returns SGPR encoding granularity supported by the subtarget.
1258e8d8bef9SDimitry Andric   unsigned getSGPREncodingGranule() const {
1259e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPREncodingGranule(this);
1260e8d8bef9SDimitry Andric   }
1261e8d8bef9SDimitry Andric 
1262e8d8bef9SDimitry Andric   /// \returns Total number of SGPRs supported by the subtarget.
1263e8d8bef9SDimitry Andric   unsigned getTotalNumSGPRs() const {
1264e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumSGPRs(this);
1265e8d8bef9SDimitry Andric   }
1266e8d8bef9SDimitry Andric 
1267e8d8bef9SDimitry Andric   /// \returns Addressable number of SGPRs supported by the subtarget.
1268e8d8bef9SDimitry Andric   unsigned getAddressableNumSGPRs() const {
1269e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumSGPRs(this);
1270e8d8bef9SDimitry Andric   }
1271e8d8bef9SDimitry Andric 
1272e8d8bef9SDimitry Andric   /// \returns Minimum number of SGPRs that meets the given number of waves per
1273e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1274e8d8bef9SDimitry Andric   unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
1275e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU);
1276e8d8bef9SDimitry Andric   }
1277e8d8bef9SDimitry Andric 
1278e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets the given number of waves per
1279e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1280e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
1281e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable);
1282e8d8bef9SDimitry Andric   }
1283e8d8bef9SDimitry Andric 
1284fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs. This is common
1285fe6060f1SDimitry Andric   /// utility function called by MachineFunction and
1286fe6060f1SDimitry Andric   /// Function variants of getReservedNumSGPRs.
128704eeddc0SDimitry Andric   unsigned getBaseReservedNumSGPRs(const bool HasFlatScratch) const;
1288fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given machine function \p MF.
1289e8d8bef9SDimitry Andric   unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
1290e8d8bef9SDimitry Andric 
1291fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given function \p F.
1292fe6060f1SDimitry Andric   unsigned getReservedNumSGPRs(const Function &F) const;
1293fe6060f1SDimitry Andric 
1294fe6060f1SDimitry Andric   /// \returns max num SGPRs. This is the common utility
1295fe6060f1SDimitry Andric   /// function called by MachineFunction and Function
1296fe6060f1SDimitry Andric   /// variants of getMaxNumSGPRs.
1297fe6060f1SDimitry Andric   unsigned getBaseMaxNumSGPRs(const Function &F,
1298fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU,
1299fe6060f1SDimitry Andric                               unsigned PreloadedSGPRs,
1300fe6060f1SDimitry Andric                               unsigned ReservedNumSGPRs) const;
1301fe6060f1SDimitry Andric 
1302e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1303e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of SGPRs explicitly
1304e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
1305e8d8bef9SDimitry Andric   ///
1306e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1307e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1308e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1309e8d8bef9SDimitry Andric   /// unit requirement.
1310e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
1311e8d8bef9SDimitry Andric 
1312fe6060f1SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1313fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of SGPRs explicitly
1314fe6060f1SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p F.
1315fe6060f1SDimitry Andric   ///
1316fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1317fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1318fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1319fe6060f1SDimitry Andric   /// unit requirement.
1320fe6060f1SDimitry Andric   unsigned getMaxNumSGPRs(const Function &F) const;
1321fe6060f1SDimitry Andric 
1322e8d8bef9SDimitry Andric   /// \returns VGPR allocation granularity supported by the subtarget.
1323e8d8bef9SDimitry Andric   unsigned getVGPRAllocGranule() const {
1324e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPRAllocGranule(this);
1325e8d8bef9SDimitry Andric   }
1326e8d8bef9SDimitry Andric 
1327e8d8bef9SDimitry Andric   /// \returns VGPR encoding granularity supported by the subtarget.
1328e8d8bef9SDimitry Andric   unsigned getVGPREncodingGranule() const {
1329e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPREncodingGranule(this);
1330e8d8bef9SDimitry Andric   }
1331e8d8bef9SDimitry Andric 
1332e8d8bef9SDimitry Andric   /// \returns Total number of VGPRs supported by the subtarget.
1333e8d8bef9SDimitry Andric   unsigned getTotalNumVGPRs() const {
1334e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumVGPRs(this);
1335e8d8bef9SDimitry Andric   }
1336e8d8bef9SDimitry Andric 
1337e8d8bef9SDimitry Andric   /// \returns Addressable number of VGPRs supported by the subtarget.
1338e8d8bef9SDimitry Andric   unsigned getAddressableNumVGPRs() const {
1339e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumVGPRs(this);
1340e8d8bef9SDimitry Andric   }
1341e8d8bef9SDimitry Andric 
1342bdd1243dSDimitry Andric   /// \returns the minimum number of VGPRs that will prevent achieving more than
1343bdd1243dSDimitry Andric   /// the specified number of waves \p WavesPerEU.
1344e8d8bef9SDimitry Andric   unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
1345e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU);
1346e8d8bef9SDimitry Andric   }
1347e8d8bef9SDimitry Andric 
1348bdd1243dSDimitry Andric   /// \returns the maximum number of VGPRs that can be used and still achieved
1349bdd1243dSDimitry Andric   /// at least the specified number of waves \p WavesPerEU.
1350e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
1351e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU);
1352e8d8bef9SDimitry Andric   }
1353e8d8bef9SDimitry Andric 
1354fe6060f1SDimitry Andric   /// \returns max num VGPRs. This is the common utility function
1355fe6060f1SDimitry Andric   /// called by MachineFunction and Function variants of getMaxNumVGPRs.
1356fe6060f1SDimitry Andric   unsigned getBaseMaxNumVGPRs(const Function &F,
1357fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU) const;
1358fe6060f1SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1359fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of VGPRs explicitly
1360fe6060f1SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p F.
1361fe6060f1SDimitry Andric   ///
1362fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1363fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1364fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1365fe6060f1SDimitry Andric   /// unit requirement.
1366fe6060f1SDimitry Andric   unsigned getMaxNumVGPRs(const Function &F) const;
1367fe6060f1SDimitry Andric 
136881ad6265SDimitry Andric   unsigned getMaxNumAGPRs(const Function &F) const {
136981ad6265SDimitry Andric     return getMaxNumVGPRs(F);
137081ad6265SDimitry Andric   }
137181ad6265SDimitry Andric 
1372e8d8bef9SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1373e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of VGPRs explicitly
1374e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
1375e8d8bef9SDimitry Andric   ///
1376e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1377e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1378e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1379e8d8bef9SDimitry Andric   /// unit requirement.
1380e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
1381e8d8bef9SDimitry Andric 
1382e8d8bef9SDimitry Andric   void getPostRAMutations(
1383e8d8bef9SDimitry Andric       std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
1384e8d8bef9SDimitry Andric       const override;
1385e8d8bef9SDimitry Andric 
1386349cc55cSDimitry Andric   std::unique_ptr<ScheduleDAGMutation>
1387349cc55cSDimitry Andric   createFillMFMAShadowMutation(const TargetInstrInfo *TII) const;
1388349cc55cSDimitry Andric 
1389e8d8bef9SDimitry Andric   bool isWave32() const {
1390e8d8bef9SDimitry Andric     return getWavefrontSize() == 32;
1391e8d8bef9SDimitry Andric   }
1392e8d8bef9SDimitry Andric 
1393e8d8bef9SDimitry Andric   bool isWave64() const {
1394e8d8bef9SDimitry Andric     return getWavefrontSize() == 64;
1395e8d8bef9SDimitry Andric   }
1396e8d8bef9SDimitry Andric 
1397e8d8bef9SDimitry Andric   const TargetRegisterClass *getBoolRC() const {
1398e8d8bef9SDimitry Andric     return getRegisterInfo()->getBoolRC();
1399e8d8bef9SDimitry Andric   }
1400e8d8bef9SDimitry Andric 
1401e8d8bef9SDimitry Andric   /// \returns Maximum number of work groups per compute unit supported by the
1402e8d8bef9SDimitry Andric   /// subtarget and limited by given \p FlatWorkGroupSize.
1403e8d8bef9SDimitry Andric   unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1404e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1405e8d8bef9SDimitry Andric   }
1406e8d8bef9SDimitry Andric 
1407e8d8bef9SDimitry Andric   /// \returns Minimum flat work group size supported by the subtarget.
1408e8d8bef9SDimitry Andric   unsigned getMinFlatWorkGroupSize() const override {
1409e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1410e8d8bef9SDimitry Andric   }
1411e8d8bef9SDimitry Andric 
1412e8d8bef9SDimitry Andric   /// \returns Maximum flat work group size supported by the subtarget.
1413e8d8bef9SDimitry Andric   unsigned getMaxFlatWorkGroupSize() const override {
1414e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1415e8d8bef9SDimitry Andric   }
1416e8d8bef9SDimitry Andric 
1417e8d8bef9SDimitry Andric   /// \returns Number of waves per execution unit required to support the given
1418e8d8bef9SDimitry Andric   /// \p FlatWorkGroupSize.
1419e8d8bef9SDimitry Andric   unsigned
1420e8d8bef9SDimitry Andric   getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
1421e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(this, FlatWorkGroupSize);
1422e8d8bef9SDimitry Andric   }
1423e8d8bef9SDimitry Andric 
1424e8d8bef9SDimitry Andric   /// \returns Minimum number of waves per execution unit supported by the
1425e8d8bef9SDimitry Andric   /// subtarget.
1426e8d8bef9SDimitry Andric   unsigned getMinWavesPerEU() const override {
1427e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1428e8d8bef9SDimitry Andric   }
1429e8d8bef9SDimitry Andric 
1430e8d8bef9SDimitry Andric   void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
1431e8d8bef9SDimitry Andric                              SDep &Dep) const override;
143281ad6265SDimitry Andric 
143381ad6265SDimitry Andric   // \returns true if it's beneficial on this subtarget for the scheduler to
143481ad6265SDimitry Andric   // cluster stores as well as loads.
143581ad6265SDimitry Andric   bool shouldClusterStores() const { return getGeneration() >= GFX11; }
1436bdd1243dSDimitry Andric 
1437bdd1243dSDimitry Andric   // \returns the number of address arguments from which to enable MIMG NSA
1438bdd1243dSDimitry Andric   // on supported architectures.
1439bdd1243dSDimitry Andric   unsigned getNSAThreshold(const MachineFunction &MF) const;
144006c3fb27SDimitry Andric 
144106c3fb27SDimitry Andric   // \returns true if the subtarget has a hazard requiring an "s_nop 0"
144206c3fb27SDimitry Andric   // instruction before "s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)".
144306c3fb27SDimitry Andric   bool requiresNopBeforeDeallocVGPRs() const {
144406c3fb27SDimitry Andric     // Currently all targets that support the dealloc VGPRs message also require
144506c3fb27SDimitry Andric     // the nop.
144606c3fb27SDimitry Andric     return true;
144706c3fb27SDimitry Andric   }
1448e8d8bef9SDimitry Andric };
1449e8d8bef9SDimitry Andric 
14505f757f3fSDimitry Andric class GCNUserSGPRUsageInfo {
14515f757f3fSDimitry Andric public:
14525f757f3fSDimitry Andric   bool hasImplicitBufferPtr() const { return ImplicitBufferPtr; }
14535f757f3fSDimitry Andric 
14545f757f3fSDimitry Andric   bool hasPrivateSegmentBuffer() const { return PrivateSegmentBuffer; }
14555f757f3fSDimitry Andric 
14565f757f3fSDimitry Andric   bool hasDispatchPtr() const { return DispatchPtr; }
14575f757f3fSDimitry Andric 
14585f757f3fSDimitry Andric   bool hasQueuePtr() const { return QueuePtr; }
14595f757f3fSDimitry Andric 
14605f757f3fSDimitry Andric   bool hasKernargSegmentPtr() const { return KernargSegmentPtr; }
14615f757f3fSDimitry Andric 
14625f757f3fSDimitry Andric   bool hasDispatchID() const { return DispatchID; }
14635f757f3fSDimitry Andric 
14645f757f3fSDimitry Andric   bool hasFlatScratchInit() const { return FlatScratchInit; }
14655f757f3fSDimitry Andric 
14665f757f3fSDimitry Andric   unsigned getNumKernargPreloadSGPRs() const { return NumKernargPreloadSGPRs; }
14675f757f3fSDimitry Andric 
14685f757f3fSDimitry Andric   unsigned getNumUsedUserSGPRs() const { return NumUsedUserSGPRs; }
14695f757f3fSDimitry Andric 
14705f757f3fSDimitry Andric   unsigned getNumFreeUserSGPRs();
14715f757f3fSDimitry Andric 
14725f757f3fSDimitry Andric   void allocKernargPreloadSGPRs(unsigned NumSGPRs);
14735f757f3fSDimitry Andric 
14745f757f3fSDimitry Andric   enum UserSGPRID : unsigned {
14755f757f3fSDimitry Andric     ImplicitBufferPtrID = 0,
14765f757f3fSDimitry Andric     PrivateSegmentBufferID = 1,
14775f757f3fSDimitry Andric     DispatchPtrID = 2,
14785f757f3fSDimitry Andric     QueuePtrID = 3,
14795f757f3fSDimitry Andric     KernargSegmentPtrID = 4,
14805f757f3fSDimitry Andric     DispatchIdID = 5,
14815f757f3fSDimitry Andric     FlatScratchInitID = 6,
14825f757f3fSDimitry Andric     PrivateSegmentSizeID = 7
14835f757f3fSDimitry Andric   };
14845f757f3fSDimitry Andric 
14855f757f3fSDimitry Andric   // Returns the size in number of SGPRs for preload user SGPR field.
14865f757f3fSDimitry Andric   static unsigned getNumUserSGPRForField(UserSGPRID ID) {
14875f757f3fSDimitry Andric     switch (ID) {
14885f757f3fSDimitry Andric     case ImplicitBufferPtrID:
14895f757f3fSDimitry Andric       return 2;
14905f757f3fSDimitry Andric     case PrivateSegmentBufferID:
14915f757f3fSDimitry Andric       return 4;
14925f757f3fSDimitry Andric     case DispatchPtrID:
14935f757f3fSDimitry Andric       return 2;
14945f757f3fSDimitry Andric     case QueuePtrID:
14955f757f3fSDimitry Andric       return 2;
14965f757f3fSDimitry Andric     case KernargSegmentPtrID:
14975f757f3fSDimitry Andric       return 2;
14985f757f3fSDimitry Andric     case DispatchIdID:
14995f757f3fSDimitry Andric       return 2;
15005f757f3fSDimitry Andric     case FlatScratchInitID:
15015f757f3fSDimitry Andric       return 2;
15025f757f3fSDimitry Andric     case PrivateSegmentSizeID:
15035f757f3fSDimitry Andric       return 1;
15045f757f3fSDimitry Andric     }
15055f757f3fSDimitry Andric     llvm_unreachable("Unknown UserSGPRID.");
15065f757f3fSDimitry Andric   }
15075f757f3fSDimitry Andric 
15085f757f3fSDimitry Andric   GCNUserSGPRUsageInfo(const Function &F, const GCNSubtarget &ST);
15095f757f3fSDimitry Andric 
15105f757f3fSDimitry Andric private:
15115f757f3fSDimitry Andric   const GCNSubtarget &ST;
15125f757f3fSDimitry Andric 
15135f757f3fSDimitry Andric   // Private memory buffer
15145f757f3fSDimitry Andric   // Compute directly in sgpr[0:1]
15155f757f3fSDimitry Andric   // Other shaders indirect 64-bits at sgpr[0:1]
15165f757f3fSDimitry Andric   bool ImplicitBufferPtr = false;
15175f757f3fSDimitry Andric 
15185f757f3fSDimitry Andric   bool PrivateSegmentBuffer = false;
15195f757f3fSDimitry Andric 
15205f757f3fSDimitry Andric   bool DispatchPtr = false;
15215f757f3fSDimitry Andric 
15225f757f3fSDimitry Andric   bool QueuePtr = false;
15235f757f3fSDimitry Andric 
15245f757f3fSDimitry Andric   bool KernargSegmentPtr = false;
15255f757f3fSDimitry Andric 
15265f757f3fSDimitry Andric   bool DispatchID = false;
15275f757f3fSDimitry Andric 
15285f757f3fSDimitry Andric   bool FlatScratchInit = false;
15295f757f3fSDimitry Andric 
15305f757f3fSDimitry Andric   unsigned NumKernargPreloadSGPRs = 0;
15315f757f3fSDimitry Andric 
15325f757f3fSDimitry Andric   unsigned NumUsedUserSGPRs = 0;
15335f757f3fSDimitry Andric };
15345f757f3fSDimitry Andric 
1535e8d8bef9SDimitry Andric } // end namespace llvm
1536e8d8bef9SDimitry Andric 
1537e8d8bef9SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
1538