Skip to content

Commit

Permalink
jit-ir: Flush consts better for a few f/v ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed May 9, 2016
1 parent 5221a02 commit 6bd31ec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Core/MIPS/IR/IRInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ enum {
IRTEMP_RHS, // Reserved for use in branches

// Hacky way to get to other state
IRREG_VPFU_CTRL_BASE = 208,
IRREG_VPFU_CC = 211,
IRREG_LO = 226, // offset of lo in MIPSState / 4
IRREG_HI = 227,
IRREG_FCR31 = 228,
Expand Down
47 changes: 47 additions & 0 deletions Core/MIPS/IR/IRPassSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) {
}
break;

case IROp::VMovFromGPR:
if (gpr.IsImm(inst.src1)) {
out.Write(IROp::SetConstV, inst.dest, out.AddConstant(gpr.GetImm(inst.src1)));
} else {
gpr.MapIn(inst.src1);
goto doDefault;
}
break;

case IROp::FMovToGPR:
gpr.MapDirty(inst.dest);
goto doDefault;

case IROp::VMovToGPR:
gpr.MapDirty(inst.dest);
goto doDefault;

case IROp::MfHi:
case IROp::MfLo:
gpr.MapDirty(inst.dest);
Expand All @@ -283,6 +300,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) {
}
break;
case IROp::StoreFloat:
case IROp::StoreFloatV:
if (gpr.IsImm(inst.src1)) {
out.Write(inst.op, inst.dest, 0, out.AddConstant(gpr.GetImm(inst.src1) + constants[inst.src2]));
} else {
Expand All @@ -305,6 +323,7 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) {
}
break;
case IROp::LoadFloat:
case IROp::LoadFloatV:
if (gpr.IsImm(inst.src1)) {
out.Write(inst.op, inst.dest, 0, out.AddConstant(gpr.GetImm(inst.src1) + constants[inst.src2]));
} else {
Expand Down Expand Up @@ -335,9 +354,37 @@ bool PropagateConstants(const IRWriter &in, IRWriter &out) {
case IROp::FAbs:
case IROp::FSqrt:
case IROp::FMov:
case IROp::FRound:
case IROp::FTrunc:
case IROp::FCeil:
case IROp::FFloor:
case IROp::FCvtSW:
out.Write(inst);
break;

case IROp::SetCtrlVFPU:
goto doDefault;

case IROp::FCvtWS:
// TODO: Actually, this should just use the currently set rounding mode.
// Move up with FCvtSW when that's implemented.
gpr.MapIn(IRREG_FCR31);
out.Write(inst);
break;

case IROp::FpCondToReg:
if (gpr.IsImm(IRREG_FPCOND)) {
gpr.SetImm(inst.dest, gpr.GetImm(IRREG_FPCOND));
} else {
gpr.MapDirtyIn(inst.dest, IRREG_FPCOND);
out.Write(inst);
}
break;

case IROp::VfpuCtrlToReg:
gpr.MapDirtyIn(inst.dest, IRREG_VPFU_CTRL_BASE + inst.src1);
goto doDefault;

case IROp::Syscall:
case IROp::Interpret:
case IROp::ExitToConst:
Expand Down

0 comments on commit 6bd31ec

Please sign in to comment.