Commit r5970 part #3: Inline the call to computeCR: it now costs a few more memory bytes per JITed instruction but it removes the CPU overhead of the CALL. This allowed to remove some unneeded MOV as well.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5974 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
dok.slade 2010-07-25 18:44:34 +00:00
parent cba42fab1d
commit c7b4df19d7
2 changed files with 48 additions and 54 deletions

View File

@ -137,6 +137,7 @@ public:
void Cleanup();
void GenerateCarry();
void ComputeRC(const Gen::OpArg & arg);
void tri_op(int d, int a, int b, bool reversible, void (XEmitter::*op)(Gen::X64Reg, Gen::OpArg));
typedef u32 (*Operation)(u32 a, u32 b);

View File

@ -35,6 +35,24 @@ void Jit64::GenerateCarry() {
SetJumpTarget(pContinue);
}
void Jit64::ComputeRC(const Gen::OpArg & arg) {
CMP(32, arg, Imm8(0));
FixupBranch pLesser = J_CC(CC_L);
FixupBranch pGreater = J_CC(CC_G);
MOV(8, M(&PowerPC::ppcState.cr_fast[0]), Imm8(0x2)); // _x86Reg == 0
FixupBranch continue1 = J();
SetJumpTarget(pGreater);
MOV(8, M(&PowerPC::ppcState.cr_fast[0]), Imm8(0x4)); // _x86Reg > 0
FixupBranch continue2 = J();
SetJumpTarget(pLesser);
MOV(8, M(&PowerPC::ppcState.cr_fast[0]), Imm8(0x8)); // _x86Reg < 0
SetJumpTarget(continue1);
SetJumpTarget(continue2);
}
u32 Add(u32 a, u32 b) {return a + b;}
u32 Or (u32 a, u32 b) {return a | b;}
u32 And(u32 a, u32 b) {return a & b;}
@ -83,8 +101,7 @@ void Jit64::regimmop(int d, int a, bool binary, u32 value, Operation doop, void
if (Rc)
{
// Todo - special case immediates.
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -283,8 +300,7 @@ void Jit64::orx(UGeckoInstruction inst)
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -313,8 +329,7 @@ void Jit64::xorx(UGeckoInstruction inst)
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -336,7 +351,7 @@ void Jit64::andx(UGeckoInstruction inst)
if (inst.Rc) {
// result is already in eax
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -353,8 +368,7 @@ void Jit64::extsbx(UGeckoInstruction inst)
MOV(32, R(EAX), gpr.R(s));
MOVSX(32, 8, gpr.RX(a), R(AL)); // watch out for ah and friends
if (inst.Rc) {
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -370,8 +384,7 @@ void Jit64::extshx(UGeckoInstruction inst)
// as the 32-bit register.
MOVSX(32, 16, gpr.RX(a), gpr.R(s));
if (inst.Rc) {
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -421,7 +434,7 @@ void Jit64::subfcx(UGeckoInstruction inst)
gpr.UnlockAll();
if (inst.OE) PanicAlert("OE: subfcx");
if (inst.Rc) {
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -464,7 +477,7 @@ void Jit64::subfex(UGeckoInstruction inst)
gpr.UnlockAllX();
if (inst.OE) PanicAlert("OE: subfex");
if (inst.Rc) {
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -486,7 +499,7 @@ void Jit64::subfx(UGeckoInstruction inst)
if (inst.OE) PanicAlert("OE: subfx");
if (inst.Rc) {
// result is already in eax
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -519,8 +532,7 @@ void Jit64::mullwx(UGeckoInstruction inst)
}
gpr.UnlockAll();
if (inst.Rc) {
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
}
@ -543,14 +555,9 @@ void Jit64::mulhwux(UGeckoInstruction inst)
MUL(32, gpr.R(b));
gpr.UnlockAll();
gpr.UnlockAllX();
if (inst.Rc) {
MOV(32, R(EAX), R(EDX));
MOV(32, gpr.R(d), R(EDX));
// result is already in eax
CALL((u8*)asm_routines.computeRc);
} else {
MOV(32, gpr.R(d), R(EDX));
}
MOV(32, gpr.R(d), R(EDX));
if (inst.Rc)
ComputeRC(R(EDX));
}
void Jit64::divwux(UGeckoInstruction inst)
@ -581,7 +588,7 @@ void Jit64::divwux(UGeckoInstruction inst)
gpr.UnlockAll();
gpr.UnlockAllX();
if (inst.Rc) {
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -604,8 +611,7 @@ void Jit64::addx(UGeckoInstruction inst)
}
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -616,8 +622,7 @@ void Jit64::addx(UGeckoInstruction inst)
ADD(32, gpr.R(d), gpr.R(b));
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -628,8 +633,7 @@ void Jit64::addx(UGeckoInstruction inst)
ADD(32, gpr.R(d), gpr.R(a));
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -640,8 +644,7 @@ void Jit64::addx(UGeckoInstruction inst)
ADD(32, gpr.R(d), gpr.R(d));
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -653,8 +656,7 @@ void Jit64::addx(UGeckoInstruction inst)
ADD(32, gpr.R(d), gpr.R(d));
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
gpr.UnlockAll();
}
@ -685,7 +687,7 @@ void Jit64::addex(UGeckoInstruction inst)
gpr.UnlockAll();
if (inst.Rc)
{
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -739,8 +741,7 @@ void Jit64::rlwinmx(UGeckoInstruction inst)
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -773,8 +774,7 @@ void Jit64::rlwimix(UGeckoInstruction inst)
gpr.UnlockAll();
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -802,8 +802,7 @@ void Jit64::rlwnmx(UGeckoInstruction inst)
gpr.UnlockAllX();
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -821,8 +820,7 @@ void Jit64::negx(UGeckoInstruction inst)
gpr.UnlockAll();
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(d));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(d));
}
}
@ -848,8 +846,7 @@ void Jit64::srwx(UGeckoInstruction inst)
gpr.UnlockAllX();
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -875,8 +872,7 @@ void Jit64::slwx(UGeckoInstruction inst)
gpr.UnlockAllX();
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(R(EAX));
}
}
@ -920,8 +916,7 @@ void Jit64::srawx(UGeckoInstruction inst)
gpr.UnlockAllX();
if (inst.Rc) {
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -963,8 +958,7 @@ void Jit64::srawix(UGeckoInstruction inst)
}
if (inst.Rc) {
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
}
}
@ -991,8 +985,7 @@ void Jit64::cntlzwx(UGeckoInstruction inst)
if (inst.Rc)
{
MOV(32, R(EAX), gpr.R(a));
CALL((u8*)asm_routines.computeRc);
ComputeRC(gpr.R(a));
// TODO: Check PPC manual too
}
}