LLVM 24.0.0git
GCNVOPDUtils.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "gcn-vopd-utils"

Functions

static const TargetRegisterClassgetVOPDSrcRegClass (const SIInstrInfo &TII, int VOPDOpc, unsigned CompIdx, unsigned SrcIdx)
static bool isValidVOPDSrc (const SIInstrInfo &TII, int VOPDOpc, unsigned CompIdx, unsigned SrcIdx, Register PhysSrcReg)
static const MachineOperandgetNamedOp (const MachineInstr &MI, AMDGPU::OpName Name)
static bool canMapVOP3PToVOPD (const MachineInstr &MI)
static bool canMaterializeVOPDLiterals (const MachineFunction &MF)
static bool checkVOPDRegConstraints (const SIInstrInfo &TII, const MachineInstr &MIX, const MachineInstr &MIY, bool IsVOPD3, bool AllowSameVGPR, SmallVectorImpl< VOPDLiteralFixup > &LiteralFixups)
static std::optional< VOPDMatchInfotryMatchVOPDPairVariant (const SIInstrInfo &TII, unsigned EncodingFamily, MachineInstr &FirstMI, MachineInstr &SecondMI, bool IsVOPD3)
 Core pair-eligibility check for a single VOPD encoding variant (VOPD or VOPD3).
static bool shouldScheduleVOPDAdjacent (const TargetInstrInfo &TII, const TargetSubtargetInfo &TSI, const MachineInstr *FirstMI, const MachineInstr &SecondMI, const SDep *)
 Check if the instr pair, FirstMI and SecondMI, should be scheduled together.
static void collectLoads (SmallPtrSet< SUnit *, 8 > &Loads, BitVector &Visited, SUnit &Head, bool Forward, bool StopAtLoads)
 Collect all load (dependents if Forward else dependencies) that connect to the Head SU.
static bool loadsMayOverlap (SUnit &I, const SmallPtrSet< SUnit *, 8 > &ILoadSuccs, SUnit &J, BitVector &LoadPredsComputed, SmallVector< SmallPtrSet< SUnit *, 8 > > &LoadPredsCache, BitVector &Scratch)
 Checks whether fusing SU I with SU J would force the loads preceding J to complete before loads depending on I.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "gcn-vopd-utils"

Definition at line 34 of file GCNVOPDUtils.cpp.

Function Documentation

◆ canMapVOP3PToVOPD()

bool canMapVOP3PToVOPD ( const MachineInstr & MI)
static

◆ canMaterializeVOPDLiterals()

◆ checkVOPDRegConstraints()

◆ collectLoads()

void collectLoads ( SmallPtrSet< SUnit *, 8 > & Loads,
BitVector & Visited,
SUnit & Head,
bool Forward,
bool StopAtLoads )
static

Collect all load (dependents if Forward else dependencies) that connect to the Head SU.

Visited should allocate enough bits for the number of SUnits, but its value can otherwise be uninitialized.

Definition at line 398 of file GCNVOPDUtils.cpp.

References llvm::SDep::Data, llvm::SUnit::getInstr(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SUnit::isBoundaryNode(), llvm::SUnit::isInstr(), llvm::MachineInstr::mayLoad(), llvm::SUnit::NodeNum, llvm::SUnit::Preds, llvm::BitVector::reset(), llvm::BitVector::set(), llvm::SUnit::Succs, and llvm::BitVector::test().

Referenced by loadsMayOverlap().

◆ getNamedOp()

const MachineOperand & getNamedOp ( const MachineInstr & MI,
AMDGPU::OpName Name )
static

Definition at line 76 of file GCNVOPDUtils.cpp.

References MI.

Referenced by canMapVOP3PToVOPD().

◆ getVOPDSrcRegClass()

const TargetRegisterClass * getVOPDSrcRegClass ( const SIInstrInfo & TII,
int VOPDOpc,
unsigned CompIdx,
unsigned SrcIdx )
static

Definition at line 39 of file GCNVOPDUtils.cpp.

References assert(), llvm_unreachable, and TII.

Referenced by checkVOPDRegConstraints(), and isValidVOPDSrc().

◆ isValidVOPDSrc()

bool isValidVOPDSrc ( const SIInstrInfo & TII,
int VOPDOpc,
unsigned CompIdx,
unsigned SrcIdx,
Register PhysSrcReg )
static

Definition at line 69 of file GCNVOPDUtils.cpp.

References llvm::MCRegisterClass::contains(), getVOPDSrcRegClass(), and TII.

Referenced by checkVOPDRegConstraints().

◆ loadsMayOverlap()

bool loadsMayOverlap ( SUnit & I,
const SmallPtrSet< SUnit *, 8 > & ILoadSuccs,
SUnit & J,
BitVector & LoadPredsComputed,
SmallVector< SmallPtrSet< SUnit *, 8 > > & LoadPredsCache,
BitVector & Scratch )
static

Checks whether fusing SU I with SU J would force the loads preceding J to complete before loads depending on I.

ILoadSuccs should hold all first load successors of I (via collectLoads with StopAtLoads=true). For set bits in LoadPredsComputed, the corresponding set in LoadPredsCache should hold all transitive load dependencies (via collectLoads with StopAtLoads=false). The Scratch bitvector should allocate enough bits for the number of SUnits.

Definition at line 436 of file GCNVOPDUtils.cpp.

References collectLoads(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::dbgs(), llvm::SmallPtrSetImplBase::empty(), I, LLVM_DEBUG, llvm::SUnit::NodeNum, llvm::BitVector::set(), and llvm::BitVector::test().

◆ shouldScheduleVOPDAdjacent()

bool shouldScheduleVOPDAdjacent ( const TargetInstrInfo & TII,
const TargetSubtargetInfo & TSI,
const MachineInstr * FirstMI,
const MachineInstr & SecondMI,
const SDep *  )
static

Check if the instr pair, FirstMI and SecondMI, should be scheduled together.

Given SecondMI, when FirstMI is unspecified, then check if SecondMI may be part of a fused pair at all.

Definition at line 358 of file GCNVOPDUtils.cpp.

References assert(), llvm::AMDGPU::getCanBeVOPD(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getParent(), llvm::SIInstrInfo::getSubtarget(), llvm::AMDGPU::getVOPDEncodingFamily(), TII, llvm::tryMatchVOPDPair(), llvm::AMDGPU::CanBeVOPD::X, and llvm::AMDGPU::CanBeVOPD::Y.

Referenced by llvm::createVOPDPairingMutation().

◆ tryMatchVOPDPairVariant()

std::optional< VOPDMatchInfo > tryMatchVOPDPairVariant ( const SIInstrInfo & TII,
unsigned EncodingFamily,
MachineInstr & FirstMI,
MachineInstr & SecondMI,
bool IsVOPD3 )
static

Core pair-eligibility check for a single VOPD encoding variant (VOPD or VOPD3).

Returns the X/Y assignment on success, or std::nullopt otherwise.

Definition at line 293 of file GCNVOPDUtils.cpp.

References checkVOPDRegConstraints(), llvm::AMDGPU::getCanBeVOPD(), llvm::MachineInstr::getOpcode(), Opc, TII, llvm::AMDGPU::CanBeVOPD::X, and llvm::AMDGPU::CanBeVOPD::Y.

Referenced by llvm::tryMatchVOPDPair().