LLVM 22.0.0git
llvm::MipsInstrInfo Class Referenceabstract

#include "Target/Mips/MipsInstrInfo.h"

Inheritance diagram for llvm::MipsInstrInfo:
[legend]

Public Types

enum  BranchType {
  BT_None , BT_NoBranch , BT_Uncond , BT_Cond ,
  BT_CondUncond , BT_Indirect
}

Public Member Functions

 MipsInstrInfo (const MipsSubtarget &STI, unsigned UncondBrOpc)
MCInst getNop () const override
bool analyzeBranch (MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
 Branch Analysis.
unsigned removeBranch (MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
unsigned insertBranch (MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
bool reverseBranchCondition (SmallVectorImpl< MachineOperand > &Cond) const override
 reverseBranchCondition - Return the inverse opcode of the specified Branch instruction.
BranchType analyzeBranch (MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify, SmallVectorImpl< MachineInstr * > &BranchInstrs) const
unsigned getEquivalentCompactForm (const MachineBasicBlock::iterator I) const
 Determine the opcode of a non-delay slot form for a branch if one exists.
bool isBranchOffsetInRange (unsigned BranchOpc, int64_t BrOffset) const override
 Determine if the branch target is in range.
bool SafeAfterMflo (const MachineInstr &MI) const
bool SafeInForbiddenSlot (const MachineInstr &MI) const
 Predicate to determine if an instruction can go in a forbidden slot.
bool SafeInFPUDelaySlot (const MachineInstr &MIInSlot, const MachineInstr &FPUMI) const
 Predicate to determine if an instruction can go in an FPU delay slot.
bool SafeInLoadDelaySlot (const MachineInstr &MIInSlot, const MachineInstr &LoadMI) const
 Predicate to determine if an instruction can go in a load delay slot.
bool IsMfloOrMfhi (const MachineInstr &MI) const
bool HasForbiddenSlot (const MachineInstr &MI) const
 Predicate to determine if an instruction has a forbidden slot.
bool HasFPUDelaySlot (const MachineInstr &MI) const
 Predicate to determine if an instruction has an FPU delay slot.
bool HasLoadDelaySlot (const MachineInstr &MI) const
 Predicate to determine if an instruction has a load delay slot.
bool isAsCheapAsAMove (const MachineInstr &MI) const override
void insertNoop (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
 Insert nop instruction when hazard condition is found.
MachineInstrBuilder insertNop (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, DebugLoc DL) const
 Insert an ISA appropriate nop.
virtual const MipsRegisterInfogetRegisterInfo () const =0
 getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
virtual unsigned getOppositeBranchOpc (unsigned Opc) const =0
virtual bool isBranchWithImm (unsigned Opc) const
unsigned getInstSizeInBytes (const MachineInstr &MI) const override
 Return the number of bytes of code the specified instruction may be.
void storeRegToStackSlot (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void loadRegFromStackSlot (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
virtual void storeRegToStack (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const =0
virtual void loadRegFromStack (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, int64_t Offset, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const =0
virtual void adjustStackPtr (unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const =0
MachineInstrBuilder genInstrWithNewOpc (unsigned NewOpc, MachineBasicBlock::iterator I) const
 Create an instruction which has the same operands and memory operands as MI but has a new opcode.
bool findCommutedOpIndices (const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
bool verifyInstruction (const MachineInstr &MI, StringRef &ErrInfo) const override
 Perform target specific instruction verification.
std::pair< unsigned, unsigneddecomposeMachineOperandsTargetFlags (unsigned TF) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags () const override
std::optional< RegImmPairisAddImmediate (const MachineInstr &MI, Register Reg) const override
std::optional< ParamLoadedValuedescribeLoadedValue (const MachineInstr &MI, Register Reg) const override

Static Public Member Functions

static const MipsInstrInfocreate (MipsSubtarget &STI)

Protected Member Functions

bool isZeroImm (const MachineOperand &op) const
MachineMemOperandGetMemOperand (MachineBasicBlock &MBB, int FI, MachineMemOperand::Flags Flags) const

Protected Attributes

const MipsSubtargetSubtarget
unsigned UncondBrOpc

Detailed Description

Definition at line 41 of file MipsInstrInfo.h.

Member Enumeration Documentation

◆ BranchType

Enumerator
BT_None 
BT_NoBranch 
BT_Uncond 
BT_Cond 
BT_CondUncond 
BT_Indirect 

Definition at line 49 of file MipsInstrInfo.h.

Constructor & Destructor Documentation

◆ MipsInstrInfo()

MipsInstrInfo::MipsInstrInfo ( const MipsSubtarget & STI,
unsigned UncondBrOpc )
explicit

Member Function Documentation

◆ adjustStackPtr()

virtual void llvm::MipsInstrInfo::adjustStackPtr ( unsigned SP,
int64_t Amount,
MachineBasicBlock & MBB,
MachineBasicBlock::iterator I ) const
pure virtual

Implemented in llvm::Mips16InstrInfo, and llvm::MipsSEInstrInfo.

References Cond, DL, I, MBB, MI, op, Opc, Reg, and TBB.

◆ analyzeBranch() [1/2]

bool MipsInstrInfo::analyzeBranch ( MachineBasicBlock & MBB,
MachineBasicBlock *& TBB,
MachineBasicBlock *& FBB,
SmallVectorImpl< MachineOperand > & Cond,
bool AllowModify ) const
override

Branch Analysis.

Definition at line 117 of file MipsInstrInfo.cpp.

References analyzeBranch(), BT_Indirect, BT_None, Cond, MBB, and TBB.

Referenced by analyzeBranch().

◆ analyzeBranch() [2/2]

◆ create()

◆ decomposeMachineOperandsTargetFlags()

std::pair< unsigned, unsigned > MipsInstrInfo::decomposeMachineOperandsTargetFlags ( unsigned TF) const
override

Definition at line 938 of file MipsInstrInfo.cpp.

◆ describeLoadedValue()

◆ findCommutedOpIndices()

bool MipsInstrInfo::findCommutedOpIndices ( const MachineInstr & MI,
unsigned & SrcOpIdx1,
unsigned & SrcOpIdx2 ) const
override

Definition at line 810 of file MipsInstrInfo.cpp.

References assert(), llvm::TargetInstrInfo::findCommutedOpIndices(), and MI.

◆ genInstrWithNewOpc()

◆ getEquivalentCompactForm()

unsigned MipsInstrInfo::getEquivalentCompactForm ( const MachineBasicBlock::iterator I) const

Determine the opcode of a non-delay slot form for a branch if one exists.

Return the corresponding compact (no delay slot) form of a branch.

Definition at line 461 of file MipsInstrInfo.cpp.

References I, and Subtarget.

◆ getInstSizeInBytes()

unsigned MipsInstrInfo::getInstSizeInBytes ( const MachineInstr & MI) const
override

Return the number of bytes of code the specified instruction may be.

Definition at line 706 of file MipsInstrInfo.cpp.

References llvm::TargetMachine::getMCAsmInfo(), llvm::MachineFunction::getTarget(), and MI.

◆ GetMemOperand()

◆ getNop()

MCInst MipsInstrInfo::getNop ( ) const
override

◆ getOppositeBranchOpc()

virtual unsigned llvm::MipsInstrInfo::getOppositeBranchOpc ( unsigned Opc) const
pure virtual

Implemented in llvm::Mips16InstrInfo, and llvm::MipsSEInstrInfo.

References Opc.

Referenced by reverseBranchCondition().

◆ getRegisterInfo()

virtual const MipsRegisterInfo & llvm::MipsInstrInfo::getRegisterInfo ( ) const
pure virtual

getRegisterInfo - TargetInstrInfo is a superset of MRegister info.

As such, whenever a client has an instance of instruction info, it should always be able to get register info as well (through this method).

Implemented in llvm::Mips16InstrInfo, and llvm::MipsSEInstrInfo.

◆ getSerializableDirectMachineOperandTargetFlags()

ArrayRef< std::pair< unsigned, const char * > > MipsInstrInfo::getSerializableDirectMachineOperandTargetFlags ( ) const
override

Definition at line 943 of file MipsInstrInfo.cpp.

References llvm::ArrayRef().

◆ HasForbiddenSlot()

bool MipsInstrInfo::HasForbiddenSlot ( const MachineInstr & MI) const

Predicate to determine if an instruction has a forbidden slot.

Predicate for distingushing instructions that have forbidden slots.

Definition at line 650 of file MipsInstrInfo.cpp.

References llvm::MipsII::HasForbiddenSlot, and MI.

◆ HasFPUDelaySlot()

bool MipsInstrInfo::HasFPUDelaySlot ( const MachineInstr & MI) const

Predicate to determine if an instruction has an FPU delay slot.

Predicate for distingushing instructions that have FPU delay slots.

Definition at line 655 of file MipsInstrInfo.cpp.

References MI.

Referenced by SafeInFPUDelaySlot().

◆ HasLoadDelaySlot()

bool MipsInstrInfo::HasLoadDelaySlot ( const MachineInstr & MI) const

Predicate to determine if an instruction has a load delay slot.

Predicate for distingushing instructions that have load delay slots.

Definition at line 674 of file MipsInstrInfo.cpp.

References MI.

◆ insertBranch()

unsigned MipsInstrInfo::insertBranch ( MachineBasicBlock & MBB,
MachineBasicBlock * TBB,
MachineBasicBlock * FBB,
ArrayRef< MachineOperand > Cond,
const DebugLoc & DL,
int * BytesAdded = nullptr ) const
override

◆ insertNoop()

void MipsInstrInfo::insertNoop ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MI ) const
override

Insert nop instruction when hazard condition is found.

insertNoop - If data hazard condition is found insert the target nop instruction.

Definition at line 66 of file MipsInstrInfo.cpp.

References llvm::BuildMI(), DL, llvm::get(), MBB, and MI.

◆ insertNop()

MachineInstrBuilder MipsInstrInfo::insertNop ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MI,
DebugLoc DL ) const

Insert an ISA appropriate nop.

Definition at line 73 of file MipsInstrInfo.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addReg(), assert(), llvm::BuildMI(), DL, llvm::get(), MBB, MI, Opc, and Subtarget.

◆ isAddImmediate()

std::optional< RegImmPair > MipsInstrInfo::isAddImmediate ( const MachineInstr & MI,
Register Reg ) const
override

◆ isAsCheapAsAMove()

bool MipsInstrInfo::isAsCheapAsAMove ( const MachineInstr & MI) const
override

Definition at line 689 of file MipsInstrInfo.cpp.

References MI.

◆ isBranchOffsetInRange()

bool MipsInstrInfo::isBranchOffsetInRange ( unsigned BranchOpc,
int64_t BrOffset ) const
override

Determine if the branch target is in range.

Definition at line 301 of file MipsInstrInfo.cpp.

References llvm::isInt(), and llvm_unreachable.

◆ isBranchWithImm()

virtual bool llvm::MipsInstrInfo::isBranchWithImm ( unsigned Opc) const
inlinevirtual

Reimplemented in llvm::MipsSEInstrInfo.

Definition at line 137 of file MipsInstrInfo.h.

References Opc.

◆ IsMfloOrMfhi()

bool MipsInstrInfo::IsMfloOrMfhi ( const MachineInstr & MI) const

Definition at line 642 of file MipsInstrInfo.cpp.

References IsMFLOMFHI, and MI.

◆ isZeroImm()

bool MipsInstrInfo::isZeroImm ( const MachineOperand & op) const
protected

◆ loadRegFromStack()

virtual void llvm::MipsInstrInfo::loadRegFromStack ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MI,
Register DestReg,
int FrameIndex,
const TargetRegisterClass * RC,
const TargetRegisterInfo * TRI,
int64_t Offset,
MachineInstr::MIFlag Flags = MachineInstr::NoFlags ) const
pure virtual

◆ loadRegFromStackSlot()

void llvm::MipsInstrInfo::loadRegFromStackSlot ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MBBI,
Register DestReg,
int FrameIndex,
const TargetRegisterClass * RC,
const TargetRegisterInfo * TRI,
Register VReg,
MachineInstr::MIFlag Flags = MachineInstr::NoFlags ) const
inlineoverride

Definition at line 152 of file MipsInstrInfo.h.

References loadRegFromStack(), MBB, MBBI, llvm::MachineInstr::NoFlags, and TRI.

◆ removeBranch()

unsigned MipsInstrInfo::removeBranch ( MachineBasicBlock & MBB,
int * BytesRemoved = nullptr ) const
override

Definition at line 177 of file MipsInstrInfo.cpp.

References assert(), I, and MBB.

◆ reverseBranchCondition()

bool MipsInstrInfo::reverseBranchCondition ( SmallVectorImpl< MachineOperand > & Cond) const
override

reverseBranchCondition - Return the inverse opcode of the specified Branch instruction.

Definition at line 205 of file MipsInstrInfo.cpp.

References assert(), Cond, llvm::getImm(), and getOppositeBranchOpc().

◆ SafeAfterMflo()

bool MipsInstrInfo::SafeAfterMflo ( const MachineInstr & MI) const

Definition at line 583 of file MipsInstrInfo.cpp.

References IsDIVMULT, and MI.

◆ SafeInForbiddenSlot()

bool MipsInstrInfo::SafeInForbiddenSlot ( const MachineInstr & MI) const

Predicate to determine if an instruction can go in a forbidden slot.

Predicate for distingushing between control transfer instructions and all other instructions for handling forbidden slots.

Consider inline assembly as unsafe as well.

Definition at line 593 of file MipsInstrInfo.cpp.

References llvm::MipsII::IsCTI, and MI.

◆ SafeInFPUDelaySlot()

bool MipsInstrInfo::SafeInFPUDelaySlot ( const MachineInstr & MIInSlot,
const MachineInstr & FPUMI ) const

◆ SafeInLoadDelaySlot()

bool MipsInstrInfo::SafeInLoadDelaySlot ( const MachineInstr & MIInSlot,
const MachineInstr & LoadMI ) const

Predicate to determine if an instruction can go in a load delay slot.

Predicate for distinguishing instructions that are hazardous in a load delay slot.

Consider inline assembly as unsafe as well.

Definition at line 632 of file MipsInstrInfo.cpp.

References llvm::any_of(), llvm::MachineInstr::defs(), and llvm::MachineInstr::isInlineAsm().

◆ storeRegToStack()

virtual void llvm::MipsInstrInfo::storeRegToStack ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MI,
Register SrcReg,
bool isKill,
int FrameIndex,
const TargetRegisterClass * RC,
const TargetRegisterInfo * TRI,
int64_t Offset,
MachineInstr::MIFlag Flags = MachineInstr::NoFlags ) const
pure virtual

◆ storeRegToStackSlot()

void llvm::MipsInstrInfo::storeRegToStackSlot ( MachineBasicBlock & MBB,
MachineBasicBlock::iterator MBBI,
Register SrcReg,
bool isKill,
int FrameIndex,
const TargetRegisterClass * RC,
const TargetRegisterInfo * TRI,
Register VReg,
MachineInstr::MIFlag Flags = MachineInstr::NoFlags ) const
inlineoverride

Definition at line 144 of file MipsInstrInfo.h.

References MBB, MBBI, llvm::MachineInstr::NoFlags, storeRegToStack(), and TRI.

◆ verifyInstruction()

bool MipsInstrInfo::verifyInstruction ( const MachineInstr & MI,
StringRef & ErrInfo ) const
override

Perform target specific instruction verification.

Definition at line 889 of file MipsInstrInfo.cpp.

References MI, Subtarget, and verifyInsExtInstruction().

Member Data Documentation

◆ Subtarget

◆ UncondBrOpc

unsigned llvm::MipsInstrInfo::UncondBrOpc
protected

Definition at line 46 of file MipsInstrInfo.h.

Referenced by insertBranch(), and MipsInstrInfo().


The documentation for this class was generated from the following files: