From 4641cf376ffc61cde4bcdcbf4821c452bbd85933 Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 5 Mar 2013 14:16:35 +1000 Subject: [PATCH] Armjit: Implement CLZ instruction. Disable reg shifts for now (breaks Wipeout Pure). --- Common/ArmEmitter.cpp | 5 +++++ Common/ArmEmitter.h | 1 + Core/MIPS/ARM/ArmCompALU.cpp | 24 ++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Common/ArmEmitter.cpp b/Common/ArmEmitter.cpp index 67f7414e99..152f84259d 100644 --- a/Common/ArmEmitter.cpp +++ b/Common/ArmEmitter.cpp @@ -542,6 +542,11 @@ void ARMXEmitter::UBFX(ARMReg dest, ARMReg rn, u8 lsb, u8 width) Write32(condition | (0x7E0 << 16) | ((width - 1) << 16) | (dest << 12) | (lsb << 7) | (5 << 4) | rn); } +void ARMXEmitter::CLZ(ARMReg rd, ARMReg rm) +{ + Write32(condition | (0x16F << 16) | (rd << 12) | (0xF1 << 4) | rm); +} + void ARMXEmitter::BFI(ARMReg rd, ARMReg rn, u8 lsb, u8 width) { u32 msb = (lsb + width - 1); diff --git a/Common/ArmEmitter.h b/Common/ArmEmitter.h index 3c6a94d8dc..a49a91104c 100644 --- a/Common/ArmEmitter.h +++ b/Common/ArmEmitter.h @@ -485,6 +485,7 @@ public: void SXTAH(ARMReg dest, ARMReg src, ARMReg op2, u8 rotation = 0); void BFI(ARMReg rd, ARMReg rn, u8 lsb, u8 width); void UBFX(ARMReg dest, ARMReg op2, u8 lsb, u8 width); + void CLZ(ARMReg rd, ARMReg rm); // Using just MSR here messes with our defines on the PPC side of stuff (when this code was in dolphin...) // Just need to put an underscore here, bit annoying. diff --git a/Core/MIPS/ARM/ArmCompALU.cpp b/Core/MIPS/ARM/ArmCompALU.cpp index 33b41bda60..154b215e3e 100644 --- a/Core/MIPS/ARM/ArmCompALU.cpp +++ b/Core/MIPS/ARM/ArmCompALU.cpp @@ -155,8 +155,26 @@ namespace MIPSComp void Jit::Comp_RType2(u32 op) { - DISABLE; - } + CONDITIONAL_DISABLE; + int rs = _RS; + int rd = _RD; + + // Don't change $zr. + if (rd == 0) + return; + + switch (op & 63) + { + case 22: //clz + gpr.MapDirtyIn(rd, rs); + CLZ(gpr.R(rd), gpr.R(rs)); + break; + case 23: //clo + DISABLE; + break; + default: + DISABLE; + } void Jit::Comp_RType3(u32 op) { @@ -271,6 +289,8 @@ namespace MIPSComp void Jit::CompShiftVar(u32 op, ArmGen::ShiftType shiftType) { + // Breaks Wipeout Pure + DISABLE; int rd = _RD; int rt = _RT; int rs = _RS;