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