LLVM 22.0.0git
SIInstrInfo.cpp File Reference

SI Implementation of TargetInstrInfo. More...

#include "SIInstrInfo.h"
#include "AMDGPU.h"
#include "AMDGPUInstrInfo.h"
#include "GCNHazardRecognizer.h"
#include "GCNSubtarget.h"
#include "SIMachineFunctionInfo.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/MC/MCContext.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetMachine.h"
#include "AMDGPUGenInstrInfo.inc"
#include "AMDGPUGenSearchableTables.inc"

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
namespace  llvm::AMDGPU

Macros

#define DEBUG_TYPE   "si-instr-info"
#define GET_INSTRINFO_CTOR_DTOR
#define GET_D16ImageDimIntrinsics_IMPL
#define GET_ImageDimIntrinsicTable_IMPL
#define GET_RsrcIntrinsics_IMPL
#define GENERATE_RENAMED_GFX9_CASES(OPCODE)

Functions

static unsigned getNumOperandsNoGlue (SDNode *Node)
static bool nodesHaveSameOperandValue (SDNode *N0, SDNode *N1, AMDGPU::OpName OpName)
 Returns true if both nodes have the same value for the given operand Op, or if both nodes do not have this operand.
static bool canRemat (const MachineInstr &MI)
static bool isStride64 (unsigned Opc)
static bool memOpsHaveSameBasePtr (const MachineInstr &MI1, ArrayRef< const MachineOperand * > BaseOps1, const MachineInstr &MI2, ArrayRef< const MachineOperand * > BaseOps2)
static void reportIllegalCopy (const SIInstrInfo *TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, const char *Msg="illegal VGPR to SGPR copy")
static void indirectCopyToAGPR (const SIInstrInfo &TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, RegScavenger &RS, bool RegsOverlap, Register ImpDefSuperReg=Register(), Register ImpUseSuperReg=Register())
 Handle copying from SGPR to AGPR, or from AGPR to AGPR on GFX908.
static void expandSGPRCopy (const SIInstrInfo &TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, const TargetRegisterClass *RC, bool Forward)
static unsigned getIndirectVGPRWriteMovRelPseudoOpc (unsigned VecSize)
static unsigned getIndirectSGPRWriteMovRelPseudo32 (unsigned VecSize)
static unsigned getIndirectSGPRWriteMovRelPseudo64 (unsigned VecSize)
static unsigned getSGPRSpillSaveOpcode (unsigned Size)
static unsigned getVGPRSpillSaveOpcode (unsigned Size)
static unsigned getAVSpillSaveOpcode (unsigned Size)
static unsigned getWWMRegSpillSaveOpcode (unsigned Size, bool IsVectorSuperClass)
static unsigned getSGPRSpillRestoreOpcode (unsigned Size)
static unsigned getVGPRSpillRestoreOpcode (unsigned Size)
static unsigned getAVSpillRestoreOpcode (unsigned Size)
static unsigned getWWMRegSpillRestoreOpcode (unsigned Size, bool IsVectorSuperClass)
static MachineInstrswapRegAndNonRegOperand (MachineInstr &MI, MachineOperand &RegOp, MachineOperand &NonRegOp)
static MachineInstrswapImmOperands (MachineInstr &MI, MachineOperand &NonRegOp1, MachineOperand &NonRegOp2)
static void preserveCondRegFlags (MachineOperand &CondReg, const MachineOperand &OrigCond)
static unsigned getNewFMAAKInst (const GCNSubtarget &ST, unsigned Opc)
static unsigned getNewFMAMKInst (const GCNSubtarget &ST, unsigned Opc)
static bool memOpsHaveSameBaseOperands (ArrayRef< const MachineOperand * > BaseOps1, ArrayRef< const MachineOperand * > BaseOps2)
static bool offsetsDoNotOverlap (LocationSize WidthA, int OffsetA, LocationSize WidthB, int OffsetB)
static bool getFoldableImm (Register Reg, const MachineRegisterInfo &MRI, int64_t &Imm, MachineInstr **DefMI=nullptr)
static bool getFoldableImm (const MachineOperand *MO, int64_t &Imm, MachineInstr **DefMI=nullptr)
static void updateLiveVariables (LiveVariables *LV, MachineInstr &MI, MachineInstr &NewMI)
static unsigned getNewFMAInst (const GCNSubtarget &ST, unsigned Opc)
static bool changesVGPRIndexingMode (const MachineInstr &MI)
static bool compareMachineOp (const MachineOperand &Op0, const MachineOperand &Op1)
static void copyFlagsToImplicitVCC (MachineInstr &MI, const MachineOperand &Orig)
static Register findImplicitSGPRRead (const MachineInstr &MI)
static bool shouldReadExec (const MachineInstr &MI)
static bool isRegOrFI (const MachineOperand &MO)
static bool isSubRegOf (const SIRegisterInfo &TRI, const MachineOperand &SuperVec, const MachineOperand &SubReg)
static const TargetRegisterClassadjustAllocatableRegClass (const GCNSubtarget &ST, const SIRegisterInfo &RI, const MCInstrDesc &TID, unsigned RCID)
static void emitLoadScalarOpsFromVGPRLoop (const SIInstrInfo &TII, MachineRegisterInfo &MRI, MachineBasicBlock &LoopBB, MachineBasicBlock &BodyBB, const DebugLoc &DL, ArrayRef< MachineOperand * > ScalarOps)
static MachineBasicBlockloadMBUFScalarOperandsFromVGPR (const SIInstrInfo &TII, MachineInstr &MI, ArrayRef< MachineOperand * > ScalarOps, MachineDominatorTree *MDT, MachineBasicBlock::iterator Begin=nullptr, MachineBasicBlock::iterator End=nullptr)
static std::tuple< unsigned, unsignedextractRsrcPtr (const SIInstrInfo &TII, MachineInstr &MI, MachineOperand &Rsrc)
static unsigned subtargetEncodingFamily (const GCNSubtarget &ST)
static bool isRenamedInGFX9 (int Opcode)
static TargetInstrInfo::RegSubRegPair getRegOrUndef (const MachineOperand &RegOpnd)
static bool followSubRegDef (MachineInstr &MI, TargetInstrInfo::RegSubRegPair &RSR)

