LLVM  8.0.1
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.

Macros

#define DEBUG_TYPE   "si-fold-operands"
 

Functions

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

◆ DEBUG_TYPE

#define DEBUG_TYPE   "si-fold-operands"

Definition at line 26 of file SIFoldOperands.cpp.

Function Documentation

◆ evalBinaryInstruction()

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

Definition at line 557 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp().

◆ getImmOrMaterializedImm()

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

◆ getMovOpc()

static unsigned getMovOpc ( bool  IsScalar)
static

Definition at line 608 of file SIFoldOperands.cpp.

Referenced by tryConstantFoldOp(), and tryFoldInst().

◆ getOModValue()

static int getOModValue ( unsigned  Opc,
int64_t  Val 
)
static

◆ hasOneNonDBGUseInst()

static bool hasOneNonDBGUseInst ( const MachineRegisterInfo MRI,
unsigned  Reg 
)
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 272 of file SIFoldOperands.cpp.

Referenced by tryAddToFoldList().

◆ isUseSafeToFold()

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

◆ mutateCopyOp()

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

Definition at line 625 of file SIFoldOperands.cpp.

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

Referenced by tryConstantFoldOp(), and tryFoldInst().

◆ 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 615 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 
)
static

◆ tryConstantFoldOp()

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

◆ tryFoldInst()

static bool tryFoldInst ( const SIInstrInfo TII,
MachineInstr MI 
)
static

◆ updateOperand()

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