From 9131b994bb5357f7699b25cac43de585e9ccc105 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Dec 2016 15:03:52 -0500 Subject: [PATCH] DSPTables: Move interpreter specifics to DSPInterpreter --- Source/Core/Core/DSP/DSPDisassembler.cpp | 11 ++++--- Source/Core/Core/DSP/DSPInterpreter.cpp | 39 ++++++++++++++++++++++-- Source/Core/Core/DSP/DSPInterpreter.h | 1 + Source/Core/Core/DSP/DSPTables.cpp | 13 ++------ Source/Core/Core/DSP/DSPTables.h | 22 ------------- 5 files changed, 46 insertions(+), 40 deletions(-) diff --git a/Source/Core/Core/DSP/DSPDisassembler.cpp b/Source/Core/Core/DSP/DSPDisassembler.cpp index a58a273ec4..30f8cd96bf 100644 --- a/Source/Core/Core/DSP/DSPDisassembler.cpp +++ b/Source/Core/Core/DSP/DSPDisassembler.cpp @@ -3,6 +3,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Core/DSP/DSPDisassembler.h" + #include #include #include @@ -12,7 +14,7 @@ #include "Common/FileUtil.h" #include "Common/StringUtil.h" -#include "Core/DSP/DSPDisassembler.h" +#include "Core/DSP/DSPInterpreter.h" #include "Core/DSP/DSPTables.h" DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(settings) @@ -192,9 +194,10 @@ bool DSPDisassembler::DisassembleOpcode(const u16* binbuf, int base_addr, int pa break; } } - const DSPOPCTemplate fake_op = { - "CW", 0x0000, 0x0000, nop, nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, - false, false, false, false, false}; + const DSPOPCTemplate fake_op = {"CW", 0x0000, 0x0000, DSPInterpreter::nop, + nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, + false, false, false, false, + false}; if (!opc) opc = &fake_op; diff --git a/Source/Core/Core/DSP/DSPInterpreter.cpp b/Source/Core/Core/DSP/DSPInterpreter.cpp index 852007570e..1f1bb3f7b3 100644 --- a/Source/Core/Core/DSP/DSPInterpreter.cpp +++ b/Source/Core/Core/DSP/DSPInterpreter.cpp @@ -4,17 +4,41 @@ // Refer to the license.txt file included. #include "Core/DSP/DSPInterpreter.h" + +#include "Common/CommonTypes.h" +#include "Common/Logging/Log.h" + #include "Core/DSP/DSPAnalyzer.h" #include "Core/DSP/DSPCore.h" -#include "Core/DSP/DSPHWInterface.h" -#include "Core/DSP/DSPIntUtil.h" #include "Core/DSP/DSPMemoryMap.h" #include "Core/DSP/DSPTables.h" namespace DSPInterpreter { -// NOTE: These have nothing to do with g_dsp.r.cr ! +namespace +{ +void ExecuteInstruction(const UDSPInstruction inst) +{ + const DSPOPCTemplate* opcode_template = GetOpTemplate(inst); + if (opcode_template->extended) + { + if ((inst >> 12) == 0x3) + extOpTable[inst & 0x7F]->intFunc(inst); + else + extOpTable[inst & 0xFF]->intFunc(inst); + } + + opcode_template->intFunc(inst); + + if (opcode_template->extended) + { + applyWriteBackLog(); + } +} +} // Anonymous namespace + +// NOTE: These have nothing to do with g_dsp.r.cr ! void WriteCR(u16 val) { // reset @@ -205,4 +229,13 @@ int RunCycles(int cycles) } } +void nop(const UDSPInstruction opc) +{ + // The real nop is 0. Anything else is bad. + if (opc == 0) + return; + + ERROR_LOG(DSPLLE, "LLE: Unrecognized opcode 0x%04x", opc); +} + } // namespace diff --git a/Source/Core/Core/DSP/DSPInterpreter.h b/Source/Core/Core/DSP/DSPInterpreter.h index dfa0dcc3ae..25153a449c 100644 --- a/Source/Core/Core/DSP/DSPInterpreter.h +++ b/Source/Core/Core/DSP/DSPInterpreter.h @@ -116,6 +116,7 @@ void mulxac(const UDSPInstruction opc); void mulxmv(const UDSPInstruction opc); void mulxmvz(const UDSPInstruction opc); void neg(const UDSPInstruction opc); +void nop(const UDSPInstruction opc); void notc(const UDSPInstruction opc); void nx(const UDSPInstruction opc); void orc(const UDSPInstruction opc); diff --git a/Source/Core/Core/DSP/DSPTables.cpp b/Source/Core/Core/DSP/DSPTables.cpp index ed638f5f1a..66f277be00 100644 --- a/Source/Core/Core/DSP/DSPTables.cpp +++ b/Source/Core/Core/DSP/DSPTables.cpp @@ -11,21 +11,12 @@ #include "Core/DSP/DSPInterpreter.h" #include "Core/DSP/DSPTables.h" -void nop(const UDSPInstruction opc) -{ - // The real nop is 0. Anything else is bad. - if (opc) - { - ERROR_LOG(DSPLLE, "LLE: Unrecognized opcode 0x%04x", opc); - } -} - // clang-format off const DSPOPCTemplate opcodes[] = { // # of parameters----+ {type, size, loc, lshift, mask} branch reads PC // instruction approximation // name opcode mask interpreter function JIT function size-V V param 1 param 2 param 3 extendable uncond. updates SR - {"NOP", 0x0000, 0xfffc, nop, &DSPEmitter::nop, 1, 0, {}, false, false, false, false, false}, // no operation + {"NOP", 0x0000, 0xfffc, DSPInterpreter::nop, &DSPEmitter::nop, 1, 0, {}, false, false, false, false, false}, // no operation {"DAR", 0x0004, 0xfffc, DSPInterpreter::dar, &DSPEmitter::dar, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false, false, false, false}, // $arD-- {"IAR", 0x0008, 0xfffc, DSPInterpreter::iar, &DSPEmitter::iar, 1, 1, {{P_REG, 1, 0, 0, 0x0003}}, false, false, false, false, false}, // $arD++ @@ -293,7 +284,7 @@ const DSPOPCTemplate opcodes[] = }; const DSPOPCTemplate cw = - {"CW", 0x0000, 0x0000, nop, nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, false, false, false, false, false}; + {"CW", 0x0000, 0x0000, DSPInterpreter::nop, nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, false, false, false, false, false}; // extended opcodes diff --git a/Source/Core/Core/DSP/DSPTables.h b/Source/Core/Core/DSP/DSPTables.h index 9413a125c0..28b67d7fec 100644 --- a/Source/Core/Core/DSP/DSPTables.h +++ b/Source/Core/Core/DSP/DSPTables.h @@ -54,8 +54,6 @@ enum partype_t #define OPTABLE_SIZE 0xffff + 1 #define EXT_OPTABLE_SIZE 0xff + 1 -void nop(const UDSPInstruction opc); - typedef void (*dspIntFunc)(const UDSPInstruction); typedef void (DSPEmitter::*dspJitFunc)(const UDSPInstruction); @@ -125,23 +123,3 @@ void zeroWriteBackLog(); void zeroWriteBackLogPreserveAcc(u8 acc); const DSPOPCTemplate* GetOpTemplate(const UDSPInstruction& inst); - -inline void ExecuteInstruction(const UDSPInstruction inst) -{ - const DSPOPCTemplate* tinst = GetOpTemplate(inst); - - if (tinst->extended) - { - if ((inst >> 12) == 0x3) - extOpTable[inst & 0x7F]->intFunc(inst); - else - extOpTable[inst & 0xFF]->intFunc(inst); - } - - tinst->intFunc(inst); - - if (tinst->extended) - { - applyWriteBackLog(); - } -}