JIT64: faster implementation of mfcr
This commit is contained in:
parent
d5d5580424
commit
8c71703098
|
@ -277,47 +277,38 @@ void Jit64::mfcr(UGeckoInstruction inst)
|
||||||
JITDISABLE(bJITSystemRegistersOff);
|
JITDISABLE(bJITSystemRegistersOff);
|
||||||
// USES_CR
|
// USES_CR
|
||||||
int d = inst.RD;
|
int d = inst.RD;
|
||||||
gpr.Lock(d);
|
gpr.BindToRegister(d, false, true);
|
||||||
gpr.KillImmediate(d, false, true);
|
XOR(32, gpr.R(d), gpr.R(d));
|
||||||
XOR(32, R(EAX), R(EAX));
|
|
||||||
|
|
||||||
gpr.FlushLockX(ABI_PARAM1, ABI_PARAM2);
|
gpr.FlushLockX(ABI_PARAM1);
|
||||||
X64Reg cr_val = ABI_PARAM1;
|
X64Reg cr_val = ABI_PARAM1;
|
||||||
X64Reg tmp = ABI_PARAM2;
|
// we only need to zero the high bits of EAX once
|
||||||
|
XOR(32, R(EAX), R(EAX));
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
static const u8 m_flagTable[8] = {0x0,0x1,0x8,0x9,0x0,0x1,0x8,0x9};
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
SHL(32, R(EAX), Imm8(4));
|
SHL(32, gpr.R(d), Imm8(4));
|
||||||
|
|
||||||
MOV(64, R(cr_val), M(&PowerPC::ppcState.cr_val[i]));
|
MOV(64, R(cr_val), M(&PowerPC::ppcState.cr_val[i]));
|
||||||
|
|
||||||
// SO: Bit 61 set.
|
// EQ: Bits 31-0 == 0; set flag bit 1
|
||||||
MOV(64, R(tmp), R(cr_val));
|
|
||||||
SHR(64, R(tmp), Imm8(61));
|
|
||||||
AND(32, R(tmp), Imm8(1));
|
|
||||||
OR(32, R(EAX), R(tmp));
|
|
||||||
|
|
||||||
// EQ: Bits 31-0 == 0.
|
|
||||||
XOR(32, R(tmp), R(tmp));
|
|
||||||
TEST(32, R(cr_val), R(cr_val));
|
TEST(32, R(cr_val), R(cr_val));
|
||||||
SETcc(CC_Z, R(tmp));
|
SETcc(CC_Z, R(EAX));
|
||||||
SHL(32, R(tmp), Imm8(1));
|
LEA(32, gpr.RX(d), MComplex(gpr.RX(d), EAX, SCALE_2, 0));
|
||||||
OR(32, R(EAX), R(tmp));
|
|
||||||
|
|
||||||
// GT: Value > 0.
|
// GT: Value > 0; set flag bit 2
|
||||||
TEST(64, R(cr_val), R(cr_val));
|
TEST(64, R(cr_val), R(cr_val));
|
||||||
SETcc(CC_G, R(tmp));
|
SETcc(CC_G, R(EAX));
|
||||||
SHL(32, R(tmp), Imm8(2));
|
LEA(32, gpr.RX(d), MComplex(gpr.RX(d), EAX, SCALE_4, 0));
|
||||||
OR(32, R(EAX), R(tmp));
|
|
||||||
|
|
||||||
// LT: Bit 62 set.
|
// SO: Bit 61 set; set flag bit 0
|
||||||
MOV(64, R(tmp), R(cr_val));
|
// LT: Bit 62 set; set flag bit 3
|
||||||
SHR(64, R(tmp), Imm8(62 - 3));
|
SHR(64, R(cr_val), Imm8(61));
|
||||||
AND(32, R(tmp), Imm8(0x8));
|
MOVZX(32, 8, EAX, MDisp(cr_val, (u32)(u64)m_flagTable));
|
||||||
OR(32, R(EAX), R(tmp));
|
OR(32, gpr.R(d), R(EAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
MOV(32, gpr.R(d), R(EAX));
|
|
||||||
gpr.UnlockAll();
|
gpr.UnlockAll();
|
||||||
gpr.UnlockAllX();
|
gpr.UnlockAllX();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue