LLVM  14.0.0git
Macros | Functions
SIFoldOperands.cpp File Reference
#include "AMDGPU.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIMachineFunctionInfo.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
Include dependency graph for SIFoldOperands.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "si-fold-operands"
 

Functions

static unsigned macToMad (unsigned Opc)
 
static bool isInlineConstantIfFolded (const SIInstrInfo *TII, const MachineInstr &UseMI, unsigned OpNo, const MachineOperand &OpToFold)
 
static bool frameIndexMayFold (const SIInstrInfo *TII, const MachineInstr &UseMI, int OpNo, const MachineOperand &OpToFold)
 
static bool updateOperand (FoldCandidate &Fold, const SIInstrInfo &TII, const TargetRegisterInfo &TRI, const GCNSubtarget &ST)
 
static bool isUseMIInFoldList (ArrayRef< FoldCandidate > FoldList, const MachineInstr *MI)
 
static void appendFoldCandidate (SmallVectorImpl< FoldCandidate > &FoldList, MachineInstr *MI, unsigned OpNo, MachineOperand *FoldOp, bool Commuted=false, int ShrinkOp=-1)
 
static bool tryAddToFoldList (SmallVectorImpl< FoldCandidate > &FoldList, MachineInstr *MI, unsigned OpNo, MachineOperand *OpToFold, const SIInstrInfo *TII)
 
static bool isUseSafeToFold (const SIInstrInfo *TII, const MachineInstr &MI, const MachineOperand &UseMO)
 
static bool getRegSeqInit (SmallVectorImpl< std::pair< MachineOperand *, unsigned >> &Defs, Register UseReg, uint8_t OpTy, const SIInstrInfo *TII, const MachineRegisterInfo &MRI)
 
static bool tryToFoldACImm (const SIInstrInfo *TII, const MachineOperand &OpToFold, MachineInstr *UseMI, unsigned UseOpIdx, SmallVectorImpl< FoldCandidate > &FoldList)
 
static bool evalBinaryInstruction (unsigned Opcode, int32_t &Result, uint32_t LHS, uint32_t RHS)
 
static unsigned getMovOpc (bool IsScalar)
 
static void stripExtraCopyOperands (MachineInstr &MI)
 Remove any leftover implicit operands from mutating the instruction. More...
 
static void mutateCopyOp (MachineInstr &MI, const MCInstrDesc &NewDesc)
 
static MachineOperandgetImmOrMaterializedImm (MachineRegisterInfo &MRI, MachineOperand &Op)
 
static bool tryConstantFoldOp (MachineRegisterInfo &MRI, const SIInstrInfo *TII, MachineInstr *MI)
 
static int getOModValue (unsigned Opc, int64_t Val)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "si-fold-operands"

Definition at line 18 of file SIFoldOperands.cpp.

Function Documentation

◆ appendFoldCandidate()

static void appendFoldCandidate ( SmallVectorImpl< FoldCandidate > &  FoldList,
MachineInstr MI,
unsigned  OpNo,
MachineOperand FoldOp,
bool  Commuted = false,
int  ShrinkOp = -1 
)
static

Definition at line 333 of file SIFoldOperands.cpp.

References llvm::dbgs(), LLVM_DEBUG, and MI.

Referenced by tryAddToFoldList(), and tryToFoldACImm().

◆ evalBinaryInstruction()

static bool evalBinaryInstruction ( unsigned  Opcode,
int32_t &  Result,
uint32_t  LHS,
uint32_t  RHS 
)
static

Definition at line 941 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp().

◆ frameIndexMayFold()

static bool frameIndexMayFold ( const SIInstrInfo TII,
const MachineInstr UseMI,
int  OpNo,
const MachineOperand OpToFold 
)
static

◆ getImmOrMaterializedImm()

static MachineOperand* getImmOrMaterializedImm ( MachineRegisterInfo MRI,
MachineOperand Op 
)
static

◆ getMovOpc()

static unsigned getMovOpc ( bool  IsScalar)
static

Definition at line 1007 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp().

◆ getOModValue()

static int getOModValue ( unsigned  Opc,
int64_t  Val 
)
static

◆ getRegSeqInit()

static bool getRegSeqInit ( SmallVectorImpl< std::pair< MachineOperand *, unsigned >> &  Defs,
Register  UseReg,
uint8_t  OpTy,
const SIInstrInfo TII,
const MachineRegisterInfo MRI 
)
static

◆ isInlineConstantIfFolded()

static bool isInlineConstantIfFolded ( const SIInstrInfo TII,
const MachineInstr UseMI,
unsigned  OpNo,
const MachineOperand OpToFold 
)
static

◆ isUseMIInFoldList()

static bool isUseMIInFoldList ( ArrayRef< FoldCandidate >  FoldList,
const MachineInstr MI 
)
static

Definition at line 324 of file SIFoldOperands.cpp.

References MI.

Referenced by tryAddToFoldList(), and tryToFoldACImm().

◆ isUseSafeToFold()

static bool isUseSafeToFold ( const SIInstrInfo TII,
const MachineInstr MI,
const MachineOperand UseMO 
)
static

Definition at line 476 of file SIFoldOperands.cpp.

References llvm::MachineOperand::isUndef(), llvm::M0(), MI, and TII.

◆ macToMad()

static unsigned macToMad ( unsigned  Opc)
static

Definition at line 131 of file SIFoldOperands.cpp.

Referenced by isInlineConstantIfFolded(), and tryAddToFoldList().

◆ mutateCopyOp()

static void mutateCopyOp ( MachineInstr MI,
const MCInstrDesc NewDesc 
)
static

Definition at line 1024 of file SIFoldOperands.cpp.

References MI, and stripExtraCopyOperands().

Referenced by tryConstantFoldOp().

◆ stripExtraCopyOperands()

static void stripExtraCopyOperands ( MachineInstr MI)
static

Remove any leftover implicit operands from mutating the instruction.

e.g. if we replace an s_and_b32 with a copy, we don't need the implicit scc def anymore.

Definition at line 1014 of file SIFoldOperands.cpp.

References llvm::MCInstrDesc::getNumImplicitDefs(), llvm::MCInstrDesc::getNumImplicitUses(), llvm::MCInstrDesc::getNumOperands(), I, and MI.

Referenced by mutateCopyOp(), and tryConstantFoldOp().

◆ tryAddToFoldList()

static bool tryAddToFoldList ( SmallVectorImpl< FoldCandidate > &  FoldList,
MachineInstr MI,
unsigned  OpNo,
MachineOperand OpToFold,
const SIInstrInfo TII 
)
static

◆ tryConstantFoldOp()

static bool tryConstantFoldOp ( MachineRegisterInfo MRI,
const SIInstrInfo TII,
MachineInstr MI 
)
static

◆ tryToFoldACImm()

static bool tryToFoldACImm ( const SIInstrInfo TII,
const MachineOperand OpToFold,
MachineInstr UseMI,
unsigned  UseOpIdx,
SmallVectorImpl< FoldCandidate > &  FoldList 
)
static

◆ updateOperand()

static bool updateOperand ( FoldCandidate &  Fold,
const SIInstrInfo TII,
const TargetRegisterInfo TRI,
const GCNSubtarget ST 
)
static