From 9bb78ce2ec9081ceed161a76384d8d354a4801f4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Feb 2013 08:45:35 -0800 Subject: [PATCH] Jit madd/msub in x86. --- Core/MIPS/MIPSTables.cpp | 4 +- Core/MIPS/x86/CompALU.cpp | 81 +++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/Core/MIPS/MIPSTables.cpp b/Core/MIPS/MIPSTables.cpp index 145e236f46..8e1b0a0f1a 100644 --- a/Core/MIPS/MIPSTables.cpp +++ b/Core/MIPS/MIPSTables.cpp @@ -224,8 +224,8 @@ const MIPSInstruction tableSpecial[64] = /// 000000 ...... ...... .......... xxx INSTR("sltu", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), INSTR("max", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), INSTR("min", &Jit::Comp_RType3, Dis_RType3, Int_RType3,IN_RS|IN_RT|OUT_RD), - INSTR("msub", &Jit::Comp_RType3, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), - INSTR("msubu", &Jit::Comp_RType3, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), + INSTR("msub", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), + INSTR("msubu", &Jit::Comp_MulDivType, Dis_MulDivType, Int_MulDivType, IN_RS|IN_RT|OUT_OTHER), //48 INSTR("tge", &Jit::Comp_Generic, Dis_RType3, 0, 0), diff --git a/Core/MIPS/x86/CompALU.cpp b/Core/MIPS/x86/CompALU.cpp index 2ffcd94d4b..4f12813315 100644 --- a/Core/MIPS/x86/CompALU.cpp +++ b/Core/MIPS/x86/CompALU.cpp @@ -423,50 +423,49 @@ namespace MIPSComp gpr.UnlockAllX(); break; + case 28: // madd + gpr.FlushLockX(EDX); + gpr.KillImmediate(rt, true, false); + MOV(32, R(EAX), gpr.R(rs)); + IMUL(32, gpr.R(rt)); + ADD(32, M((void *)&mips_->lo), R(EAX)); + ADC(32, M((void *)&mips_->hi), R(EDX)); + gpr.UnlockAllX(); + break; + + case 29: // maddu + gpr.FlushLockX(EDX); + gpr.KillImmediate(rt, true, false); + MOV(32, R(EAX), gpr.R(rs)); + MUL(32, gpr.R(rt)); + ADD(32, M((void *)&mips_->lo), R(EAX)); + ADC(32, M((void *)&mips_->hi), R(EDX)); + gpr.UnlockAllX(); + break; + + case 46: // msub + gpr.FlushLockX(EDX); + gpr.KillImmediate(rt, true, false); + MOV(32, R(EAX), gpr.R(rs)); + IMUL(32, gpr.R(rt)); + SUB(32, M((void *)&mips_->lo), R(EAX)); + SBB(32, M((void *)&mips_->hi), R(EDX)); + gpr.UnlockAllX(); + break; + + case 47: // msubu + gpr.FlushLockX(EDX); + gpr.KillImmediate(rt, true, false); + MOV(32, R(EAX), gpr.R(rs)); + MUL(32, gpr.R(rt)); + SUB(32, M((void *)&mips_->lo), R(EAX)); + SBB(32, M((void *)&mips_->hi), R(EDX)); + gpr.UnlockAllX(); + break; default: - DISABLE; + DISABLE; /* - case 28: //madd - { - u32 a=R(rs),b=R(rt),hi=HI,lo=LO; - u64 origValBits = (u64)lo | ((u64)(hi)<<32); - s64 origVal = (s64)origValBits; - s64 result = origVal + (s64)(s32)a * (s64)(s32)b; - u64 resultBits = (u64)(result); - LO = (u32)(resultBits); - HI = (u32)(resultBits>>32); - } - break; - case 29: //maddu - { - u32 a=R(rs),b=R(rt),hi=HI,lo=LO; - u64 origVal = (u64)lo | ((u64)(hi)<<32); - u64 result = origVal + (u64)a * (u64)b; - LO = (u32)(result); - HI = (u32)(result>>32); - } - break; - case 46: //msub - { - u32 a=R(rs),b=R(rt),hi=HI,lo=LO; - u64 origValBits = (u64)lo | ((u64)(hi)<<32); - s64 origVal = (s64)origValBits; - s64 result = origVal - (s64)(s32)a * (s64)(s32)b; - u64 resultBits = (u64)(result); - LO = (u32)(resultBits); - HI = (u32)(resultBits>>32); - } - break; - case 47: //msubu - { - u32 a=R(rs),b=R(rt),hi=HI,lo=LO; - u64 origVal = (u64)lo | ((u64)(hi)<<32); - u64 result = origVal - (u64)a * (u64)b; - LO = (u32)(result); - HI = (u32)(result>>32); - } - break; case 26: //div { s32 a = (s32)R(rs);