#include "Mips.h"
#include "MipsInstrInfo.h"
#include "MipsSubtarget.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/Debug.h"
usingnamespacellvm;
#define DEBUG_TYPE …
#define MICROMIPS_SIZE_REDUCE_NAME …
STATISTIC(NumReduced, "Number of instructions reduced (32-bit to 16-bit ones, "
"or two instructions into one");
namespace {
enum OperandTransfer { … };
enum ReduceType { … };
struct ImmField { … };
struct OpInfo { … };
struct OpCodes { … };
ReduceEntryFunArgs;
struct ReduceEntry { … };
struct ReduceEntryFunArgs { … };
ReduceEntryVector;
class MicroMipsSizeReduce : public MachineFunctionPass { … };
char MicroMipsSizeReduce::ID = …;
const MipsInstrInfo *MicroMipsSizeReduce::MipsII;
ReduceEntryVector MicroMipsSizeReduce::ReduceTable = …;
}
INITIALIZE_PASS(…)
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) { … }
MicroMipsSizeReduce::MicroMipsSizeReduce() : … { … }
bool MicroMipsSizeReduce::ReduceMI(const MachineBasicBlock::instr_iterator &MII,
MachineBasicBlock::instr_iterator &NextMII) { … }
bool MicroMipsSizeReduce::ReduceXWtoXWSP(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceXWtoXWP(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceArithmeticInstructions(
ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceADDIUToADDIUR1SP(
ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceADDIUToADDIUSP(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceLXUtoLXU16(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceSXtoSX16(ReduceEntryFunArgs *Arguments) { … }
static bool IsMovepSrcRegister(unsigned Reg) { … }
static bool IsMovepDestinationReg(unsigned Reg) { … }
static bool IsMovepDestinationRegPair(unsigned R0, unsigned R1) { … }
bool MicroMipsSizeReduce::ReduceMoveToMovep(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceXORtoXOR16(ReduceEntryFunArgs *Arguments) { … }
bool MicroMipsSizeReduce::ReduceMBB(MachineBasicBlock &MBB) { … }
bool MicroMipsSizeReduce::ReplaceInstruction(MachineInstr *MI,
const ReduceEntry &Entry,
MachineInstr *MI2,
bool ConsecutiveForward) { … }
bool MicroMipsSizeReduce::runOnMachineFunction(MachineFunction &MF) { … }
FunctionPass *llvm::createMicroMipsSizeReducePass() { … }