LLVM 24.0.0git
MicroMipsSizeReduction.cpp File Reference

This pass is used to reduce the size of instructions where applicable. More...

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "mips-micromips-reduce-size"
#define MICROMIPS_SIZE_REDUCE_NAME   "MicroMips instruction size reduce pass"

Functions

 STATISTIC (NumReduced, "Number of instructions reduced (32-bit to 16-bit ones, " "or two instructions into one")
 INITIALIZE_PASS (MicroMipsSizeReduceLegacy, DEBUG_TYPE, MICROMIPS_SIZE_REDUCE_NAME, false, false) static bool IsSP(const MachineOperand &MO)
static bool isMMThreeBitGPRegister (const MachineOperand &MO)
static bool isMMSourceRegister (const MachineOperand &MO)
static bool GetImm (MachineInstr *MI, unsigned Op, int64_t &Imm)
static bool AddiuspImmValue (int64_t Value)
static bool InRange (int64_t Value, unsigned short Shift, int LBound, int HBound)
static bool ImmInRange (MachineInstr *MI, const ReduceEntry &Entry)
static bool CheckXWPInstr (MachineInstr *MI, bool ReduceToLwp, const ReduceEntry &Entry)
static bool ConsecutiveRegisters (unsigned Reg1, unsigned Reg2)
static bool ConsecutiveInstr (MachineInstr *MI1, MachineInstr *MI2)
static bool ReplaceInstruction (MachineInstr *MI, const ReduceEntry &Entry, const MipsInstrInfo *MipsII, MachineInstr *MI2=nullptr, bool ConsecutiveForward=true)
static bool ReduceXWtoXWSP (ReduceEntryFunArgs *Arguments)
static bool ReduceXWtoXWP (ReduceEntryFunArgs *Arguments)
static bool ReduceArithmeticInstructions (ReduceEntryFunArgs *Arguments)
static bool ReduceADDIUToADDIUR1SP (ReduceEntryFunArgs *Arguments)
static bool ReduceADDIUToADDIUSP (ReduceEntryFunArgs *Arguments)
static bool ReduceLXUtoLXU16 (ReduceEntryFunArgs *Arguments)
static bool ReduceSXtoSX16 (ReduceEntryFunArgs *Arguments)
static bool IsMovepSrcRegister (unsigned Reg)
static bool IsMovepDestinationReg (unsigned Reg)
static bool IsMovepDestinationRegPair (unsigned R0, unsigned R1)
static bool ReduceMoveToMovep (ReduceEntryFunArgs *Arguments)
static bool ReduceXORtoXOR16 (ReduceEntryFunArgs *Arguments)
static bool ReduceMI (const MachineBasicBlock::instr_iterator &MII, MachineBasicBlock::instr_iterator &NextMII, const MipsInstrInfo *MipsII)
static bool ReduceMBB (MachineBasicBlock &MBB, const MipsInstrInfo *MipsII)
 Reduces width of instructions in the specified basic block.
static bool runMipsSizeReduce (MachineFunction &MF)

Variables

static ReduceEntryVector ReduceTable

Detailed Description

This pass is used to reduce the size of instructions where applicable.

TODO: Implement microMIPS64 support.

Definition in file MicroMipsSizeReduction.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mips-micromips-reduce-size"

Definition at line 26 of file MicroMipsSizeReduction.cpp.

◆ MICROMIPS_SIZE_REDUCE_NAME

#define MICROMIPS_SIZE_REDUCE_NAME   "MicroMips instruction size reduce pass"

Definition at line 27 of file MicroMipsSizeReduction.cpp.

Referenced by INITIALIZE_PASS().

Function Documentation

◆ AddiuspImmValue()

bool AddiuspImmValue ( int64_t Value)
static

Definition at line 197 of file MicroMipsSizeReduction.cpp.

References llvm::maskTrailingZeros().

Referenced by ReduceADDIUToADDIUSP().

◆ CheckXWPInstr()

bool CheckXWPInstr ( MachineInstr * MI,
bool ReduceToLwp,
const ReduceEntry & Entry )
static

