LLVM 22.0.0git
SIPeepholeSDWA.cpp File Reference
#include "SIPeepholeSDWA.h"
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include <optional>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "si-peephole-sdwa"

Functions

 STATISTIC (NumSDWAPatternsFound, "Number of SDWA patterns found.")
 STATISTIC (NumSDWAInstructionsPeepholed, "Number of instruction converted to SDWA.")
static raw_ostreamoperator<< (raw_ostream &OS, SdwaSel Sel)
static raw_ostreamoperator<< (raw_ostream &OS, const DstUnused &Un)
static void copyRegOperand (MachineOperand &To, const MachineOperand &From)
static bool isSameReg (const MachineOperand &LHS, const MachineOperand &RHS)
static MachineOperandfindSingleRegUse (const MachineOperand *Reg, const MachineRegisterInfo *MRI)
static MachineOperandfindSingleRegDef (const MachineOperand *Reg, const MachineRegisterInfo *MRI)
static std::optional< SdwaSelcombineSdwaSel (SdwaSel Sel, SdwaSel OperandSel)
 Combine an SDWA instruction's existing SDWA selection Sel with the SDWA selection OperandSel of its operand.
static bool canCombineOpSel (const MachineInstr &MI, const SIInstrInfo *TII, AMDGPU::OpName SrcSelOpName, SdwaSel OpSel)
 Verify that the SDWA selection operand SrcSelOpName of the SDWA instruction MI can be combined with the selection OpSel.
static bool canCombineOpSel (const MachineInstr &MI, const SIInstrInfo *TII, AMDGPU::OpName SrcOpName, AMDGPU::OpName SrcSelOpName, MachineOperand *Op, SdwaSel OpSel)
 Verify that Op is the same register as the operand of the SDWA instruction MI named by SrcOpName and that the SDWA selection SrcSelOpName can be combined with the OpSel.
static raw_ostreamoperator<< (raw_ostream &OS, const SDWAOperand &Operand)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "si-peephole-sdwa"

Definition at line 33 of file SIPeepholeSDWA.cpp.

Function Documentation

◆ canCombineOpSel() [1/2]

bool canCombineOpSel ( const MachineInstr & MI,
const SIInstrInfo * TII,
AMDGPU::OpName SrcOpName,
AMDGPU::OpName SrcSelOpName,
MachineOperand * Op,
SdwaSel OpSel )
static

Verify that Op is the same register as the operand of the SDWA instruction MI named by SrcOpName and that the SDWA selection SrcSelOpName can be combined with the OpSel.

Definition at line 515 of file SIPeepholeSDWA.cpp.

References assert(), canCombineOpSel(), isSameReg(), MI, and TII.

◆ canCombineOpSel() [2/2]

bool canCombineOpSel ( const MachineInstr & MI,
const SIInstrInfo * TII,
AMDGPU::OpName SrcSelOpName,
SdwaSel OpSel )
static

Verify that the SDWA selection operand SrcSelOpName of the SDWA instruction MI can be combined with the selection OpSel.

Definition at line 502 of file SIPeepholeSDWA.cpp.

References assert(), combineSdwaSel(), llvm::MachineOperand::getImm(), MI, and TII.

Referenced by canCombineOpSel().

◆ combineSdwaSel()

std::optional< SdwaSel > combineSdwaSel ( SdwaSel Sel,
SdwaSel OperandSel )
static

Combine an SDWA instruction's existing SDWA selection Sel with the SDWA selection OperandSel of its operand.

If the selections are compatible, return the combined selection, otherwise return a nullopt. For example, if we have Sel = BYTE_0 Sel and OperandSel = WORD_1: BYTE_0 Sel (WORD_1 Sel (X)) -> BYTE_2 Sel (X)

Definition at line 311 of file SIPeepholeSDWA.cpp.

Referenced by canCombineOpSel().

◆ copyRegOperand()

◆ findSingleRegDef()

MachineOperand * findSingleRegDef ( const MachineOperand * Reg,
const MachineRegisterInfo * MRI )
static

Definition at line 297 of file SIPeepholeSDWA.cpp.

References MRI, and Reg.

◆ findSingleRegUse()

MachineOperand * findSingleRegUse ( const MachineOperand * Reg,
const MachineRegisterInfo * MRI )
static

Definition at line 289 of file SIPeepholeSDWA.cpp.

References MRI, and Reg.

◆ isSameReg()

bool isSameReg ( const MachineOperand & LHS,
const MachineOperand & RHS )
static

Definition at line 282 of file SIPeepholeSDWA.cpp.

References LHS, and RHS.

Referenced by canCombineOpSel().

◆ operator<<() [1/3]

◆ operator<<() [2/3]

raw_ostream & operator<< ( raw_ostream & OS,
const SDWAOperand & Operand )
static

Definition at line 972 of file SIPeepholeSDWA.cpp.

◆ operator<<() [3/3]

◆ STATISTIC() [1/2]

STATISTIC ( NumSDWAInstructionsPeepholed ,
"Number of instruction converted to SDWA."  )

References MBB, MI, MRI, TII, and TRI.

◆ STATISTIC() [2/2]

STATISTIC ( NumSDWAPatternsFound ,
"Number of SDWA patterns found."  )