Combine move-from-gpr and float cast.

This commit is contained in:
Henrik Rydgård committed 2024-06-08 22:59:48 +02:00
1 parent 0abcd00372
commit c9ca3904d3
4 files changed
+17 -3

No files matched your search

+1
View File
@@ -121,6 +121,7 @@ static const IRMeta irMeta[] = {
{ IROp::FMovFromGPR, "FMovFromGPR", "FG" },
{ IROp::FMovToGPR, "FMovToGPR", "GF" },
{ IROp::OptFMovToGPRShr8, "OptFMovToGPRShr8", "GF" },
{ IROp::OptFCvtSWFromGPR, "OptFCvtSWFromGPR", "FG" },
{ IROp::FpCondFromReg, "FpCondFromReg", "_G" },
{ IROp::FpCondToReg, "FpCondToReg", "G" },
{ IROp::FpCtrlFromReg, "FpCtrlFromReg", "_G" },
+1
View File
@@ -138,6 +138,7 @@ enum class IROp : uint8_t {
FCvtScaledSW,
FMovFromGPR,
OptFCvtSWFromGPR,
FMovToGPR,
OptFMovToGPRShr8,
+4
View File
@@ -997,6 +997,9 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst) {
case IROp::FMovFromGPR:
memcpy(&mips->f[inst->dest], &mips->r[inst->src1], 4);
break;
case IROp::OptFCvtSWFromGPR:
mips->f[inst->dest] = (float)(int)mips->r[inst->src1];
break;
case IROp::FMovToGPR:
memcpy(&mips->r[inst->dest], &mips->f[inst->src1], 4);
break;
@@ -1007,6 +1010,7 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst) {
mips->r[inst->dest] = temp >> 8;
break;
}
case IROp::ExitToConst:
return inst->constant;
+11 -3
View File
@@ -2269,10 +2269,18 @@ bool OptimizeForInterpreter(const IRWriter &in, IRWriter &out, const IROptions &
inst.op = IROp::OptFMovToGPRShr8;
i++; // Skip the next instruction.
}
out.Write(inst);
} else {
out.Write(inst);
}
out.Write(inst);
break;
case IROp::FMovFromGPR:
if (!last) {
IRInst next = in.GetInstructions()[i + 1];
if (next.op == IROp::FCvtSW && next.src1 == inst.dest && next.dest == inst.dest) {
inst.op = IROp::OptFCvtSWFromGPR;
i++; // Skip the next
}
}
out.Write(inst);
break;
default:
out.Write(inst);