xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/AMDGPU/GCNSubtarget.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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"
18*06c3fb27SDimitry Andric #include "AMDGPURegisterBankInfo.h"
19e8d8bef9SDimitry Andric #include "AMDGPUSubtarget.h"
20e8d8bef9SDimitry Andric #include "SIFrameLowering.h"
21e8d8bef9SDimitry Andric #include "SIISelLowering.h"
22e8d8bef9SDimitry Andric #include "SIInstrInfo.h"
23*06c3fb27SDimitry Andric #include "Utils/AMDGPUBaseInfo.h"
24e8d8bef9SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
25e8d8bef9SDimitry Andric 
26e8d8bef9SDimitry Andric #define GET_SUBTARGETINFO_HEADER
27e8d8bef9SDimitry Andric #include "AMDGPUGenSubtargetInfo.inc"
28e8d8bef9SDimitry Andric 
29e8d8bef9SDimitry Andric namespace llvm {
30e8d8bef9SDimitry Andric 
31e8d8bef9SDimitry Andric class GCNTargetMachine;
32e8d8bef9SDimitry Andric 
33e8d8bef9SDimitry Andric class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
34e8d8bef9SDimitry Andric                            public AMDGPUSubtarget {
35bdd1243dSDimitry Andric public:
36e8d8bef9SDimitry Andric   using AMDGPUSubtarget::getMaxWavesPerEU;
37e8d8bef9SDimitry Andric 
38fe6060f1SDimitry Andric   // Following 2 enums are documented at:
39fe6060f1SDimitry Andric   //   - https://llvm.org/docs/AMDGPUUsage.html#trap-handler-abi
40fe6060f1SDimitry Andric   enum class TrapHandlerAbi {
41fe6060f1SDimitry Andric     NONE   = 0x00,
42fe6060f1SDimitry Andric     AMDHSA = 0x01,
43e8d8bef9SDimitry Andric   };
44e8d8bef9SDimitry Andric 
45fe6060f1SDimitry Andric   enum class TrapID {
46fe6060f1SDimitry Andric     LLVMAMDHSATrap      = 0x02,
47fe6060f1SDimitry Andric     LLVMAMDHSADebugTrap = 0x03,
48e8d8bef9SDimitry Andric   };
49e8d8bef9SDimitry Andric 
50e8d8bef9SDimitry Andric private:
51e8d8bef9SDimitry Andric   /// GlobalISel related APIs.
52e8d8bef9SDimitry Andric   std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
53e8d8bef9SDimitry Andric   std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
54e8d8bef9SDimitry Andric   std::unique_ptr<InstructionSelector> InstSelector;
55e8d8bef9SDimitry Andric   std::unique_ptr<LegalizerInfo> Legalizer;
56*06c3fb27SDimitry Andric   std::unique_ptr<AMDGPURegisterBankInfo> RegBankInfo;
57e8d8bef9SDimitry Andric 
58e8d8bef9SDimitry Andric protected:
59e8d8bef9SDimitry Andric   // Basic subtarget description.
60e8d8bef9SDimitry Andric   Triple TargetTriple;
61e8d8bef9SDimitry Andric   AMDGPU::IsaInfo::AMDGPUTargetID TargetID;
6281ad6265SDimitry Andric   unsigned Gen = INVALID;
63e8d8bef9SDimitry Andric   InstrItineraryData InstrItins;
6481ad6265SDimitry Andric   int LDSBankCount = 0;
6581ad6265SDimitry Andric   unsigned MaxPrivateElementSize = 0;
66e8d8bef9SDimitry Andric 
67e8d8bef9SDimitry Andric   // Possibly statically set by tablegen, but may want to be overridden.
6881ad6265SDimitry Andric   bool FastDenormalF32 = false;
6981ad6265SDimitry Andric   bool HalfRate64Ops = false;
7081ad6265SDimitry Andric   bool FullRate64Ops = false;
71e8d8bef9SDimitry Andric 
72e8d8bef9SDimitry Andric   // Dynamically set bits that enable features.
7381ad6265SDimitry Andric   bool FlatForGlobal = false;
7481ad6265SDimitry Andric   bool AutoWaitcntBeforeBarrier = false;
75bdd1243dSDimitry Andric   bool BackOffBarrier = false;
7681ad6265SDimitry Andric   bool UnalignedScratchAccess = false;
7781ad6265SDimitry Andric   bool UnalignedAccessMode = false;
7881ad6265SDimitry Andric   bool HasApertureRegs = false;
7981ad6265SDimitry Andric   bool SupportsXNACK = false;
80e8d8bef9SDimitry Andric 
81e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
82e8d8bef9SDimitry Andric   // for XNACK.
8381ad6265SDimitry Andric   bool EnableXNACK = false;
84e8d8bef9SDimitry Andric 
8581ad6265SDimitry Andric   bool EnableTgSplit = false;
8681ad6265SDimitry Andric   bool EnableCuMode = false;
8781ad6265SDimitry Andric   bool TrapHandler = false;
88e8d8bef9SDimitry Andric 
89e8d8bef9SDimitry Andric   // Used as options.
9081ad6265SDimitry Andric   bool EnableLoadStoreOpt = false;
9181ad6265SDimitry Andric   bool EnableUnsafeDSOffsetFolding = false;
9281ad6265SDimitry Andric   bool EnableSIScheduler = false;
9381ad6265SDimitry Andric   bool EnableDS128 = false;
9481ad6265SDimitry Andric   bool EnablePRTStrictNull = false;
9581ad6265SDimitry Andric   bool DumpCode = false;
96e8d8bef9SDimitry Andric 
97e8d8bef9SDimitry Andric   // Subtarget statically properties set by tablegen
9881ad6265SDimitry Andric   bool FP64 = false;
9981ad6265SDimitry Andric   bool FMA = false;
10081ad6265SDimitry Andric   bool MIMG_R128 = false;
10181ad6265SDimitry Andric   bool CIInsts = false;
10281ad6265SDimitry Andric   bool GFX8Insts = false;
10381ad6265SDimitry Andric   bool GFX9Insts = false;
10481ad6265SDimitry Andric   bool GFX90AInsts = false;
10581ad6265SDimitry Andric   bool GFX940Insts = false;
10681ad6265SDimitry Andric   bool GFX10Insts = false;
10781ad6265SDimitry Andric   bool GFX11Insts = false;
10881ad6265SDimitry Andric   bool GFX10_3Insts = false;
10981ad6265SDimitry Andric   bool GFX7GFX8GFX9Insts = false;
11081ad6265SDimitry Andric   bool SGPRInitBug = false;
11181ad6265SDimitry Andric   bool UserSGPRInit16Bug = false;
11281ad6265SDimitry Andric   bool NegativeScratchOffsetBug = false;
11381ad6265SDimitry Andric   bool NegativeUnalignedScratchOffsetBug = false;
11481ad6265SDimitry Andric   bool HasSMemRealTime = false;
11581ad6265SDimitry Andric   bool HasIntClamp = false;
11681ad6265SDimitry Andric   bool HasFmaMixInsts = false;
11781ad6265SDimitry Andric   bool HasMovrel = false;
11881ad6265SDimitry Andric   bool HasVGPRIndexMode = false;
11981ad6265SDimitry Andric   bool HasScalarStores = false;
12081ad6265SDimitry Andric   bool HasScalarAtomics = false;
12181ad6265SDimitry Andric   bool HasSDWAOmod = false;
12281ad6265SDimitry Andric   bool HasSDWAScalar = false;
12381ad6265SDimitry Andric   bool HasSDWASdst = false;
12481ad6265SDimitry Andric   bool HasSDWAMac = false;
12581ad6265SDimitry Andric   bool HasSDWAOutModsVOPC = false;
12681ad6265SDimitry Andric   bool HasDPP = false;
12781ad6265SDimitry Andric   bool HasDPP8 = false;
12881ad6265SDimitry Andric   bool Has64BitDPP = false;
12981ad6265SDimitry Andric   bool HasPackedFP32Ops = false;
13081ad6265SDimitry Andric   bool HasImageInsts = false;
13181ad6265SDimitry Andric   bool HasExtendedImageInsts = false;
13281ad6265SDimitry Andric   bool HasR128A16 = false;
133bdd1243dSDimitry Andric   bool HasA16 = false;
13481ad6265SDimitry Andric   bool HasG16 = false;
13581ad6265SDimitry Andric   bool HasNSAEncoding = false;
136*06c3fb27SDimitry Andric   bool HasPartialNSAEncoding = false;
13781ad6265SDimitry Andric   bool GFX10_AEncoding = false;
13881ad6265SDimitry Andric   bool GFX10_BEncoding = false;
13981ad6265SDimitry Andric   bool HasDLInsts = false;
140bdd1243dSDimitry Andric   bool HasFmacF64Inst = false;
14181ad6265SDimitry Andric   bool HasDot1Insts = false;
14281ad6265SDimitry Andric   bool HasDot2Insts = false;
14381ad6265SDimitry Andric   bool HasDot3Insts = false;
14481ad6265SDimitry Andric   bool HasDot4Insts = false;
14581ad6265SDimitry Andric   bool HasDot5Insts = false;
14681ad6265SDimitry Andric   bool HasDot6Insts = false;
14781ad6265SDimitry Andric   bool HasDot7Insts = false;
14881ad6265SDimitry Andric   bool HasDot8Insts = false;
149bdd1243dSDimitry Andric   bool HasDot9Insts = false;
150*06c3fb27SDimitry Andric   bool HasDot10Insts = false;
15181ad6265SDimitry Andric   bool HasMAIInsts = false;
152fcaf7f86SDimitry Andric   bool HasFP8Insts = false;
15381ad6265SDimitry Andric   bool HasPkFmacF16Inst = false;
154*06c3fb27SDimitry Andric   bool HasAtomicDsPkAdd16Insts = false;
155*06c3fb27SDimitry Andric   bool HasAtomicFlatPkAdd16Insts = false;
15681ad6265SDimitry Andric   bool HasAtomicFaddRtnInsts = false;
15781ad6265SDimitry Andric   bool HasAtomicFaddNoRtnInsts = false;
158*06c3fb27SDimitry Andric   bool HasAtomicBufferGlobalPkAddF16NoRtnInsts = false;
159*06c3fb27SDimitry Andric   bool HasAtomicBufferGlobalPkAddF16Insts = false;
160*06c3fb27SDimitry Andric   bool HasAtomicGlobalPkAddBF16Inst = false;
161bdd1243dSDimitry Andric   bool HasFlatAtomicFaddF32Inst = false;
16281ad6265SDimitry Andric   bool SupportsSRAMECC = false;
163e8d8bef9SDimitry Andric 
164e8d8bef9SDimitry Andric   // This should not be used directly. 'TargetID' tracks the dynamic settings
165e8d8bef9SDimitry Andric   // for SRAMECC.
16681ad6265SDimitry Andric   bool EnableSRAMECC = false;
167e8d8bef9SDimitry Andric 
16881ad6265SDimitry Andric   bool HasNoSdstCMPX = false;
16981ad6265SDimitry Andric   bool HasVscnt = false;
17081ad6265SDimitry Andric   bool HasGetWaveIdInst = false;
17181ad6265SDimitry Andric   bool HasSMemTimeInst = false;
17281ad6265SDimitry Andric   bool HasShaderCyclesRegister = false;
17381ad6265SDimitry Andric   bool HasVOP3Literal = false;
17481ad6265SDimitry Andric   bool HasNoDataDepHazard = false;
17581ad6265SDimitry Andric   bool FlatAddressSpace = false;
17681ad6265SDimitry Andric   bool FlatInstOffsets = false;
17781ad6265SDimitry Andric   bool FlatGlobalInsts = false;
17881ad6265SDimitry Andric   bool FlatScratchInsts = false;
17981ad6265SDimitry Andric   bool ScalarFlatScratchInsts = false;
18081ad6265SDimitry Andric   bool HasArchitectedFlatScratch = false;
18181ad6265SDimitry Andric   bool EnableFlatScratch = false;
182*06c3fb27SDimitry Andric   bool HasArchitectedSGPRs = false;
18381ad6265SDimitry Andric   bool AddNoCarryInsts = false;
18481ad6265SDimitry Andric   bool HasUnpackedD16VMem = false;
18581ad6265SDimitry Andric   bool LDSMisalignedBug = false;
18681ad6265SDimitry Andric   bool HasMFMAInlineLiteralBug = false;
18781ad6265SDimitry Andric   bool UnalignedBufferAccess = false;
18881ad6265SDimitry Andric   bool UnalignedDSAccess = false;
18981ad6265SDimitry Andric   bool HasPackedTID = false;
19081ad6265SDimitry Andric   bool ScalarizeGlobal = false;
191e8d8bef9SDimitry Andric 
19281ad6265SDimitry Andric   bool HasVcmpxPermlaneHazard = false;
19381ad6265SDimitry Andric   bool HasVMEMtoScalarWriteHazard = false;
19481ad6265SDimitry Andric   bool HasSMEMtoVectorWriteHazard = false;
19581ad6265SDimitry Andric   bool HasInstFwdPrefetchBug = false;
19681ad6265SDimitry Andric   bool HasVcmpxExecWARHazard = false;
19781ad6265SDimitry Andric   bool HasLdsBranchVmemWARHazard = false;
19881ad6265SDimitry Andric   bool HasNSAtoVMEMBug = false;
19981ad6265SDimitry Andric   bool HasNSAClauseBug = false;
20081ad6265SDimitry Andric   bool HasOffset3fBug = false;
20181ad6265SDimitry Andric   bool HasFlatSegmentOffsetBug = false;
20281ad6265SDimitry Andric   bool HasImageStoreD16Bug = false;
20381ad6265SDimitry Andric   bool HasImageGather4D16Bug = false;
204bdd1243dSDimitry Andric   bool HasGFX11FullVGPRs = false;
205bdd1243dSDimitry Andric   bool HasMADIntraFwdBug = false;
20681ad6265SDimitry Andric   bool HasVOPDInsts = false;
207bdd1243dSDimitry Andric   bool HasVALUTransUseHazard = false;
208*06c3fb27SDimitry Andric   bool HasForceStoreSC0SC1 = false;
209e8d8bef9SDimitry Andric 
210e8d8bef9SDimitry Andric   // Dummy feature to use for assembler in tablegen.
21181ad6265SDimitry Andric   bool FeatureDisable = false;
212e8d8bef9SDimitry Andric 
213e8d8bef9SDimitry Andric   SelectionDAGTargetInfo TSInfo;
214e8d8bef9SDimitry Andric private:
215e8d8bef9SDimitry Andric   SIInstrInfo InstrInfo;
216e8d8bef9SDimitry Andric   SITargetLowering TLInfo;
217e8d8bef9SDimitry Andric   SIFrameLowering FrameLowering;
218e8d8bef9SDimitry Andric 
219e8d8bef9SDimitry Andric public:
220e8d8bef9SDimitry Andric   GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
221e8d8bef9SDimitry Andric                const GCNTargetMachine &TM);
222e8d8bef9SDimitry Andric   ~GCNSubtarget() override;
223e8d8bef9SDimitry Andric 
224e8d8bef9SDimitry Andric   GCNSubtarget &initializeSubtargetDependencies(const Triple &TT,
225e8d8bef9SDimitry Andric                                                    StringRef GPU, StringRef FS);
226e8d8bef9SDimitry Andric 
227e8d8bef9SDimitry Andric   const SIInstrInfo *getInstrInfo() const override {
228e8d8bef9SDimitry Andric     return &InstrInfo;
229e8d8bef9SDimitry Andric   }
230e8d8bef9SDimitry Andric 
231e8d8bef9SDimitry Andric   const SIFrameLowering *getFrameLowering() const override {
232e8d8bef9SDimitry Andric     return &FrameLowering;
233e8d8bef9SDimitry Andric   }
234e8d8bef9SDimitry Andric 
235e8d8bef9SDimitry Andric   const SITargetLowering *getTargetLowering() const override {
236e8d8bef9SDimitry Andric     return &TLInfo;
237e8d8bef9SDimitry Andric   }
238e8d8bef9SDimitry Andric 
239e8d8bef9SDimitry Andric   const SIRegisterInfo *getRegisterInfo() const override {
240e8d8bef9SDimitry Andric     return &InstrInfo.getRegisterInfo();
241e8d8bef9SDimitry Andric   }
242e8d8bef9SDimitry Andric 
243e8d8bef9SDimitry Andric   const CallLowering *getCallLowering() const override {
244e8d8bef9SDimitry Andric     return CallLoweringInfo.get();
245e8d8bef9SDimitry Andric   }
246e8d8bef9SDimitry Andric 
247e8d8bef9SDimitry Andric   const InlineAsmLowering *getInlineAsmLowering() const override {
248e8d8bef9SDimitry Andric     return InlineAsmLoweringInfo.get();
249e8d8bef9SDimitry Andric   }
250e8d8bef9SDimitry Andric 
251e8d8bef9SDimitry Andric   InstructionSelector *getInstructionSelector() const override {
252e8d8bef9SDimitry Andric     return InstSelector.get();
253e8d8bef9SDimitry Andric   }
254e8d8bef9SDimitry Andric 
255e8d8bef9SDimitry Andric   const LegalizerInfo *getLegalizerInfo() const override {
256e8d8bef9SDimitry Andric     return Legalizer.get();
257e8d8bef9SDimitry Andric   }
258e8d8bef9SDimitry Andric 
259*06c3fb27SDimitry Andric   const AMDGPURegisterBankInfo *getRegBankInfo() const override {
260e8d8bef9SDimitry Andric     return RegBankInfo.get();
261e8d8bef9SDimitry Andric   }
262e8d8bef9SDimitry Andric 
263fe6060f1SDimitry Andric   const AMDGPU::IsaInfo::AMDGPUTargetID &getTargetID() const {
264fe6060f1SDimitry Andric     return TargetID;
265fe6060f1SDimitry Andric   }
266fe6060f1SDimitry Andric 
267e8d8bef9SDimitry Andric   // Nothing implemented, just prevent crashes on use.
268e8d8bef9SDimitry Andric   const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
269e8d8bef9SDimitry Andric     return &TSInfo;
270e8d8bef9SDimitry Andric   }
271e8d8bef9SDimitry Andric 
272e8d8bef9SDimitry Andric   const InstrItineraryData *getInstrItineraryData() const override {
273e8d8bef9SDimitry Andric     return &InstrItins;
274e8d8bef9SDimitry Andric   }
275e8d8bef9SDimitry Andric 
276e8d8bef9SDimitry Andric   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
277e8d8bef9SDimitry Andric 
278e8d8bef9SDimitry Andric   Generation getGeneration() const {
279e8d8bef9SDimitry Andric     return (Generation)Gen;
280e8d8bef9SDimitry Andric   }
281e8d8bef9SDimitry Andric 
28281ad6265SDimitry Andric   unsigned getMaxWaveScratchSize() const {
28381ad6265SDimitry Andric     // See COMPUTE_TMPRING_SIZE.WAVESIZE.
28481ad6265SDimitry Andric     if (getGeneration() < GFX11) {
28581ad6265SDimitry Andric       // 13-bit field in units of 256-dword.
28681ad6265SDimitry Andric       return (256 * 4) * ((1 << 13) - 1);
28781ad6265SDimitry Andric     }
28881ad6265SDimitry Andric     // 15-bit field in units of 64-dword.
28981ad6265SDimitry Andric     return (64 * 4) * ((1 << 15) - 1);
29081ad6265SDimitry Andric   }
29181ad6265SDimitry Andric 
292349cc55cSDimitry Andric   /// Return the number of high bits known to be zero for a frame index.
293e8d8bef9SDimitry Andric   unsigned getKnownHighZeroBitsForFrameIndex() const {
294*06c3fb27SDimitry Andric     return llvm::countl_zero(getMaxWaveScratchSize()) + getWavefrontSizeLog2();
295e8d8bef9SDimitry Andric   }
296e8d8bef9SDimitry Andric 
297e8d8bef9SDimitry Andric   int getLDSBankCount() const {
298e8d8bef9SDimitry Andric     return LDSBankCount;
299e8d8bef9SDimitry Andric   }
300e8d8bef9SDimitry Andric 
301e8d8bef9SDimitry Andric   unsigned getMaxPrivateElementSize(bool ForBufferRSrc = false) const {
302e8d8bef9SDimitry Andric     return (ForBufferRSrc || !enableFlatScratch()) ? MaxPrivateElementSize : 16;
303e8d8bef9SDimitry Andric   }
304e8d8bef9SDimitry Andric 
305e8d8bef9SDimitry Andric   unsigned getConstantBusLimit(unsigned Opcode) const;
306e8d8bef9SDimitry Andric 
307fe6060f1SDimitry Andric   /// Returns if the result of this instruction with a 16-bit result returned in
308fe6060f1SDimitry Andric   /// a 32-bit register implicitly zeroes the high 16-bits, rather than preserve
309fe6060f1SDimitry Andric   /// the original value.
310fe6060f1SDimitry Andric   bool zeroesHigh16BitsOfDest(unsigned Opcode) const;
311fe6060f1SDimitry Andric 
312bdd1243dSDimitry Andric   bool supportsWGP() const { return getGeneration() >= GFX10; }
313bdd1243dSDimitry Andric 
314e8d8bef9SDimitry Andric   bool hasIntClamp() const {
315e8d8bef9SDimitry Andric     return HasIntClamp;
316e8d8bef9SDimitry Andric   }
317e8d8bef9SDimitry Andric 
318e8d8bef9SDimitry Andric   bool hasFP64() const {
319e8d8bef9SDimitry Andric     return FP64;
320e8d8bef9SDimitry Andric   }
321e8d8bef9SDimitry Andric 
322e8d8bef9SDimitry Andric   bool hasMIMG_R128() const {
323e8d8bef9SDimitry Andric     return MIMG_R128;
324e8d8bef9SDimitry Andric   }
325e8d8bef9SDimitry Andric 
326e8d8bef9SDimitry Andric   bool hasHWFP64() const {
327e8d8bef9SDimitry Andric     return FP64;
328e8d8bef9SDimitry Andric   }
329e8d8bef9SDimitry Andric 
330e8d8bef9SDimitry Andric   bool hasHalfRate64Ops() const {
331e8d8bef9SDimitry Andric     return HalfRate64Ops;
332e8d8bef9SDimitry Andric   }
333e8d8bef9SDimitry Andric 
334fe6060f1SDimitry Andric   bool hasFullRate64Ops() const {
335fe6060f1SDimitry Andric     return FullRate64Ops;
336fe6060f1SDimitry Andric   }
337fe6060f1SDimitry Andric 
338e8d8bef9SDimitry Andric   bool hasAddr64() const {
339e8d8bef9SDimitry Andric     return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS);
340e8d8bef9SDimitry Andric   }
341e8d8bef9SDimitry Andric 
342e8d8bef9SDimitry Andric   bool hasFlat() const {
343e8d8bef9SDimitry Andric     return (getGeneration() > AMDGPUSubtarget::SOUTHERN_ISLANDS);
344e8d8bef9SDimitry Andric   }
345e8d8bef9SDimitry Andric 
346e8d8bef9SDimitry Andric   // Return true if the target only has the reverse operand versions of VALU
347e8d8bef9SDimitry Andric   // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
348e8d8bef9SDimitry Andric   bool hasOnlyRevVALUShifts() const {
349e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
350e8d8bef9SDimitry Andric   }
351e8d8bef9SDimitry Andric 
352e8d8bef9SDimitry Andric   bool hasFractBug() const {
353e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
354e8d8bef9SDimitry Andric   }
355e8d8bef9SDimitry Andric 
356e8d8bef9SDimitry Andric   bool hasBFE() const {
357e8d8bef9SDimitry Andric     return true;
358e8d8bef9SDimitry Andric   }
359e8d8bef9SDimitry Andric 
360e8d8bef9SDimitry Andric   bool hasBFI() const {
361e8d8bef9SDimitry Andric     return true;
362e8d8bef9SDimitry Andric   }
363e8d8bef9SDimitry Andric 
364e8d8bef9SDimitry Andric   bool hasBFM() const {
365e8d8bef9SDimitry Andric     return hasBFE();
366e8d8bef9SDimitry Andric   }
367e8d8bef9SDimitry Andric 
368e8d8bef9SDimitry Andric   bool hasBCNT(unsigned Size) const {
369e8d8bef9SDimitry Andric     return true;
370e8d8bef9SDimitry Andric   }
371e8d8bef9SDimitry Andric 
372e8d8bef9SDimitry Andric   bool hasFFBL() const {
373e8d8bef9SDimitry Andric     return true;
374e8d8bef9SDimitry Andric   }
375e8d8bef9SDimitry Andric 
376e8d8bef9SDimitry Andric   bool hasFFBH() const {
377e8d8bef9SDimitry Andric     return true;
378e8d8bef9SDimitry Andric   }
379e8d8bef9SDimitry Andric 
380e8d8bef9SDimitry Andric   bool hasMed3_16() const {
381e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
382e8d8bef9SDimitry Andric   }
383e8d8bef9SDimitry Andric 
384e8d8bef9SDimitry Andric   bool hasMin3Max3_16() const {
385e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
386e8d8bef9SDimitry Andric   }
387e8d8bef9SDimitry Andric 
388e8d8bef9SDimitry Andric   bool hasFmaMixInsts() const {
389e8d8bef9SDimitry Andric     return HasFmaMixInsts;
390e8d8bef9SDimitry Andric   }
391e8d8bef9SDimitry Andric 
392e8d8bef9SDimitry Andric   bool hasCARRY() const {
393e8d8bef9SDimitry Andric     return true;
394e8d8bef9SDimitry Andric   }
395e8d8bef9SDimitry Andric 
396e8d8bef9SDimitry Andric   bool hasFMA() const {
397e8d8bef9SDimitry Andric     return FMA;
398e8d8bef9SDimitry Andric   }
399e8d8bef9SDimitry Andric 
400e8d8bef9SDimitry Andric   bool hasSwap() const {
401e8d8bef9SDimitry Andric     return GFX9Insts;
402e8d8bef9SDimitry Andric   }
403e8d8bef9SDimitry Andric 
404e8d8bef9SDimitry Andric   bool hasScalarPackInsts() const {
405e8d8bef9SDimitry Andric     return GFX9Insts;
406e8d8bef9SDimitry Andric   }
407e8d8bef9SDimitry Andric 
408e8d8bef9SDimitry Andric   bool hasScalarMulHiInsts() const {
409e8d8bef9SDimitry Andric     return GFX9Insts;
410e8d8bef9SDimitry Andric   }
411e8d8bef9SDimitry Andric 
412e8d8bef9SDimitry Andric   TrapHandlerAbi getTrapHandlerAbi() const {
413fe6060f1SDimitry Andric     return isAmdHsaOS() ? TrapHandlerAbi::AMDHSA : TrapHandlerAbi::NONE;
414fe6060f1SDimitry Andric   }
415fe6060f1SDimitry Andric 
416fe6060f1SDimitry Andric   bool supportsGetDoorbellID() const {
417fe6060f1SDimitry Andric     // The S_GETREG DOORBELL_ID is supported by all GFX9 onward targets.
418fe6060f1SDimitry Andric     return getGeneration() >= GFX9;
419e8d8bef9SDimitry Andric   }
420e8d8bef9SDimitry Andric 
421e8d8bef9SDimitry Andric   /// True if the offset field of DS instructions works as expected. On SI, the
422e8d8bef9SDimitry Andric   /// offset uses a 16-bit adder and does not always wrap properly.
423e8d8bef9SDimitry Andric   bool hasUsableDSOffset() const {
424e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
425e8d8bef9SDimitry Andric   }
426e8d8bef9SDimitry Andric 
427e8d8bef9SDimitry Andric   bool unsafeDSOffsetFoldingEnabled() const {
428e8d8bef9SDimitry Andric     return EnableUnsafeDSOffsetFolding;
429e8d8bef9SDimitry Andric   }
430e8d8bef9SDimitry Andric 
431e8d8bef9SDimitry Andric   /// Condition output from div_scale is usable.
432e8d8bef9SDimitry Andric   bool hasUsableDivScaleConditionOutput() const {
433e8d8bef9SDimitry Andric     return getGeneration() != SOUTHERN_ISLANDS;
434e8d8bef9SDimitry Andric   }
435e8d8bef9SDimitry Andric 
436e8d8bef9SDimitry Andric   /// Extra wait hazard is needed in some cases before
437e8d8bef9SDimitry Andric   /// s_cbranch_vccnz/s_cbranch_vccz.
438e8d8bef9SDimitry Andric   bool hasReadVCCZBug() const {
439e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS;
440e8d8bef9SDimitry Andric   }
441e8d8bef9SDimitry Andric 
442e8d8bef9SDimitry Andric   /// Writes to VCC_LO/VCC_HI update the VCCZ flag.
443e8d8bef9SDimitry Andric   bool partialVCCWritesUpdateVCCZ() const {
444e8d8bef9SDimitry Andric     return getGeneration() >= GFX10;
445e8d8bef9SDimitry Andric   }
446e8d8bef9SDimitry Andric 
447e8d8bef9SDimitry Andric   /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
448e8d8bef9SDimitry Andric   /// was written by a VALU instruction.
449e8d8bef9SDimitry Andric   bool hasSMRDReadVALUDefHazard() const {
450e8d8bef9SDimitry Andric     return getGeneration() == SOUTHERN_ISLANDS;
451e8d8bef9SDimitry Andric   }
452e8d8bef9SDimitry Andric 
453e8d8bef9SDimitry Andric   /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
454e8d8bef9SDimitry Andric   /// SGPR was written by a VALU Instruction.
455e8d8bef9SDimitry Andric   bool hasVMEMReadSGPRVALUDefHazard() const {
456e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
457e8d8bef9SDimitry Andric   }
458e8d8bef9SDimitry Andric 
459e8d8bef9SDimitry Andric   bool hasRFEHazards() const {
460e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
461e8d8bef9SDimitry Andric   }
462e8d8bef9SDimitry Andric 
463e8d8bef9SDimitry Andric   /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
464e8d8bef9SDimitry Andric   unsigned getSetRegWaitStates() const {
465e8d8bef9SDimitry Andric     return getGeneration() <= SEA_ISLANDS ? 1 : 2;
466e8d8bef9SDimitry Andric   }
467e8d8bef9SDimitry Andric 
468e8d8bef9SDimitry Andric   bool dumpCode() const {
469e8d8bef9SDimitry Andric     return DumpCode;
470e8d8bef9SDimitry Andric   }
471e8d8bef9SDimitry Andric 
472e8d8bef9SDimitry Andric   /// Return the amount of LDS that can be used that will not restrict the
473e8d8bef9SDimitry Andric   /// occupancy lower than WaveCount.
474e8d8bef9SDimitry Andric   unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
475e8d8bef9SDimitry Andric                                            const Function &) const;
476e8d8bef9SDimitry Andric 
477e8d8bef9SDimitry Andric   bool supportsMinMaxDenormModes() const {
478e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
479e8d8bef9SDimitry Andric   }
480e8d8bef9SDimitry Andric 
481e8d8bef9SDimitry Andric   /// \returns If target supports S_DENORM_MODE.
482e8d8bef9SDimitry Andric   bool hasDenormModeInst() const {
483e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX10;
484e8d8bef9SDimitry Andric   }
485e8d8bef9SDimitry Andric 
486e8d8bef9SDimitry Andric   bool useFlatForGlobal() const {
487e8d8bef9SDimitry Andric     return FlatForGlobal;
488e8d8bef9SDimitry Andric   }
489e8d8bef9SDimitry Andric 
490e8d8bef9SDimitry Andric   /// \returns If target supports ds_read/write_b128 and user enables generation
491e8d8bef9SDimitry Andric   /// of ds_read/write_b128.
492e8d8bef9SDimitry Andric   bool useDS128() const {
493e8d8bef9SDimitry Andric     return CIInsts && EnableDS128;
494e8d8bef9SDimitry Andric   }
495e8d8bef9SDimitry Andric 
496e8d8bef9SDimitry Andric   /// \return If target supports ds_read/write_b96/128.
497e8d8bef9SDimitry Andric   bool hasDS96AndDS128() const {
498e8d8bef9SDimitry Andric     return CIInsts;
499e8d8bef9SDimitry Andric   }
500e8d8bef9SDimitry Andric 
501e8d8bef9SDimitry Andric   /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
502e8d8bef9SDimitry Andric   bool haveRoundOpsF64() const {
503e8d8bef9SDimitry Andric     return CIInsts;
504e8d8bef9SDimitry Andric   }
505e8d8bef9SDimitry Andric 
506e8d8bef9SDimitry Andric   /// \returns If MUBUF instructions always perform range checking, even for
507e8d8bef9SDimitry Andric   /// buffer resources used for private memory access.
508e8d8bef9SDimitry Andric   bool privateMemoryResourceIsRangeChecked() const {
509e8d8bef9SDimitry Andric     return getGeneration() < AMDGPUSubtarget::GFX9;
510e8d8bef9SDimitry Andric   }
511e8d8bef9SDimitry Andric 
512e8d8bef9SDimitry Andric   /// \returns If target requires PRT Struct NULL support (zero result registers
513e8d8bef9SDimitry Andric   /// for sparse texture support).
514e8d8bef9SDimitry Andric   bool usePRTStrictNull() const {
515e8d8bef9SDimitry Andric     return EnablePRTStrictNull;
516e8d8bef9SDimitry Andric   }
517e8d8bef9SDimitry Andric 
518e8d8bef9SDimitry Andric   bool hasAutoWaitcntBeforeBarrier() const {
519e8d8bef9SDimitry Andric     return AutoWaitcntBeforeBarrier;
520e8d8bef9SDimitry Andric   }
521e8d8bef9SDimitry Andric 
522bdd1243dSDimitry Andric   /// \returns true if the target supports backing off of s_barrier instructions
523bdd1243dSDimitry Andric   /// when an exception is raised.
524bdd1243dSDimitry Andric   bool supportsBackOffBarrier() const {
525bdd1243dSDimitry Andric     return BackOffBarrier;
526bdd1243dSDimitry Andric   }
527bdd1243dSDimitry Andric 
528e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccess() const {
529e8d8bef9SDimitry Andric     return UnalignedBufferAccess;
530e8d8bef9SDimitry Andric   }
531e8d8bef9SDimitry Andric 
532e8d8bef9SDimitry Andric   bool hasUnalignedBufferAccessEnabled() const {
533e8d8bef9SDimitry Andric     return UnalignedBufferAccess && UnalignedAccessMode;
534e8d8bef9SDimitry Andric   }
535e8d8bef9SDimitry Andric 
536e8d8bef9SDimitry Andric   bool hasUnalignedDSAccess() const {
537e8d8bef9SDimitry Andric     return UnalignedDSAccess;
538e8d8bef9SDimitry Andric   }
539e8d8bef9SDimitry Andric 
540e8d8bef9SDimitry Andric   bool hasUnalignedDSAccessEnabled() const {
541e8d8bef9SDimitry Andric     return UnalignedDSAccess && UnalignedAccessMode;
542e8d8bef9SDimitry Andric   }
543e8d8bef9SDimitry Andric 
544e8d8bef9SDimitry Andric   bool hasUnalignedScratchAccess() const {
545e8d8bef9SDimitry Andric     return UnalignedScratchAccess;
546e8d8bef9SDimitry Andric   }
547e8d8bef9SDimitry Andric 
548e8d8bef9SDimitry Andric   bool hasUnalignedAccessMode() const {
549e8d8bef9SDimitry Andric     return UnalignedAccessMode;
550e8d8bef9SDimitry Andric   }
551e8d8bef9SDimitry Andric 
552e8d8bef9SDimitry Andric   bool hasApertureRegs() const {
553e8d8bef9SDimitry Andric     return HasApertureRegs;
554e8d8bef9SDimitry Andric   }
555e8d8bef9SDimitry Andric 
556e8d8bef9SDimitry Andric   bool isTrapHandlerEnabled() const {
557e8d8bef9SDimitry Andric     return TrapHandler;
558e8d8bef9SDimitry Andric   }
559e8d8bef9SDimitry Andric 
560e8d8bef9SDimitry Andric   bool isXNACKEnabled() const {
561e8d8bef9SDimitry Andric     return TargetID.isXnackOnOrAny();
562e8d8bef9SDimitry Andric   }
563e8d8bef9SDimitry Andric 
564fe6060f1SDimitry Andric   bool isTgSplitEnabled() const {
565fe6060f1SDimitry Andric     return EnableTgSplit;
566fe6060f1SDimitry Andric   }
567fe6060f1SDimitry Andric 
568e8d8bef9SDimitry Andric   bool isCuModeEnabled() const {
569e8d8bef9SDimitry Andric     return EnableCuMode;
570e8d8bef9SDimitry Andric   }
571e8d8bef9SDimitry Andric 
572e8d8bef9SDimitry Andric   bool hasFlatAddressSpace() const {
573e8d8bef9SDimitry Andric     return FlatAddressSpace;
574e8d8bef9SDimitry Andric   }
575e8d8bef9SDimitry Andric 
576e8d8bef9SDimitry Andric   bool hasFlatScrRegister() const {
577e8d8bef9SDimitry Andric     return hasFlatAddressSpace();
578e8d8bef9SDimitry Andric   }
579e8d8bef9SDimitry Andric 
580e8d8bef9SDimitry Andric   bool hasFlatInstOffsets() const {
581e8d8bef9SDimitry Andric     return FlatInstOffsets;
582e8d8bef9SDimitry Andric   }
583e8d8bef9SDimitry Andric 
584e8d8bef9SDimitry Andric   bool hasFlatGlobalInsts() const {
585e8d8bef9SDimitry Andric     return FlatGlobalInsts;
586e8d8bef9SDimitry Andric   }
587e8d8bef9SDimitry Andric 
588e8d8bef9SDimitry Andric   bool hasFlatScratchInsts() const {
589e8d8bef9SDimitry Andric     return FlatScratchInsts;
590e8d8bef9SDimitry Andric   }
591e8d8bef9SDimitry Andric 
592e8d8bef9SDimitry Andric   // Check if target supports ST addressing mode with FLAT scratch instructions.
593e8d8bef9SDimitry Andric   // The ST addressing mode means no registers are used, either VGPR or SGPR,
594e8d8bef9SDimitry Andric   // but only immediate offset is swizzled and added to the FLAT scratch base.
595e8d8bef9SDimitry Andric   bool hasFlatScratchSTMode() const {
59681ad6265SDimitry Andric     return hasFlatScratchInsts() && (hasGFX10_3Insts() || hasGFX940Insts());
597e8d8bef9SDimitry Andric   }
598e8d8bef9SDimitry Andric 
59981ad6265SDimitry Andric   bool hasFlatScratchSVSMode() const { return GFX940Insts || GFX11Insts; }
60081ad6265SDimitry Andric 
601e8d8bef9SDimitry Andric   bool hasScalarFlatScratchInsts() const {
602e8d8bef9SDimitry Andric     return ScalarFlatScratchInsts;
603e8d8bef9SDimitry Andric   }
604e8d8bef9SDimitry Andric 
60581ad6265SDimitry Andric   bool enableFlatScratch() const {
60681ad6265SDimitry Andric     return flatScratchIsArchitected() ||
60781ad6265SDimitry Andric            (EnableFlatScratch && hasFlatScratchInsts());
60881ad6265SDimitry Andric   }
60981ad6265SDimitry Andric 
610e8d8bef9SDimitry Andric   bool hasGlobalAddTidInsts() const {
611e8d8bef9SDimitry Andric     return GFX10_BEncoding;
612e8d8bef9SDimitry Andric   }
613e8d8bef9SDimitry Andric 
614e8d8bef9SDimitry Andric   bool hasAtomicCSub() const {
615e8d8bef9SDimitry Andric     return GFX10_BEncoding;
616e8d8bef9SDimitry Andric   }
617e8d8bef9SDimitry Andric 
618e8d8bef9SDimitry Andric   bool hasMultiDwordFlatScratchAddressing() const {
619e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
620e8d8bef9SDimitry Andric   }
621e8d8bef9SDimitry Andric 
622e8d8bef9SDimitry Andric   bool hasFlatSegmentOffsetBug() const {
623e8d8bef9SDimitry Andric     return HasFlatSegmentOffsetBug;
624e8d8bef9SDimitry Andric   }
625e8d8bef9SDimitry Andric 
626e8d8bef9SDimitry Andric   bool hasFlatLgkmVMemCountInOrder() const {
627e8d8bef9SDimitry Andric     return getGeneration() > GFX9;
628e8d8bef9SDimitry Andric   }
629e8d8bef9SDimitry Andric 
630e8d8bef9SDimitry Andric   bool hasD16LoadStore() const {
631e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
632e8d8bef9SDimitry Andric   }
633e8d8bef9SDimitry Andric 
634e8d8bef9SDimitry Andric   bool d16PreservesUnusedBits() const {
635e8d8bef9SDimitry Andric     return hasD16LoadStore() && !TargetID.isSramEccOnOrAny();
636e8d8bef9SDimitry Andric   }
637e8d8bef9SDimitry Andric 
638e8d8bef9SDimitry Andric   bool hasD16Images() const {
639e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
640e8d8bef9SDimitry Andric   }
641e8d8bef9SDimitry Andric 
642e8d8bef9SDimitry Andric   /// Return if most LDS instructions have an m0 use that require m0 to be
643349cc55cSDimitry Andric   /// initialized.
644e8d8bef9SDimitry Andric   bool ldsRequiresM0Init() const {
645e8d8bef9SDimitry Andric     return getGeneration() < GFX9;
646e8d8bef9SDimitry Andric   }
647e8d8bef9SDimitry Andric 
648e8d8bef9SDimitry Andric   // True if the hardware rewinds and replays GWS operations if a wave is
649e8d8bef9SDimitry Andric   // preempted.
650e8d8bef9SDimitry Andric   //
651e8d8bef9SDimitry Andric   // If this is false, a GWS operation requires testing if a nack set the
652e8d8bef9SDimitry Andric   // MEM_VIOL bit, and repeating if so.
653e8d8bef9SDimitry Andric   bool hasGWSAutoReplay() const {
654e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
655e8d8bef9SDimitry Andric   }
656e8d8bef9SDimitry Andric 
657e8d8bef9SDimitry Andric   /// \returns if target has ds_gws_sema_release_all instruction.
658e8d8bef9SDimitry Andric   bool hasGWSSemaReleaseAll() const {
659e8d8bef9SDimitry Andric     return CIInsts;
660e8d8bef9SDimitry Andric   }
661e8d8bef9SDimitry Andric 
662e8d8bef9SDimitry Andric   /// \returns true if the target has integer add/sub instructions that do not
663e8d8bef9SDimitry Andric   /// produce a carry-out. This includes v_add_[iu]32, v_sub_[iu]32,
664e8d8bef9SDimitry Andric   /// v_add_[iu]16, and v_sub_[iu]16, all of which support the clamp modifier
665e8d8bef9SDimitry Andric   /// for saturation.
666e8d8bef9SDimitry Andric   bool hasAddNoCarry() const {
667e8d8bef9SDimitry Andric     return AddNoCarryInsts;
668e8d8bef9SDimitry Andric   }
669e8d8bef9SDimitry Andric 
670e8d8bef9SDimitry Andric   bool hasUnpackedD16VMem() const {
671e8d8bef9SDimitry Andric     return HasUnpackedD16VMem;
672e8d8bef9SDimitry Andric   }
673e8d8bef9SDimitry Andric 
674e8d8bef9SDimitry Andric   // Covers VS/PS/CS graphics shaders
675e8d8bef9SDimitry Andric   bool isMesaGfxShader(const Function &F) const {
676e8d8bef9SDimitry Andric     return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
677e8d8bef9SDimitry Andric   }
678e8d8bef9SDimitry Andric 
679e8d8bef9SDimitry Andric   bool hasMad64_32() const {
680e8d8bef9SDimitry Andric     return getGeneration() >= SEA_ISLANDS;
681e8d8bef9SDimitry Andric   }
682e8d8bef9SDimitry Andric 
683e8d8bef9SDimitry Andric   bool hasSDWAOmod() const {
684e8d8bef9SDimitry Andric     return HasSDWAOmod;
685e8d8bef9SDimitry Andric   }
686e8d8bef9SDimitry Andric 
687e8d8bef9SDimitry Andric   bool hasSDWAScalar() const {
688e8d8bef9SDimitry Andric     return HasSDWAScalar;
689e8d8bef9SDimitry Andric   }
690e8d8bef9SDimitry Andric 
691e8d8bef9SDimitry Andric   bool hasSDWASdst() const {
692e8d8bef9SDimitry Andric     return HasSDWASdst;
693e8d8bef9SDimitry Andric   }
694e8d8bef9SDimitry Andric 
695e8d8bef9SDimitry Andric   bool hasSDWAMac() const {
696e8d8bef9SDimitry Andric     return HasSDWAMac;
697e8d8bef9SDimitry Andric   }
698e8d8bef9SDimitry Andric 
699e8d8bef9SDimitry Andric   bool hasSDWAOutModsVOPC() const {
700e8d8bef9SDimitry Andric     return HasSDWAOutModsVOPC;
701e8d8bef9SDimitry Andric   }
702e8d8bef9SDimitry Andric 
703e8d8bef9SDimitry Andric   bool hasDLInsts() const {
704e8d8bef9SDimitry Andric     return HasDLInsts;
705e8d8bef9SDimitry Andric   }
706e8d8bef9SDimitry Andric 
707bdd1243dSDimitry Andric   bool hasFmacF64Inst() const { return HasFmacF64Inst; }
708bdd1243dSDimitry Andric 
709e8d8bef9SDimitry Andric   bool hasDot1Insts() const {
710e8d8bef9SDimitry Andric     return HasDot1Insts;
711e8d8bef9SDimitry Andric   }
712e8d8bef9SDimitry Andric 
713e8d8bef9SDimitry Andric   bool hasDot2Insts() const {
714e8d8bef9SDimitry Andric     return HasDot2Insts;
715e8d8bef9SDimitry Andric   }
716e8d8bef9SDimitry Andric 
717e8d8bef9SDimitry Andric   bool hasDot3Insts() const {
718e8d8bef9SDimitry Andric     return HasDot3Insts;
719e8d8bef9SDimitry Andric   }
720e8d8bef9SDimitry Andric 
721e8d8bef9SDimitry Andric   bool hasDot4Insts() const {
722e8d8bef9SDimitry Andric     return HasDot4Insts;
723e8d8bef9SDimitry Andric   }
724e8d8bef9SDimitry Andric 
725e8d8bef9SDimitry Andric   bool hasDot5Insts() const {
726e8d8bef9SDimitry Andric     return HasDot5Insts;
727e8d8bef9SDimitry Andric   }
728e8d8bef9SDimitry Andric 
729e8d8bef9SDimitry Andric   bool hasDot6Insts() const {
730e8d8bef9SDimitry Andric     return HasDot6Insts;
731e8d8bef9SDimitry Andric   }
732e8d8bef9SDimitry Andric 
733fe6060f1SDimitry Andric   bool hasDot7Insts() const {
734fe6060f1SDimitry Andric     return HasDot7Insts;
735fe6060f1SDimitry Andric   }
736fe6060f1SDimitry Andric 
73781ad6265SDimitry Andric   bool hasDot8Insts() const {
73881ad6265SDimitry Andric     return HasDot8Insts;
73981ad6265SDimitry Andric   }
74081ad6265SDimitry Andric 
741bdd1243dSDimitry Andric   bool hasDot9Insts() const {
742bdd1243dSDimitry Andric     return HasDot9Insts;
743bdd1243dSDimitry Andric   }
744bdd1243dSDimitry Andric 
745*06c3fb27SDimitry Andric   bool hasDot10Insts() const {
746*06c3fb27SDimitry Andric     return HasDot10Insts;
747*06c3fb27SDimitry Andric   }
748*06c3fb27SDimitry Andric 
749e8d8bef9SDimitry Andric   bool hasMAIInsts() const {
750e8d8bef9SDimitry Andric     return HasMAIInsts;
751e8d8bef9SDimitry Andric   }
752e8d8bef9SDimitry Andric 
753fcaf7f86SDimitry Andric   bool hasFP8Insts() const {
754fcaf7f86SDimitry Andric     return HasFP8Insts;
755fcaf7f86SDimitry Andric   }
756fcaf7f86SDimitry Andric 
757e8d8bef9SDimitry Andric   bool hasPkFmacF16Inst() const {
758e8d8bef9SDimitry Andric     return HasPkFmacF16Inst;
759e8d8bef9SDimitry Andric   }
760e8d8bef9SDimitry Andric 
761*06c3fb27SDimitry Andric   bool hasAtomicDsPkAdd16Insts() const { return HasAtomicDsPkAdd16Insts; }
762*06c3fb27SDimitry Andric 
763*06c3fb27SDimitry Andric   bool hasAtomicFlatPkAdd16Insts() const { return HasAtomicFlatPkAdd16Insts; }
764*06c3fb27SDimitry Andric 
765e8d8bef9SDimitry Andric   bool hasAtomicFaddInsts() const {
76681ad6265SDimitry Andric     return HasAtomicFaddRtnInsts || HasAtomicFaddNoRtnInsts;
767e8d8bef9SDimitry Andric   }
768e8d8bef9SDimitry Andric 
76981ad6265SDimitry Andric   bool hasAtomicFaddRtnInsts() const { return HasAtomicFaddRtnInsts; }
77081ad6265SDimitry Andric 
77181ad6265SDimitry Andric   bool hasAtomicFaddNoRtnInsts() const { return HasAtomicFaddNoRtnInsts; }
77281ad6265SDimitry Andric 
773*06c3fb27SDimitry Andric   bool hasAtomicBufferGlobalPkAddF16NoRtnInsts() const {
774*06c3fb27SDimitry Andric     return HasAtomicBufferGlobalPkAddF16NoRtnInsts;
775*06c3fb27SDimitry Andric   }
776*06c3fb27SDimitry Andric 
777*06c3fb27SDimitry Andric   bool hasAtomicBufferGlobalPkAddF16Insts() const {
778*06c3fb27SDimitry Andric     return HasAtomicBufferGlobalPkAddF16Insts;
779*06c3fb27SDimitry Andric   }
780*06c3fb27SDimitry Andric 
781*06c3fb27SDimitry Andric   bool hasAtomicGlobalPkAddBF16Inst() const {
782*06c3fb27SDimitry Andric     return HasAtomicGlobalPkAddBF16Inst;
783*06c3fb27SDimitry Andric   }
78481ad6265SDimitry Andric 
785bdd1243dSDimitry Andric   bool hasFlatAtomicFaddF32Inst() const { return HasFlatAtomicFaddF32Inst; }
786bdd1243dSDimitry Andric 
787e8d8bef9SDimitry Andric   bool hasNoSdstCMPX() const {
788e8d8bef9SDimitry Andric     return HasNoSdstCMPX;
789e8d8bef9SDimitry Andric   }
790e8d8bef9SDimitry Andric 
791e8d8bef9SDimitry Andric   bool hasVscnt() const {
792e8d8bef9SDimitry Andric     return HasVscnt;
793e8d8bef9SDimitry Andric   }
794e8d8bef9SDimitry Andric 
795e8d8bef9SDimitry Andric   bool hasGetWaveIdInst() const {
796e8d8bef9SDimitry Andric     return HasGetWaveIdInst;
797e8d8bef9SDimitry Andric   }
798e8d8bef9SDimitry Andric 
799e8d8bef9SDimitry Andric   bool hasSMemTimeInst() const {
800e8d8bef9SDimitry Andric     return HasSMemTimeInst;
801e8d8bef9SDimitry Andric   }
802e8d8bef9SDimitry Andric 
803fe6060f1SDimitry Andric   bool hasShaderCyclesRegister() const {
804fe6060f1SDimitry Andric     return HasShaderCyclesRegister;
805fe6060f1SDimitry Andric   }
806fe6060f1SDimitry Andric 
807e8d8bef9SDimitry Andric   bool hasVOP3Literal() const {
808e8d8bef9SDimitry Andric     return HasVOP3Literal;
809e8d8bef9SDimitry Andric   }
810e8d8bef9SDimitry Andric 
811e8d8bef9SDimitry Andric   bool hasNoDataDepHazard() const {
812e8d8bef9SDimitry Andric     return HasNoDataDepHazard;
813e8d8bef9SDimitry Andric   }
814e8d8bef9SDimitry Andric 
815e8d8bef9SDimitry Andric   bool vmemWriteNeedsExpWaitcnt() const {
816e8d8bef9SDimitry Andric     return getGeneration() < SEA_ISLANDS;
817e8d8bef9SDimitry Andric   }
818e8d8bef9SDimitry Andric 
819bdd1243dSDimitry Andric   bool hasInstPrefetch() const { return getGeneration() >= GFX10; }
820bdd1243dSDimitry Andric 
821e8d8bef9SDimitry Andric   // Scratch is allocated in 256 dword per wave blocks for the entire
822349cc55cSDimitry Andric   // wavefront. When viewed from the perspective of an arbitrary workitem, this
823e8d8bef9SDimitry Andric   // is 4-byte aligned.
824e8d8bef9SDimitry Andric   //
825e8d8bef9SDimitry Andric   // Only 4-byte alignment is really needed to access anything. Transformations
826e8d8bef9SDimitry Andric   // on the pointer value itself may rely on the alignment / known low bits of
827e8d8bef9SDimitry Andric   // the pointer. Set this to something above the minimum to avoid needing
828e8d8bef9SDimitry Andric   // dynamic realignment in common cases.
829e8d8bef9SDimitry Andric   Align getStackAlignment() const { return Align(16); }
830e8d8bef9SDimitry Andric 
831e8d8bef9SDimitry Andric   bool enableMachineScheduler() const override {
832e8d8bef9SDimitry Andric     return true;
833e8d8bef9SDimitry Andric   }
834e8d8bef9SDimitry Andric 
835e8d8bef9SDimitry Andric   bool useAA() const override;
836e8d8bef9SDimitry Andric 
837e8d8bef9SDimitry Andric   bool enableSubRegLiveness() const override {
838e8d8bef9SDimitry Andric     return true;
839e8d8bef9SDimitry Andric   }
840e8d8bef9SDimitry Andric 
841e8d8bef9SDimitry Andric   void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; }
842e8d8bef9SDimitry Andric   bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; }
843e8d8bef9SDimitry Andric 
844e8d8bef9SDimitry Andric   // static wrappers
845e8d8bef9SDimitry Andric   static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
846e8d8bef9SDimitry Andric 
847e8d8bef9SDimitry Andric   // XXX - Why is this here if it isn't in the default pass set?
848e8d8bef9SDimitry Andric   bool enableEarlyIfConversion() const override {
849e8d8bef9SDimitry Andric     return true;
850e8d8bef9SDimitry Andric   }
851e8d8bef9SDimitry Andric 
852e8d8bef9SDimitry Andric   void overrideSchedPolicy(MachineSchedPolicy &Policy,
853e8d8bef9SDimitry Andric                            unsigned NumRegionInstrs) const override;
854e8d8bef9SDimitry Andric 
855e8d8bef9SDimitry Andric   unsigned getMaxNumUserSGPRs() const {
856e8d8bef9SDimitry Andric     return 16;
857e8d8bef9SDimitry Andric   }
858e8d8bef9SDimitry Andric 
859e8d8bef9SDimitry Andric   bool hasSMemRealTime() const {
860e8d8bef9SDimitry Andric     return HasSMemRealTime;
861e8d8bef9SDimitry Andric   }
862e8d8bef9SDimitry Andric 
863e8d8bef9SDimitry Andric   bool hasMovrel() const {
864e8d8bef9SDimitry Andric     return HasMovrel;
865e8d8bef9SDimitry Andric   }
866e8d8bef9SDimitry Andric 
867e8d8bef9SDimitry Andric   bool hasVGPRIndexMode() const {
868e8d8bef9SDimitry Andric     return HasVGPRIndexMode;
869e8d8bef9SDimitry Andric   }
870e8d8bef9SDimitry Andric 
871e8d8bef9SDimitry Andric   bool useVGPRIndexMode() const;
872e8d8bef9SDimitry Andric 
873e8d8bef9SDimitry Andric   bool hasScalarCompareEq64() const {
874e8d8bef9SDimitry Andric     return getGeneration() >= VOLCANIC_ISLANDS;
875e8d8bef9SDimitry Andric   }
876e8d8bef9SDimitry Andric 
877e8d8bef9SDimitry Andric   bool hasScalarStores() const {
878e8d8bef9SDimitry Andric     return HasScalarStores;
879e8d8bef9SDimitry Andric   }
880e8d8bef9SDimitry Andric 
881e8d8bef9SDimitry Andric   bool hasScalarAtomics() const {
882e8d8bef9SDimitry Andric     return HasScalarAtomics;
883e8d8bef9SDimitry Andric   }
884e8d8bef9SDimitry Andric 
885349cc55cSDimitry Andric   bool hasLDSFPAtomicAdd() const { return GFX8Insts; }
886e8d8bef9SDimitry Andric 
887fe6060f1SDimitry Andric   /// \returns true if the subtarget has the v_permlanex16_b32 instruction.
888fe6060f1SDimitry Andric   bool hasPermLaneX16() const { return getGeneration() >= GFX10; }
889fe6060f1SDimitry Andric 
89081ad6265SDimitry Andric   /// \returns true if the subtarget has the v_permlane64_b32 instruction.
89181ad6265SDimitry Andric   bool hasPermLane64() const { return getGeneration() >= GFX11; }
89281ad6265SDimitry Andric 
893e8d8bef9SDimitry Andric   bool hasDPP() const {
894e8d8bef9SDimitry Andric     return HasDPP;
895e8d8bef9SDimitry Andric   }
896e8d8bef9SDimitry Andric 
897e8d8bef9SDimitry Andric   bool hasDPPBroadcasts() const {
898e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
899e8d8bef9SDimitry Andric   }
900e8d8bef9SDimitry Andric 
901e8d8bef9SDimitry Andric   bool hasDPPWavefrontShifts() const {
902e8d8bef9SDimitry Andric     return HasDPP && getGeneration() < GFX10;
903e8d8bef9SDimitry Andric   }
904e8d8bef9SDimitry Andric 
905e8d8bef9SDimitry Andric   bool hasDPP8() const {
906e8d8bef9SDimitry Andric     return HasDPP8;
907e8d8bef9SDimitry Andric   }
908e8d8bef9SDimitry Andric 
909fe6060f1SDimitry Andric   bool has64BitDPP() const {
910fe6060f1SDimitry Andric     return Has64BitDPP;
911fe6060f1SDimitry Andric   }
912fe6060f1SDimitry Andric 
913fe6060f1SDimitry Andric   bool hasPackedFP32Ops() const {
914fe6060f1SDimitry Andric     return HasPackedFP32Ops;
915fe6060f1SDimitry Andric   }
916fe6060f1SDimitry Andric 
917fe6060f1SDimitry Andric   bool hasFmaakFmamkF32Insts() const {
91881ad6265SDimitry Andric     return getGeneration() >= GFX10 || hasGFX940Insts();
91981ad6265SDimitry Andric   }
92081ad6265SDimitry Andric 
92181ad6265SDimitry Andric   bool hasImageInsts() const {
92281ad6265SDimitry Andric     return HasImageInsts;
923fe6060f1SDimitry Andric   }
924fe6060f1SDimitry Andric 
925fe6060f1SDimitry Andric   bool hasExtendedImageInsts() const {
926fe6060f1SDimitry Andric     return HasExtendedImageInsts;
927fe6060f1SDimitry Andric   }
928fe6060f1SDimitry Andric 
929e8d8bef9SDimitry Andric   bool hasR128A16() const {
930e8d8bef9SDimitry Andric     return HasR128A16;
931e8d8bef9SDimitry Andric   }
932e8d8bef9SDimitry Andric 
933bdd1243dSDimitry Andric   bool hasA16() const { return HasA16; }
934e8d8bef9SDimitry Andric 
935e8d8bef9SDimitry Andric   bool hasG16() const { return HasG16; }
936e8d8bef9SDimitry Andric 
937e8d8bef9SDimitry Andric   bool hasOffset3fBug() const {
938e8d8bef9SDimitry Andric     return HasOffset3fBug;
939e8d8bef9SDimitry Andric   }
940e8d8bef9SDimitry Andric 
941e8d8bef9SDimitry Andric   bool hasImageStoreD16Bug() const { return HasImageStoreD16Bug; }
942e8d8bef9SDimitry Andric 
943e8d8bef9SDimitry Andric   bool hasImageGather4D16Bug() const { return HasImageGather4D16Bug; }
944e8d8bef9SDimitry Andric 
945bdd1243dSDimitry Andric   bool hasMADIntraFwdBug() const { return HasMADIntraFwdBug; }
946bdd1243dSDimitry Andric 
947e8d8bef9SDimitry Andric   bool hasNSAEncoding() const { return HasNSAEncoding; }
948e8d8bef9SDimitry Andric 
949*06c3fb27SDimitry Andric   bool hasPartialNSAEncoding() const { return HasPartialNSAEncoding; }
950*06c3fb27SDimitry Andric 
951*06c3fb27SDimitry Andric   unsigned getNSAMaxSize() const { return AMDGPU::getNSAMaxSize(*this); }
952fe6060f1SDimitry Andric 
953fe6060f1SDimitry Andric   bool hasGFX10_AEncoding() const {
954fe6060f1SDimitry Andric     return GFX10_AEncoding;
955fe6060f1SDimitry Andric   }
956fe6060f1SDimitry Andric 
957e8d8bef9SDimitry Andric   bool hasGFX10_BEncoding() const {
958e8d8bef9SDimitry Andric     return GFX10_BEncoding;
959e8d8bef9SDimitry Andric   }
960e8d8bef9SDimitry Andric 
961e8d8bef9SDimitry Andric   bool hasGFX10_3Insts() const {
962e8d8bef9SDimitry Andric     return GFX10_3Insts;
963e8d8bef9SDimitry Andric   }
964e8d8bef9SDimitry Andric 
965e8d8bef9SDimitry Andric   bool hasMadF16() const;
966e8d8bef9SDimitry Andric 
96781ad6265SDimitry Andric   bool hasMovB64() const { return GFX940Insts; }
96881ad6265SDimitry Andric 
96981ad6265SDimitry Andric   bool hasLshlAddB64() const { return GFX940Insts; }
97081ad6265SDimitry Andric 
971e8d8bef9SDimitry Andric   bool enableSIScheduler() const {
972e8d8bef9SDimitry Andric     return EnableSIScheduler;
973e8d8bef9SDimitry Andric   }
974e8d8bef9SDimitry Andric 
975e8d8bef9SDimitry Andric   bool loadStoreOptEnabled() const {
976e8d8bef9SDimitry Andric     return EnableLoadStoreOpt;
977e8d8bef9SDimitry Andric   }
978e8d8bef9SDimitry Andric 
979e8d8bef9SDimitry Andric   bool hasSGPRInitBug() const {
980e8d8bef9SDimitry Andric     return SGPRInitBug;
981e8d8bef9SDimitry Andric   }
982e8d8bef9SDimitry Andric 
98381ad6265SDimitry Andric   bool hasUserSGPRInit16Bug() const {
984fcaf7f86SDimitry Andric     return UserSGPRInit16Bug && isWave32();
98581ad6265SDimitry Andric   }
98681ad6265SDimitry Andric 
987fe6060f1SDimitry Andric   bool hasNegativeScratchOffsetBug() const { return NegativeScratchOffsetBug; }
988fe6060f1SDimitry Andric 
989fe6060f1SDimitry Andric   bool hasNegativeUnalignedScratchOffsetBug() const {
990fe6060f1SDimitry Andric     return NegativeUnalignedScratchOffsetBug;
991fe6060f1SDimitry Andric   }
992fe6060f1SDimitry Andric 
993e8d8bef9SDimitry Andric   bool hasMFMAInlineLiteralBug() const {
994e8d8bef9SDimitry Andric     return HasMFMAInlineLiteralBug;
995e8d8bef9SDimitry Andric   }
996e8d8bef9SDimitry Andric 
997e8d8bef9SDimitry Andric   bool has12DWordStoreHazard() const {
998e8d8bef9SDimitry Andric     return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
999e8d8bef9SDimitry Andric   }
1000e8d8bef9SDimitry Andric 
1001e8d8bef9SDimitry Andric   // \returns true if the subtarget supports DWORDX3 load/store instructions.
1002e8d8bef9SDimitry Andric   bool hasDwordx3LoadStores() const {
1003e8d8bef9SDimitry Andric     return CIInsts;
1004e8d8bef9SDimitry Andric   }
1005e8d8bef9SDimitry Andric 
1006e8d8bef9SDimitry Andric   bool hasReadM0MovRelInterpHazard() const {
1007e8d8bef9SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
1008e8d8bef9SDimitry Andric   }
1009e8d8bef9SDimitry Andric 
1010e8d8bef9SDimitry Andric   bool hasReadM0SendMsgHazard() const {
1011e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&
1012e8d8bef9SDimitry Andric            getGeneration() <= AMDGPUSubtarget::GFX9;
1013e8d8bef9SDimitry Andric   }
1014e8d8bef9SDimitry Andric 
101581ad6265SDimitry Andric   bool hasReadM0LdsDmaHazard() const {
101681ad6265SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
101781ad6265SDimitry Andric   }
101881ad6265SDimitry Andric 
101981ad6265SDimitry Andric   bool hasReadM0LdsDirectHazard() const {
102081ad6265SDimitry Andric     return getGeneration() == AMDGPUSubtarget::GFX9;
102181ad6265SDimitry Andric   }
102281ad6265SDimitry Andric 
1023e8d8bef9SDimitry Andric   bool hasVcmpxPermlaneHazard() const {
1024e8d8bef9SDimitry Andric     return HasVcmpxPermlaneHazard;
1025e8d8bef9SDimitry Andric   }
1026e8d8bef9SDimitry Andric 
1027e8d8bef9SDimitry Andric   bool hasVMEMtoScalarWriteHazard() const {
1028e8d8bef9SDimitry Andric     return HasVMEMtoScalarWriteHazard;
1029e8d8bef9SDimitry Andric   }
1030e8d8bef9SDimitry Andric 
1031e8d8bef9SDimitry Andric   bool hasSMEMtoVectorWriteHazard() const {
1032e8d8bef9SDimitry Andric     return HasSMEMtoVectorWriteHazard;
1033e8d8bef9SDimitry Andric   }
1034e8d8bef9SDimitry Andric 
1035e8d8bef9SDimitry Andric   bool hasLDSMisalignedBug() const {
1036e8d8bef9SDimitry Andric     return LDSMisalignedBug && !EnableCuMode;
1037e8d8bef9SDimitry Andric   }
1038e8d8bef9SDimitry Andric 
1039e8d8bef9SDimitry Andric   bool hasInstFwdPrefetchBug() const {
1040e8d8bef9SDimitry Andric     return HasInstFwdPrefetchBug;
1041e8d8bef9SDimitry Andric   }
1042e8d8bef9SDimitry Andric 
1043e8d8bef9SDimitry Andric   bool hasVcmpxExecWARHazard() const {
1044e8d8bef9SDimitry Andric     return HasVcmpxExecWARHazard;
1045e8d8bef9SDimitry Andric   }
1046e8d8bef9SDimitry Andric 
1047e8d8bef9SDimitry Andric   bool hasLdsBranchVmemWARHazard() const {
1048e8d8bef9SDimitry Andric     return HasLdsBranchVmemWARHazard;
1049e8d8bef9SDimitry Andric   }
1050e8d8bef9SDimitry Andric 
1051bdd1243dSDimitry Andric   // Shift amount of a 64 bit shift cannot be a highest allocated register
1052bdd1243dSDimitry Andric   // if also at the end of the allocation block.
1053bdd1243dSDimitry Andric   bool hasShift64HighRegBug() const {
1054bdd1243dSDimitry Andric     return GFX90AInsts && !GFX940Insts;
1055bdd1243dSDimitry Andric   }
1056bdd1243dSDimitry Andric 
105781ad6265SDimitry Andric   // Has one cycle hazard on transcendental instruction feeding a
105881ad6265SDimitry Andric   // non transcendental VALU.
105981ad6265SDimitry Andric   bool hasTransForwardingHazard() const { return GFX940Insts; }
106081ad6265SDimitry Andric 
106181ad6265SDimitry Andric   // Has one cycle hazard on a VALU instruction partially writing dst with
106281ad6265SDimitry Andric   // a shift of result bits feeding another VALU instruction.
106381ad6265SDimitry Andric   bool hasDstSelForwardingHazard() const { return GFX940Insts; }
106481ad6265SDimitry Andric 
106581ad6265SDimitry Andric   // Cannot use op_sel with v_dot instructions.
106681ad6265SDimitry Andric   bool hasDOTOpSelHazard() const { return GFX940Insts; }
106781ad6265SDimitry Andric 
106881ad6265SDimitry Andric   // Does not have HW interlocs for VALU writing and then reading SGPRs.
106981ad6265SDimitry Andric   bool hasVDecCoExecHazard() const {
107081ad6265SDimitry Andric     return GFX940Insts;
107181ad6265SDimitry Andric   }
107281ad6265SDimitry Andric 
1073e8d8bef9SDimitry Andric   bool hasNSAtoVMEMBug() const {
1074e8d8bef9SDimitry Andric     return HasNSAtoVMEMBug;
1075e8d8bef9SDimitry Andric   }
1076e8d8bef9SDimitry Andric 
1077fe6060f1SDimitry Andric   bool hasNSAClauseBug() const { return HasNSAClauseBug; }
1078fe6060f1SDimitry Andric 
1079e8d8bef9SDimitry Andric   bool hasHardClauses() const { return getGeneration() >= GFX10; }
1080e8d8bef9SDimitry Andric 
1081fe6060f1SDimitry Andric   bool hasGFX90AInsts() const { return GFX90AInsts; }
1082fe6060f1SDimitry Andric 
1083bdd1243dSDimitry Andric   bool hasFPAtomicToDenormModeHazard() const {
1084bdd1243dSDimitry Andric     return getGeneration() == GFX10;
1085bdd1243dSDimitry Andric   }
1086bdd1243dSDimitry Andric 
108781ad6265SDimitry Andric   bool hasVOP3DPP() const { return getGeneration() >= GFX11; }
108881ad6265SDimitry Andric 
108981ad6265SDimitry Andric   bool hasLdsDirect() const { return getGeneration() >= GFX11; }
109081ad6265SDimitry Andric 
109181ad6265SDimitry Andric   bool hasVALUPartialForwardingHazard() const {
109281ad6265SDimitry Andric     return getGeneration() >= GFX11;
109381ad6265SDimitry Andric   }
109481ad6265SDimitry Andric 
1095bdd1243dSDimitry Andric   bool hasVALUTransUseHazard() const { return HasVALUTransUseHazard; }
1096bdd1243dSDimitry Andric 
1097*06c3fb27SDimitry Andric   bool hasForceStoreSC0SC1() const { return HasForceStoreSC0SC1; }
1098*06c3fb27SDimitry Andric 
1099bdd1243dSDimitry Andric   bool hasVALUMaskWriteHazard() const { return getGeneration() >= GFX11; }
110081ad6265SDimitry Andric 
1101fe6060f1SDimitry Andric   /// Return if operations acting on VGPR tuples require even alignment.
1102fe6060f1SDimitry Andric   bool needsAlignedVGPRs() const { return GFX90AInsts; }
1103fe6060f1SDimitry Andric 
110481ad6265SDimitry Andric   /// Return true if the target has the S_PACK_HL_B32_B16 instruction.
110581ad6265SDimitry Andric   bool hasSPackHL() const { return GFX11Insts; }
110681ad6265SDimitry Andric 
110781ad6265SDimitry Andric   /// Return true if the target's EXP instruction has the COMPR flag, which
110881ad6265SDimitry Andric   /// affects the meaning of the EN (enable) bits.
110981ad6265SDimitry Andric   bool hasCompressedExport() const { return !GFX11Insts; }
111081ad6265SDimitry Andric 
111181ad6265SDimitry Andric   /// Return true if the target's EXP instruction supports the NULL export
111281ad6265SDimitry Andric   /// target.
111381ad6265SDimitry Andric   bool hasNullExportTarget() const { return !GFX11Insts; }
111481ad6265SDimitry Andric 
1115bdd1243dSDimitry Andric   bool hasGFX11FullVGPRs() const { return HasGFX11FullVGPRs; }
1116bdd1243dSDimitry Andric 
111781ad6265SDimitry Andric   bool hasVOPDInsts() const { return HasVOPDInsts; }
111881ad6265SDimitry Andric 
111981ad6265SDimitry Andric   bool hasFlatScratchSVSSwizzleBug() const { return getGeneration() == GFX11; }
112081ad6265SDimitry Andric 
112181ad6265SDimitry Andric   /// Return true if the target has the S_DELAY_ALU instruction.
112281ad6265SDimitry Andric   bool hasDelayAlu() const { return GFX11Insts; }
112381ad6265SDimitry Andric 
1124fe6060f1SDimitry Andric   bool hasPackedTID() const { return HasPackedTID; }
1125fe6060f1SDimitry Andric 
112681ad6265SDimitry Andric   // GFX940 is a derivation to GFX90A. hasGFX940Insts() being true implies that
112781ad6265SDimitry Andric   // hasGFX90AInsts is also true.
112881ad6265SDimitry Andric   bool hasGFX940Insts() const { return GFX940Insts; }
112981ad6265SDimitry Andric 
1130e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
1131e8d8bef9SDimitry Andric   /// SGPRs
1132e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
1133e8d8bef9SDimitry Andric 
1134e8d8bef9SDimitry Andric   /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
1135e8d8bef9SDimitry Andric   /// VGPRs
1136e8d8bef9SDimitry Andric   unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
1137e8d8bef9SDimitry Andric 
1138e8d8bef9SDimitry Andric   /// Return occupancy for the given function. Used LDS and a number of
1139e8d8bef9SDimitry Andric   /// registers if provided.
1140e8d8bef9SDimitry Andric   /// Note, occupancy can be affected by the scratch allocation as well, but
1141e8d8bef9SDimitry Andric   /// we do not have enough information to compute it.
1142e8d8bef9SDimitry Andric   unsigned computeOccupancy(const Function &F, unsigned LDSSize = 0,
1143e8d8bef9SDimitry Andric                             unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const;
1144e8d8bef9SDimitry Andric 
1145e8d8bef9SDimitry Andric   /// \returns true if the flat_scratch register should be initialized with the
1146e8d8bef9SDimitry Andric   /// pointer to the wave's scratch memory rather than a size and offset.
1147e8d8bef9SDimitry Andric   bool flatScratchIsPointer() const {
1148e8d8bef9SDimitry Andric     return getGeneration() >= AMDGPUSubtarget::GFX9;
1149e8d8bef9SDimitry Andric   }
1150e8d8bef9SDimitry Andric 
1151fe6060f1SDimitry Andric   /// \returns true if the flat_scratch register is initialized by the HW.
1152fe6060f1SDimitry Andric   /// In this case it is readonly.
1153fe6060f1SDimitry Andric   bool flatScratchIsArchitected() const { return HasArchitectedFlatScratch; }
1154fe6060f1SDimitry Andric 
1155*06c3fb27SDimitry Andric   /// \returns true if the architected SGPRs are enabled.
1156*06c3fb27SDimitry Andric   bool hasArchitectedSGPRs() const { return HasArchitectedSGPRs; }
1157*06c3fb27SDimitry Andric 
1158e8d8bef9SDimitry Andric   /// \returns true if the machine has merged shaders in which s0-s7 are
1159e8d8bef9SDimitry Andric   /// reserved by the hardware and user SGPRs start at s8
1160e8d8bef9SDimitry Andric   bool hasMergedShaders() const {
1161e8d8bef9SDimitry Andric     return getGeneration() >= GFX9;
1162e8d8bef9SDimitry Andric   }
1163e8d8bef9SDimitry Andric 
116481ad6265SDimitry Andric   // \returns true if the target supports the pre-NGG legacy geometry path.
116581ad6265SDimitry Andric   bool hasLegacyGeometry() const { return getGeneration() < GFX11; }
116681ad6265SDimitry Andric 
1167e8d8bef9SDimitry Andric   /// \returns SGPR allocation granularity supported by the subtarget.
1168e8d8bef9SDimitry Andric   unsigned getSGPRAllocGranule() const {
1169e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPRAllocGranule(this);
1170e8d8bef9SDimitry Andric   }
1171e8d8bef9SDimitry Andric 
1172e8d8bef9SDimitry Andric   /// \returns SGPR encoding granularity supported by the subtarget.
1173e8d8bef9SDimitry Andric   unsigned getSGPREncodingGranule() const {
1174e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getSGPREncodingGranule(this);
1175e8d8bef9SDimitry Andric   }
1176e8d8bef9SDimitry Andric 
1177e8d8bef9SDimitry Andric   /// \returns Total number of SGPRs supported by the subtarget.
1178e8d8bef9SDimitry Andric   unsigned getTotalNumSGPRs() const {
1179e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumSGPRs(this);
1180e8d8bef9SDimitry Andric   }
1181e8d8bef9SDimitry Andric 
1182e8d8bef9SDimitry Andric   /// \returns Addressable number of SGPRs supported by the subtarget.
1183e8d8bef9SDimitry Andric   unsigned getAddressableNumSGPRs() const {
1184e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumSGPRs(this);
1185e8d8bef9SDimitry Andric   }
1186e8d8bef9SDimitry Andric 
1187e8d8bef9SDimitry Andric   /// \returns Minimum number of SGPRs that meets the given number of waves per
1188e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1189e8d8bef9SDimitry Andric   unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
1190e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU);
1191e8d8bef9SDimitry Andric   }
1192e8d8bef9SDimitry Andric 
1193e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets the given number of waves per
1194e8d8bef9SDimitry Andric   /// execution unit requirement supported by the subtarget.
1195e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
1196e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable);
1197e8d8bef9SDimitry Andric   }
1198e8d8bef9SDimitry Andric 
1199fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs. This is common
1200fe6060f1SDimitry Andric   /// utility function called by MachineFunction and
1201fe6060f1SDimitry Andric   /// Function variants of getReservedNumSGPRs.
120204eeddc0SDimitry Andric   unsigned getBaseReservedNumSGPRs(const bool HasFlatScratch) const;
1203fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given machine function \p MF.
1204e8d8bef9SDimitry Andric   unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
1205e8d8bef9SDimitry Andric 
1206fe6060f1SDimitry Andric   /// \returns Reserved number of SGPRs for given function \p F.
1207fe6060f1SDimitry Andric   unsigned getReservedNumSGPRs(const Function &F) const;
1208fe6060f1SDimitry Andric 
1209fe6060f1SDimitry Andric   /// \returns max num SGPRs. This is the common utility
1210fe6060f1SDimitry Andric   /// function called by MachineFunction and Function
1211fe6060f1SDimitry Andric   /// variants of getMaxNumSGPRs.
1212fe6060f1SDimitry Andric   unsigned getBaseMaxNumSGPRs(const Function &F,
1213fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU,
1214fe6060f1SDimitry Andric                               unsigned PreloadedSGPRs,
1215fe6060f1SDimitry Andric                               unsigned ReservedNumSGPRs) const;
1216fe6060f1SDimitry Andric 
1217e8d8bef9SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1218e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of SGPRs explicitly
1219e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
1220e8d8bef9SDimitry Andric   ///
1221e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1222e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1223e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1224e8d8bef9SDimitry Andric   /// unit requirement.
1225e8d8bef9SDimitry Andric   unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
1226e8d8bef9SDimitry Andric 
1227fe6060f1SDimitry Andric   /// \returns Maximum number of SGPRs that meets number of waves per execution
1228fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of SGPRs explicitly
1229fe6060f1SDimitry Andric   /// requested using "amdgpu-num-sgpr" attribute attached to function \p F.
1230fe6060f1SDimitry Andric   ///
1231fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1232fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1233fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1234fe6060f1SDimitry Andric   /// unit requirement.
1235fe6060f1SDimitry Andric   unsigned getMaxNumSGPRs(const Function &F) const;
1236fe6060f1SDimitry Andric 
1237e8d8bef9SDimitry Andric   /// \returns VGPR allocation granularity supported by the subtarget.
1238e8d8bef9SDimitry Andric   unsigned getVGPRAllocGranule() const {
1239e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPRAllocGranule(this);
1240e8d8bef9SDimitry Andric   }
1241e8d8bef9SDimitry Andric 
1242e8d8bef9SDimitry Andric   /// \returns VGPR encoding granularity supported by the subtarget.
1243e8d8bef9SDimitry Andric   unsigned getVGPREncodingGranule() const {
1244e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getVGPREncodingGranule(this);
1245e8d8bef9SDimitry Andric   }
1246e8d8bef9SDimitry Andric 
1247e8d8bef9SDimitry Andric   /// \returns Total number of VGPRs supported by the subtarget.
1248e8d8bef9SDimitry Andric   unsigned getTotalNumVGPRs() const {
1249e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getTotalNumVGPRs(this);
1250e8d8bef9SDimitry Andric   }
1251e8d8bef9SDimitry Andric 
1252e8d8bef9SDimitry Andric   /// \returns Addressable number of VGPRs supported by the subtarget.
1253e8d8bef9SDimitry Andric   unsigned getAddressableNumVGPRs() const {
1254e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getAddressableNumVGPRs(this);
1255e8d8bef9SDimitry Andric   }
1256e8d8bef9SDimitry Andric 
1257bdd1243dSDimitry Andric   /// \returns the minimum number of VGPRs that will prevent achieving more than
1258bdd1243dSDimitry Andric   /// the specified number of waves \p WavesPerEU.
1259e8d8bef9SDimitry Andric   unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
1260e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU);
1261e8d8bef9SDimitry Andric   }
1262e8d8bef9SDimitry Andric 
1263bdd1243dSDimitry Andric   /// \returns the maximum number of VGPRs that can be used and still achieved
1264bdd1243dSDimitry Andric   /// at least the specified number of waves \p WavesPerEU.
1265e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
1266e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU);
1267e8d8bef9SDimitry Andric   }
1268e8d8bef9SDimitry Andric 
1269fe6060f1SDimitry Andric   /// \returns max num VGPRs. This is the common utility function
1270fe6060f1SDimitry Andric   /// called by MachineFunction and Function variants of getMaxNumVGPRs.
1271fe6060f1SDimitry Andric   unsigned getBaseMaxNumVGPRs(const Function &F,
1272fe6060f1SDimitry Andric                               std::pair<unsigned, unsigned> WavesPerEU) const;
1273fe6060f1SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1274fe6060f1SDimitry Andric   /// unit requirement for function \p F, or number of VGPRs explicitly
1275fe6060f1SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p F.
1276fe6060f1SDimitry Andric   ///
1277fe6060f1SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1278fe6060f1SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1279fe6060f1SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1280fe6060f1SDimitry Andric   /// unit requirement.
1281fe6060f1SDimitry Andric   unsigned getMaxNumVGPRs(const Function &F) const;
1282fe6060f1SDimitry Andric 
128381ad6265SDimitry Andric   unsigned getMaxNumAGPRs(const Function &F) const {
128481ad6265SDimitry Andric     return getMaxNumVGPRs(F);
128581ad6265SDimitry Andric   }
128681ad6265SDimitry Andric 
1287e8d8bef9SDimitry Andric   /// \returns Maximum number of VGPRs that meets number of waves per execution
1288e8d8bef9SDimitry Andric   /// unit requirement for function \p MF, or number of VGPRs explicitly
1289e8d8bef9SDimitry Andric   /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
1290e8d8bef9SDimitry Andric   ///
1291e8d8bef9SDimitry Andric   /// \returns Value that meets number of waves per execution unit requirement
1292e8d8bef9SDimitry Andric   /// if explicitly requested value cannot be converted to integer, violates
1293e8d8bef9SDimitry Andric   /// subtarget's specifications, or does not meet number of waves per execution
1294e8d8bef9SDimitry Andric   /// unit requirement.
1295e8d8bef9SDimitry Andric   unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
1296e8d8bef9SDimitry Andric 
1297e8d8bef9SDimitry Andric   void getPostRAMutations(
1298e8d8bef9SDimitry Andric       std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
1299e8d8bef9SDimitry Andric       const override;
1300e8d8bef9SDimitry Andric 
1301349cc55cSDimitry Andric   std::unique_ptr<ScheduleDAGMutation>
1302349cc55cSDimitry Andric   createFillMFMAShadowMutation(const TargetInstrInfo *TII) const;
1303349cc55cSDimitry Andric 
1304e8d8bef9SDimitry Andric   bool isWave32() const {
1305e8d8bef9SDimitry Andric     return getWavefrontSize() == 32;
1306e8d8bef9SDimitry Andric   }
1307e8d8bef9SDimitry Andric 
1308e8d8bef9SDimitry Andric   bool isWave64() const {
1309e8d8bef9SDimitry Andric     return getWavefrontSize() == 64;
1310e8d8bef9SDimitry Andric   }
1311e8d8bef9SDimitry Andric 
1312e8d8bef9SDimitry Andric   const TargetRegisterClass *getBoolRC() const {
1313e8d8bef9SDimitry Andric     return getRegisterInfo()->getBoolRC();
1314e8d8bef9SDimitry Andric   }
1315e8d8bef9SDimitry Andric 
1316e8d8bef9SDimitry Andric   /// \returns Maximum number of work groups per compute unit supported by the
1317e8d8bef9SDimitry Andric   /// subtarget and limited by given \p FlatWorkGroupSize.
1318e8d8bef9SDimitry Andric   unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1319e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1320e8d8bef9SDimitry Andric   }
1321e8d8bef9SDimitry Andric 
1322e8d8bef9SDimitry Andric   /// \returns Minimum flat work group size supported by the subtarget.
1323e8d8bef9SDimitry Andric   unsigned getMinFlatWorkGroupSize() const override {
1324e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1325e8d8bef9SDimitry Andric   }
1326e8d8bef9SDimitry Andric 
1327e8d8bef9SDimitry Andric   /// \returns Maximum flat work group size supported by the subtarget.
1328e8d8bef9SDimitry Andric   unsigned getMaxFlatWorkGroupSize() const override {
1329e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1330e8d8bef9SDimitry Andric   }
1331e8d8bef9SDimitry Andric 
1332e8d8bef9SDimitry Andric   /// \returns Number of waves per execution unit required to support the given
1333e8d8bef9SDimitry Andric   /// \p FlatWorkGroupSize.
1334e8d8bef9SDimitry Andric   unsigned
1335e8d8bef9SDimitry Andric   getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
1336e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(this, FlatWorkGroupSize);
1337e8d8bef9SDimitry Andric   }
1338e8d8bef9SDimitry Andric 
1339e8d8bef9SDimitry Andric   /// \returns Minimum number of waves per execution unit supported by the
1340e8d8bef9SDimitry Andric   /// subtarget.
1341e8d8bef9SDimitry Andric   unsigned getMinWavesPerEU() const override {
1342e8d8bef9SDimitry Andric     return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1343e8d8bef9SDimitry Andric   }
1344e8d8bef9SDimitry Andric 
1345e8d8bef9SDimitry Andric   void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
1346e8d8bef9SDimitry Andric                              SDep &Dep) const override;
134781ad6265SDimitry Andric 
134881ad6265SDimitry Andric   // \returns true if it's beneficial on this subtarget for the scheduler to
134981ad6265SDimitry Andric   // cluster stores as well as loads.
135081ad6265SDimitry Andric   bool shouldClusterStores() const { return getGeneration() >= GFX11; }
1351bdd1243dSDimitry Andric 
1352bdd1243dSDimitry Andric   // \returns the number of address arguments from which to enable MIMG NSA
1353bdd1243dSDimitry Andric   // on supported architectures.
1354bdd1243dSDimitry Andric   unsigned getNSAThreshold(const MachineFunction &MF) const;
1355*06c3fb27SDimitry Andric 
1356*06c3fb27SDimitry Andric   // \returns true if the subtarget has a hazard requiring an "s_nop 0"
1357*06c3fb27SDimitry Andric   // instruction before "s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)".
1358*06c3fb27SDimitry Andric   bool requiresNopBeforeDeallocVGPRs() const {
1359*06c3fb27SDimitry Andric     // Currently all targets that support the dealloc VGPRs message also require
1360*06c3fb27SDimitry Andric     // the nop.
1361*06c3fb27SDimitry Andric     return true;
1362*06c3fb27SDimitry Andric   }
1363e8d8bef9SDimitry Andric };
1364e8d8bef9SDimitry Andric 
1365e8d8bef9SDimitry Andric } // end namespace llvm
1366e8d8bef9SDimitry Andric 
1367e8d8bef9SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
1368