LLVM  9.0.0svn
Macros | Functions
SIFoldOperands.cpp File Reference
#include "AMDGPU.h"
#include "AMDGPUSubtarget.h"
#include "SIInstrInfo.h"
#include "SIMachineFunctionInfo.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
Include dependency graph for SIFoldOperands.cpp:

Go to the source code of this file.


#define DEBUG_TYPE   "si-fold-operands"


static bool isInlineConstantIfFolded (const SIInstrInfo *TII, const MachineInstr &UseMI, unsigned OpNo, const MachineOperand &OpToFold)
static bool updateOperand (FoldCandidate &Fold, const SIInstrInfo &TII, const TargetRegisterInfo &TRI)
static bool isUseMIInFoldList (ArrayRef< FoldCandidate > FoldList, const MachineInstr *MI)
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 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, MachineOperand *ImmOp)
static bool tryFoldInst (const SIInstrInfo *TII, MachineInstr *MI)
static bool hasOneNonDBGUseInst (const MachineRegisterInfo &MRI, unsigned Reg)
static int getOModValue (unsigned Opc, int64_t Val)

Macro Definition Documentation


#define DEBUG_TYPE   "si-fold-operands"

Definition at line 25 of file SIFoldOperands.cpp.

Function Documentation

◆ evalBinaryInstruction()

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

Definition at line 547 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp().

◆ getImmOrMaterializedImm()

static MachineOperand* getImmOrMaterializedImm ( MachineRegisterInfo MRI,
MachineOperand Op 

◆ getMovOpc()

static unsigned getMovOpc ( bool  IsScalar)

Definition at line 598 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp(), and tryFoldInst().

◆ getOModValue()

static int getOModValue ( unsigned  Opc,
int64_t  Val 

◆ hasOneNonDBGUseInst()

static bool hasOneNonDBGUseInst ( const MachineRegisterInfo MRI,
unsigned  Reg 

◆ isInlineConstantIfFolded()

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

◆ isUseMIInFoldList()

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

Definition at line 265 of file SIFoldOperands.cpp.

Referenced by tryAddToFoldList().

◆ isUseSafeToFold()

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

◆ mutateCopyOp()

static void mutateCopyOp ( MachineInstr MI,
const MCInstrDesc NewDesc 

Definition at line 615 of file SIFoldOperands.cpp.

References llvm::MachineInstr::setDesc(), and stripExtraCopyOperands().

Referenced by tryConstantFoldOp(), and tryFoldInst().

◆ stripExtraCopyOperands()

static void stripExtraCopyOperands ( MachineInstr MI)

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 605 of file SIFoldOperands.cpp.

References llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getNumImplicitDefs(), llvm::MCInstrDesc::getNumImplicitUses(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getNumOperands(), I, and llvm::MachineInstr::RemoveOperand().

Referenced by mutateCopyOp(), and tryConstantFoldOp().

◆ tryAddToFoldList()

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

◆ tryConstantFoldOp()

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

◆ tryFoldInst()

static bool tryFoldInst ( const SIInstrInfo TII,
MachineInstr MI 

◆ updateOperand()

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