Variables

static cl::opt< unsignedBranchOffsetBits ("amdgpu-s-branch-bits", cl::ReallyHidden, cl::init(16), cl::desc("Restrict range of branch instructions (DEBUG)"))
static cl::opt< boolFix16BitCopies ("amdgpu-fix-16-bit-physreg-copies", cl::desc("Fix copies between 32 and 16 bit registers by extending to 32 bit"), cl::init(true), cl::ReallyHidden)
static constexpr AMDGPU::OpName ModifierOpNames []

Detailed Description

SI Implementation of TargetInstrInfo.

Definition in file SIInstrInfo.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "si-instr-info"

Definition at line 39 of file SIInstrInfo.cpp.

◆ GENERATE_RENAMED_GFX9_CASES

#define GENERATE_RENAMED_GFX9_CASES ( OPCODE)
Value:
case OPCODE##_dpp: \
case OPCODE##_e32: \
case OPCODE##_e64: \
case OPCODE##_e64_dpp: \
case OPCODE##_sdwa:
#define OPCODE(NAME)

Definition at line 9913 of file SIInstrInfo.cpp.

Referenced by isRenamedInGFX9().

◆ GET_D16ImageDimIntrinsics_IMPL

#define GET_D16ImageDimIntrinsics_IMPL

Definition at line 45 of file SIInstrInfo.cpp.

◆ GET_ImageDimIntrinsicTable_IMPL

#define GET_ImageDimIntrinsicTable_IMPL

Definition at line 46 of file SIInstrInfo.cpp.

◆ GET_INSTRINFO_CTOR_DTOR

#define GET_INSTRINFO_CTOR_DTOR

Definition at line 41 of file SIInstrInfo.cpp.

◆ GET_RsrcIntrinsics_IMPL

#define GET_RsrcIntrinsics_IMPL

Definition at line 47 of file SIInstrInfo.cpp.

Function Documentation

◆ adjustAllocatableRegClass()

◆ canRemat()

◆ changesVGPRIndexingMode()

bool changesVGPRIndexingMode ( const MachineInstr & MI)
static

Definition at line 4284 of file SIInstrInfo.cpp.

References MI.

Referenced by llvm::SIInstrInfo::isSchedulingBoundary().

◆ compareMachineOp()

