DSPTables: Move interpreter specifics to DSPInterpreter

This commit is contained in:
Lioncash 2016-12-21 15:03:52 -05:00
parent a5e555e609
commit 9131b994bb
5 changed files with 46 additions and 40 deletions

View File

@ -3,6 +3,8 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "Core/DSP/DSPDisassembler.h"
#include <algorithm> #include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
@ -12,7 +14,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/DSP/DSPDisassembler.h" #include "Core/DSP/DSPInterpreter.h"
#include "Core/DSP/DSPTables.h" #include "Core/DSP/DSPTables.h"
DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(settings) DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(settings)
@ -192,9 +194,10 @@ bool DSPDisassembler::DisassembleOpcode(const u16* binbuf, int base_addr, int pa
break; break;
} }
} }
const DSPOPCTemplate fake_op = { const DSPOPCTemplate fake_op = {"CW", 0x0000, 0x0000, DSPInterpreter::nop,
"CW", 0x0000, 0x0000, nop, nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, nullptr, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}},
false, false, false, false, false}; false, false, false, false,
false};
if (!opc) if (!opc)
opc = &fake_op; opc = &fake_op;

View File

@ -4,17 +4,41 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "Core/DSP/DSPInterpreter.h" #include "Core/DSP/DSPInterpreter.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/DSP/DSPAnalyzer.h" #include "Core/DSP/DSPAnalyzer.h"
#include "Core/DSP/DSPCore.h" #include "Core/DSP/DSPCore.h"
#include "Core/DSP/DSPHWInterface.h"
#include "Core/DSP/DSPIntUtil.h"
#include "Core/DSP/DSPMemoryMap.h" #include "Core/DSP/DSPMemoryMap.h"
#include "Core/DSP/DSPTables.h" #include "Core/DSP/DSPTables.h"
namespace DSPInterpreter 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) void WriteCR(u16 val)
{ {
// reset // 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 } // namespace

View File

@ -116,6 +116,7 @@ void mulxac(const UDSPInstruction opc);
void mulxmv(const UDSPInstruction opc); void mulxmv(const UDSPInstruction opc);
void mulxmvz(const UDSPInstruction opc); void mulxmvz(const UDSPInstruction opc);
void neg(const UDSPInstruction opc); void neg(const UDSPInstruction opc);
void nop(const UDSPInstruction opc);
void notc(const UDSPInstruction opc); void notc(const UDSPInstruction opc);
void nx(const UDSPInstruction opc); void nx(const UDSPInstruction opc);
void orc(const UDSPInstruction opc); void orc(const UDSPInstruction opc);

View File

@ -11,21 +11,12 @@
#include "Core/DSP/DSPInterpreter.h" #include "Core/DSP/DSPInterpreter.h"
#include "Core/DSP/DSPTables.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 // clang-format off
const DSPOPCTemplate opcodes[] = const DSPOPCTemplate opcodes[] =
{ {
// # of parameters----+ {type, size, loc, lshift, mask} branch reads PC // instruction approximation // # 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 // 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-- {"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++ {"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 = 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 // extended opcodes

View File

@ -54,8 +54,6 @@ enum partype_t
#define OPTABLE_SIZE 0xffff + 1 #define OPTABLE_SIZE 0xffff + 1
#define EXT_OPTABLE_SIZE 0xff + 1 #define EXT_OPTABLE_SIZE 0xff + 1
void nop(const UDSPInstruction opc);
typedef void (*dspIntFunc)(const UDSPInstruction); typedef void (*dspIntFunc)(const UDSPInstruction);
typedef void (DSPEmitter::*dspJitFunc)(const UDSPInstruction); typedef void (DSPEmitter::*dspJitFunc)(const UDSPInstruction);
@ -125,23 +123,3 @@ void zeroWriteBackLog();
void zeroWriteBackLogPreserveAcc(u8 acc); void zeroWriteBackLogPreserveAcc(u8 acc);
const DSPOPCTemplate* GetOpTemplate(const UDSPInstruction& inst); 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();
}
}