Definition at line 231 of file MicroMipsSizeReduction.cpp.

References ImmInRange(), MI, and llvm::Mips::RA.

Referenced by ReduceXWtoXWP().

◆ ConsecutiveInstr()

bool ConsecutiveInstr ( MachineInstr * MI1,
MachineInstr * MI2 )
static

◆ ConsecutiveRegisters()

bool ConsecutiveRegisters ( unsigned Reg1,
unsigned Reg2 )
static

Definition at line 258 of file MicroMipsSizeReduction.cpp.

References Registers.

Referenced by ConsecutiveInstr().

◆ GetImm()

bool GetImm ( MachineInstr * MI,
unsigned Op,
int64_t & Imm )
static

Definition at line 188 of file MicroMipsSizeReduction.cpp.

References Imm, and MI.

Referenced by ConsecutiveInstr(), llvm::ShapeT::deduceImm(), ImmInRange(), and ReduceADDIUToADDIUSP().

◆ ImmInRange()

bool ImmInRange ( MachineInstr * MI,
const ReduceEntry & Entry )
static

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( MicroMipsSizeReduceLegacy ,
DEBUG_TYPE ,
MICROMIPS_SIZE_REDUCE_NAME ,
false ,
false  ) const &

◆ InRange()

◆ isMMSourceRegister()

bool isMMSourceRegister ( const MachineOperand & MO)
static

◆ isMMThreeBitGPRegister()

◆ IsMovepDestinationReg()

bool IsMovepDestinationReg ( unsigned Reg)
static

Definition at line 539 of file MicroMipsSizeReduction.cpp.

References Reg.

Referenced by ReduceMoveToMovep().

◆ IsMovepDestinationRegPair()

bool IsMovepDestinationRegPair ( unsigned R0,
unsigned R1 )
static

Definition at line 550 of file MicroMipsSizeReduction.cpp.

Referenced by ReduceMoveToMovep().

◆ IsMovepSrcRegister()

bool IsMovepSrcRegister ( unsigned Reg)
static

Definition at line 527 of file MicroMipsSizeReduction.cpp.

References Reg.

Referenced by ReduceMoveToMovep().

◆ ReduceADDIUToADDIUR1SP()

bool ReduceADDIUToADDIUR1SP ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceADDIUToADDIUSP()

bool ReduceADDIUToADDIUSP ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceArithmeticInstructions()

bool ReduceArithmeticInstructions ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceLXUtoLXU16()

bool ReduceLXUtoLXU16 ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceMBB()

bool ReduceMBB ( MachineBasicBlock & MBB,
const MipsInstrInfo * MipsII )
static

Reduces width of instructions in the specified basic block.

Definition at line 732 of file MicroMipsSizeReduction.cpp.

References E(), MBB, MI, Modified, and ReduceMI().

Referenced by runMipsSizeReduce().

◆ ReduceMI()

Definition at line 704 of file MicroMipsSizeReduction.cpp.

References Arguments, llvm::End, MI, Range, and ReduceTable.

Referenced by ReduceMBB().

◆ ReduceMoveToMovep()

◆ ReduceSXtoSX16()

bool ReduceSXtoSX16 ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceXORtoXOR16()

bool ReduceXORtoXOR16 ( ReduceEntryFunArgs * Arguments)
static

◆ ReduceXWtoXWP()

◆ ReduceXWtoXWSP()

bool ReduceXWtoXWSP ( ReduceEntryFunArgs * Arguments)
static

Definition at line 384 of file MicroMipsSizeReduction.cpp.

References Arguments, ImmInRange(), MI, and ReplaceInstruction().

◆ ReplaceInstruction()

◆ runMipsSizeReduce()

◆ STATISTIC()

STATISTIC ( NumReduced )

Variable Documentation

◆ ReduceTable

ReduceEntryVector ReduceTable
static

Definition at line 632 of file MicroMipsSizeReduction.cpp.

Referenced by INITIALIZE_PASS(), and ReduceMI().