◆ copyFlagsToImplicitVCC()

void copyFlagsToImplicitVCC ( MachineInstr & MI,
const MachineOperand & Orig )
static

◆ emitLoadScalarOpsFromVGPRLoop()

◆ expandSGPRCopy()

◆ extractRsrcPtr()

◆ findImplicitSGPRRead()

Register findImplicitSGPRRead ( const MachineInstr & MI)
static

Definition at line 4824 of file SIInstrInfo.cpp.

References MI, and Register.

Referenced by llvm::SIInstrInfo::legalizeOperandsVOP2(), and llvm::SIInstrInfo::verifyInstruction().

◆ followSubRegDef()

◆ getAVSpillRestoreOpcode()

unsigned getAVSpillRestoreOpcode ( unsigned Size)
static

Definition at line 1823 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillRestoreOpcode().

◆ getAVSpillSaveOpcode()

unsigned getAVSpillSaveOpcode ( unsigned Size)
static

Definition at line 1631 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillSaveOpcode().

◆ getFoldableImm() [1/2]

◆ getFoldableImm() [2/2]

bool getFoldableImm ( Register Reg,
const MachineRegisterInfo & MRI,
int64_t & Imm,
MachineInstr ** DefMI = nullptr )
static

◆ getIndirectSGPRWriteMovRelPseudo32()

unsigned getIndirectSGPRWriteMovRelPseudo32 ( unsigned VecSize)
static

Definition at line 1497 of file SIInstrInfo.cpp.

References llvm_unreachable.

Referenced by llvm::SIInstrInfo::getIndirectRegWriteMovRelPseudo().

◆ getIndirectSGPRWriteMovRelPseudo64()

unsigned getIndirectSGPRWriteMovRelPseudo64 ( unsigned VecSize)
static

Definition at line 1526 of file SIInstrInfo.cpp.

References llvm_unreachable.

Referenced by llvm::SIInstrInfo::getIndirectRegWriteMovRelPseudo().

◆ getIndirectVGPRWriteMovRelPseudoOpc()

unsigned getIndirectVGPRWriteMovRelPseudoOpc ( unsigned VecSize)
static

Definition at line 1468 of file SIInstrInfo.cpp.

References llvm_unreachable.

Referenced by llvm::SIInstrInfo::getIndirectRegWriteMovRelPseudo().

◆ getNewFMAAKInst()

unsigned getNewFMAAKInst ( const GCNSubtarget & ST,
unsigned Opc )
static

◆ getNewFMAInst()

unsigned getNewFMAInst ( const GCNSubtarget & ST,
unsigned Opc )
static

Definition at line 4005 of file SIInstrInfo.cpp.

References llvm_unreachable, and Opc.

Referenced by llvm::SIInstrInfo::convertToThreeAddress().

◆ getNewFMAMKInst()

unsigned getNewFMAMKInst ( const GCNSubtarget & ST,
unsigned Opc )
static

◆ getNumOperandsNoGlue()

unsigned getNumOperandsNoGlue ( SDNode * Node)
static

Definition at line 74 of file SIInstrInfo.cpp.

References N.

Referenced by llvm::SIInstrInfo::areLoadsFromSameBasePtr().

◆ getRegOrUndef()

◆ getSGPRSpillRestoreOpcode()

unsigned getSGPRSpillRestoreOpcode ( unsigned Size)
static

Definition at line 1751 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::loadRegFromStackSlot().

◆ getSGPRSpillSaveOpcode()

unsigned getSGPRSpillSaveOpcode ( unsigned Size)
static

Definition at line 1559 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::storeRegToStackSlot().

◆ getVGPRSpillRestoreOpcode()

unsigned getVGPRSpillRestoreOpcode ( unsigned Size)
static

Definition at line 1786 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillRestoreOpcode().

◆ getVGPRSpillSaveOpcode()

unsigned getVGPRSpillSaveOpcode ( unsigned Size)
static

Definition at line 1594 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillSaveOpcode().

◆ getWWMRegSpillRestoreOpcode()

unsigned getWWMRegSpillRestoreOpcode ( unsigned Size,
bool IsVectorSuperClass )
static

Definition at line 1858 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillRestoreOpcode().

◆ getWWMRegSpillSaveOpcode()

unsigned getWWMRegSpillSaveOpcode ( unsigned Size,
bool IsVectorSuperClass )
static

Definition at line 1666 of file SIInstrInfo.cpp.

References llvm_unreachable, and Size.

Referenced by llvm::SIInstrInfo::getVectorRegSpillSaveOpcode().

◆ indirectCopyToAGPR()

◆ isRegOrFI()

bool isRegOrFI ( const MachineOperand & MO)
static

◆ isRenamedInGFX9()

bool isRenamedInGFX9 ( int Opcode)
static

Definition at line 9920 of file SIInstrInfo.cpp.

References GENERATE_RENAMED_GFX9_CASES.

Referenced by llvm::SIInstrInfo::pseudoToMCOpcode().

◆ isStride64()

bool isStride64 ( unsigned Opc)
static

Definition at line 351 of file SIInstrInfo.cpp.

References Opc.

Referenced by llvm::SIInstrInfo::getMemOperandsWithOffsetWidth().

◆ isSubRegOf()

bool isSubRegOf ( const SIRegisterInfo & TRI,
const MachineOperand & SuperVec,
const MachineOperand & SubReg )
static

Definition at line 4872 of file SIInstrInfo.cpp.

References llvm::MachineOperand::getReg(), SubReg, and TRI.

Referenced by llvm::SIInstrInfo::verifyInstruction().

◆ loadMBUFScalarOperandsFromVGPR()

◆ memOpsHaveSameBaseOperands()

bool memOpsHaveSameBaseOperands ( ArrayRef< const MachineOperand * > BaseOps1,
ArrayRef< const MachineOperand * > BaseOps2 )
static

Definition at line 3861 of file SIInstrInfo.cpp.

References E(), I, and llvm::ArrayRef< T >::size().

◆ memOpsHaveSameBasePtr()

◆ nodesHaveSameOperandValue()

bool nodesHaveSameOperandValue ( SDNode * N0,
SDNode * N1,
AMDGPU::OpName OpName )
static

Returns true if both nodes have the same value for the given operand Op, or if both nodes do not have this operand.

Definition at line 83 of file SIInstrInfo.cpp.

References llvm::SDNode::getMachineOpcode(), and llvm::SDNode::getOperand().

Referenced by llvm::SIInstrInfo::areLoadsFromSameBasePtr().

◆ offsetsDoNotOverlap()

bool offsetsDoNotOverlap ( LocationSize WidthA,
int OffsetA,
LocationSize WidthB,
int OffsetB )
static

◆ preserveCondRegFlags()

◆ reportIllegalCopy()

◆ shouldReadExec()

◆ subtargetEncodingFamily()

◆ swapImmOperands()

◆ swapRegAndNonRegOperand()

◆ updateLiveVariables()

void updateLiveVariables ( LiveVariables * LV,
MachineInstr & MI,
MachineInstr & NewMI )
static

Variable Documentation

◆ BranchOffsetBits

cl::opt< unsigned > BranchOffsetBits("amdgpu-s-branch-bits", cl::ReallyHidden, cl::init(16), cl::desc("Restrict range of branch instructions (DEBUG)")) ( "amdgpu-s-branch-bits" ,
cl::ReallyHidden ,
cl::init(16) ,
cl::desc("Restrict range of branch instructions (DEBUG)")  )
static

◆ Fix16BitCopies

cl::opt< bool > Fix16BitCopies("amdgpu-fix-16-bit-physreg-copies", cl::desc("Fix copies between 32 and 16 bit registers by extending to 32 bit"), cl::init(true), cl::ReallyHidden) ( "amdgpu-fix-16-bit-physreg-copies" ,
cl::desc("Fix copies between 32 and 16 bit registers by extending to 32 bit") ,
cl::init(true) ,
cl::ReallyHidden  )
static

◆ ModifierOpNames

AMDGPU::OpName ModifierOpNames[]
staticconstexpr
Initial value:
= {
AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src1_modifiers,
AMDGPU::OpName::src2_modifiers, AMDGPU::OpName::clamp,
AMDGPU::OpName::omod, AMDGPU::OpName::op_sel}

Definition at line 3453 of file SIInstrInfo.cpp.

Referenced by llvm::SIInstrInfo::hasAnyModifiersSet(), and llvm::SIInstrInfo::removeModOperands().