From 3754bf5d0677b9fe154146f4d2ae498b252a9e30 Mon Sep 17 00:00:00 2001 From: Sonicadvance1 Date: Tue, 9 Mar 2010 21:22:09 +0000 Subject: [PATCH] Add JITTed version of subfex, disabled for now since it requires us to set the CR0 flag correctly, which I currently don't have working with 64bit build. It will improve performance in RE0 which will be nice. Can probably be done more efficiently as well git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5180 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/Src/PowerPC/Jit64/Jit_Integer.cpp | 75 ++++++++++++++++--- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp index 674fbe8a3e..fc57c06bfe 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp @@ -403,19 +403,72 @@ void Jit64::subfcx(UGeckoInstruction inst) void Jit64::subfex(UGeckoInstruction inst) { - INSTRUCTION_START; + INSTRUCTION_START; + JITDISABLE(Integer) Default(inst); return; - /* - u32 a = m_GPR[_inst.RA]; - u32 b = m_GPR[_inst.RB]; - int carry = GetCarry(); - m_GPR[_inst.RD] = (~a) + b + carry; - SetCarry(Helper_Carry(~a, b) || Helper_Carry((~a) + b, carry)); - - if (_inst.OE) PanicAlert("OE: subfcx"); - if (_inst.Rc) Helper_UpdateCR0(m_GPR[_inst.RD]); - */ + int a = inst.RA, b = inst.RB, d = inst.RD; + gpr.FlushLockX(ECX); + gpr.Lock(a, b, d); + + if(d != a && d != b) + gpr.LoadToX64(d, false, true); + else + gpr.LoadToX64(d, true, true); + + MOV(32, R(EAX), gpr.R(b)); + SUB(32, R(EAX), gpr.R(a)); + MOV(32, gpr.R(d), R(EAX)); + + MOV(32, R(EAX), gpr.R(a)); + MOV(32, R(ECX), gpr.R(b)); + + CMP(32, R(EAX), Imm8(0)); + FixupBranch cpLesser = J_CC(CC_L); + FixupBranch cpGreater = J_CC(CC_G); + + // Equal + JitSetCA(); + FixupBranch continue1 = J(); + + // Lesser and greater + SetJumpTarget(cpGreater); + SetJumpTarget(cpLesser); + + NEG(32, R(EAX)); + NOT(32, R(ECX)); + + CMP(32, R(EAX), R(ECX)); + FixupBranch pLesser = J_CC(CC_L); + FixupBranch pGreater = J_CC(CC_G); + + // Equal + JitClearCA(); + FixupBranch continue2 = J(); + + // Greater + SetJumpTarget(pGreater); + JitSetCA(); + FixupBranch continue3 = J(); + + // Less than + SetJumpTarget(pLesser); + JitClearCA(); + + SetJumpTarget(continue1); + SetJumpTarget(continue2); + SetJumpTarget(continue3); + + gpr.UnlockAll(); + gpr.UnlockAllX(); + if (inst.OE) PanicAlert("OE: subfcx"); + if (inst.Rc) { + MOV(32, R(EAX), gpr.R(d)); + CALL((u8*)asm_routines.computeRc); + + // Doesn't yet work for 64bit machines + //CALL((u8*)asm_routines.computeCr); + } } void Jit64::subfx(UGeckoInstruction inst)