From 282cf6c6b5f9623c8d996ec250b625252438be22 Mon Sep 17 00:00:00 2001 From: nakeee Date: Mon, 19 Apr 2010 13:02:24 +0000 Subject: [PATCH] DSP jit: 'mv 's 'sn are now jitted. Added void pushExtValueFromReg(u16 dreg, u16 sreg); void popExtValueToReg(); instead of the backlog. Someone might want to add it to the Unit test git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5389 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPEmitter.cpp | 7 +++++-- Source/Core/DSPCore/Src/DSPEmitter.h | 9 ++++++++- Source/Core/DSPCore/Src/DSPTables.cpp | 6 +++--- Source/Core/DSPCore/Src/Jit/DSPJitExtOps.cpp | 16 ++++++++++++---- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Source/Core/DSPCore/Src/DSPEmitter.cpp b/Source/Core/DSPCore/Src/DSPEmitter.cpp index 61fc9f6e04..2d9ba26e1f 100644 --- a/Source/Core/DSPCore/Src/DSPEmitter.cpp +++ b/Source/Core/DSPCore/Src/DSPEmitter.cpp @@ -127,9 +127,12 @@ void DSPEmitter::WriteCallInterpreter(UDSPInstruction inst) (this->*opTable[inst]->jitFunc)(inst); // Backlog - // TODO if for jit if (tinst->extended) { - ABI_CallFunction((void*)applyWriteBackLog); + if (! extOpTable[inst & 0x7F]->jitFunc) { + ABI_CallFunction((void*)applyWriteBackLog); + } else { + popExtValueToReg(); + } } } diff --git a/Source/Core/DSPCore/Src/DSPEmitter.h b/Source/Core/DSPCore/Src/DSPEmitter.h index 7d44d74a42..0c505bb8cb 100644 --- a/Source/Core/DSPCore/Src/DSPEmitter.h +++ b/Source/Core/DSPCore/Src/DSPEmitter.h @@ -33,6 +33,10 @@ class DSPEmitter : public Gen::XCodeBlock u16 blockSize[0x10000]; bool *endBlock; u16 compileSR; + + // The index of the last stored ext value (compile time). + u16 storeIndex; + DISALLOW_COPY_AND_ASSIGN(DSPEmitter); void ToMask(Gen::X64Reg value_reg = Gen::EDI, Gen::X64Reg temp_reg = Gen::ESI); @@ -62,7 +66,10 @@ public: void decrease_addr_reg(int reg); void ext_dmem_write(u32 src, u32 dest); void ext_dmem_read(u16 addr); - void storeExtValue(u16 value); + + // Ext command helpers + void pushExtValueFromReg(u16 dreg, u16 sreg); + void popExtValueToReg(); // Ext commands void l(const UDSPInstruction opc); diff --git a/Source/Core/DSPCore/Src/DSPTables.cpp b/Source/Core/DSPCore/Src/DSPTables.cpp index 99fc7d59c0..b8cfc48af4 100644 --- a/Source/Core/DSPCore/Src/DSPTables.cpp +++ b/Source/Core/DSPCore/Src/DSPTables.cpp @@ -311,10 +311,10 @@ const DSPOPCTemplate opcodes_ext[] = {"DR", 0x0004, 0x00fc, DSPInterpreter::Ext::dr, &DSPEmitter::dr, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false}, {"IR", 0x0008, 0x00fc, DSPInterpreter::Ext::ir, &DSPEmitter::ir, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false}, {"NR", 0x000c, 0x00fc, DSPInterpreter::Ext::nr, &DSPEmitter::nr, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false}, - {"MV", 0x0010, 0x00f0, DSPInterpreter::Ext::mv, NULL /*&DSPEmitter::mv*/, 1, +2, {{P_REG18, 1, 0, 2, 0x000c}, {P_REG1C, 1, 0, 0, 0x0003}}, false, false}, + {"MV", 0x0010, 0x00f0, DSPInterpreter::Ext::mv, &DSPEmitter::mv, 1, 2, {{P_REG18, 1, 0, 2, 0x000c}, {P_REG1C, 1, 0, 0, 0x0003}}, false, false}, - {"S", 0x0020, 0x00e4, DSPInterpreter::Ext::s, NULL /*&DSPEmitter::s*/, 1, 2, {{P_PRG, 1, 0, 0, 0x0003}, {P_REG1C, 1, 0, 3, 0x0018}}, false, false}, - {"SN", 0x0024, 0x00e4, DSPInterpreter::Ext::sn, NULL /*&DSPEmitter::sn*/, 1, 2, {{P_PRG, 1, 0, 0, 0x0003}, {P_REG1C, 1, 0, 3, 0x0018}}, false, false}, + {"S", 0x0020, 0x00e4, DSPInterpreter::Ext::s, &DSPEmitter::s, 1, 2, {{P_PRG, 1, 0, 0, 0x0003}, {P_REG1C, 1, 0, 3, 0x0018}}, false, false}, + {"SN", 0x0024, 0x00e4, DSPInterpreter::Ext::sn, &DSPEmitter::sn, 1, 2, {{P_PRG, 1, 0, 0, 0x0003}, {P_REG1C, 1, 0, 3, 0x0018}}, false, false}, {"L", 0x0040, 0x00c4, DSPInterpreter::Ext::l, NULL /*&DSPEmitter::l*/, 1, 2, {{P_REG18, 1, 0, 3, 0x0038}, {P_PRG, 1, 0, 0, 0x0003}}, false, false}, {"LN", 0x0044, 0x00c4, DSPInterpreter::Ext::ln, NULL /*&DSPEmitter::ln*/, 1, 2, {{P_REG18, 1, 0, 3, 0x0038}, {P_PRG, 1, 0, 0, 0x0003}}, false, false}, diff --git a/Source/Core/DSPCore/Src/Jit/DSPJitExtOps.cpp b/Source/Core/DSPCore/Src/Jit/DSPJitExtOps.cpp index 992686f841..7a911ae66c 100644 --- a/Source/Core/DSPCore/Src/Jit/DSPJitExtOps.cpp +++ b/Source/Core/DSPCore/Src/Jit/DSPJitExtOps.cpp @@ -53,8 +53,8 @@ void DSPEmitter::mv(const UDSPInstruction opc) { u8 sreg = (opc & 0x3) + DSP_REG_ACL0; u8 dreg = ((opc >> 2) & 0x3); - - MOV(16, M(&g_dsp.r[dreg + DSP_REG_AXL0]), M(&g_dsp.r[sreg])); + pushExtValueFromReg(dreg + DSP_REG_AXL0, sreg); + // MOV(16, M(&g_dsp.r[dreg + DSP_REG_AXL0]), M(&g_dsp.r[sreg])); } // S @$arD, $acS.S @@ -524,8 +524,16 @@ void DSPEmitter::ldnm(const UDSPInstruction opc) } -void DSPEmitter::storeExtValue(u16 value) { - +// Push value from g_dsp.r[sreg] into EBX and stores the destinationindex in +// storeIndex +void DSPEmitter::pushExtValueFromReg(u16 dreg, u16 sreg) { + MOVZX(32, 16, EBX, M(&g_dsp.r[sreg])); + storeIndex = dreg; } +void DSPEmitter::popExtValueToReg() { + MOV(16, M(&g_dsp.r[storeIndex]), R(EBX)); + + // TODO handle commands such as 'l +}