Jit_Integer: arithcx

This commit is contained in:
MerryMage 2018-10-15 21:01:07 +01:00
parent 6ce718b920
commit bde5df03a3
1 changed files with 24 additions and 20 deletions

View File

@ -1466,37 +1466,41 @@ void Jit64::arithcx(UGeckoInstruction inst)
JITDISABLE(bJITIntegerOff);
bool add = !!(inst.SUBOP10 & 2); // add or sub
int a = inst.RA, b = inst.RB, d = inst.RD;
gpr.Lock(a, b, d);
gpr.BindToRegister(d, d == a || d == b, true);
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCOpArg Rb = gpr.Use(b, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rb, Rd);
if (d == a && d != b)
{
if (add)
{
ADD(32, gpr.R(d), gpr.R(b));
ADD(32, Rd, Rb);
}
else
{
// special case, because sub isn't reversible
MOV(32, R(RSCRATCH), gpr.R(a));
MOV(32, gpr.R(d), gpr.R(b));
SUB(32, gpr.R(d), R(RSCRATCH));
MOV(32, R(RSCRATCH), Ra);
MOV(32, Rd, Rb);
SUB(32, Rd, R(RSCRATCH));
}
}
else
{
if (d != b)
MOV(32, gpr.R(d), gpr.R(b));
MOV(32, Rd, Rb);
if (add)
ADD(32, gpr.R(d), gpr.R(a));
ADD(32, Rd, Ra);
else
SUB(32, gpr.R(d), gpr.R(a));
SUB(32, Rd, Ra);
}
}
FinalizeCarryOverflow(inst.OE, !add);
if (inst.Rc)
ComputeRC(gpr.R(d));
gpr.UnlockAll();
ComputeRC(d);
}
void Jit64::rlwinmx(UGeckoInstruction inst)