DSP: Namespace the JIT

This commit is contained in:
Lioncash 2016-12-28 18:45:12 -05:00
parent 10b4f6a250
commit c79cc3f470
16 changed files with 137 additions and 10 deletions

View File

@ -29,7 +29,7 @@ DSPBreakpoints g_dsp_breakpoints;
static DSPCoreState core_state = DSPCORE_STOP;
u16 g_cycles_left = 0;
bool g_init_hax = false;
std::unique_ptr<DSPEmitter> g_dsp_jit;
std::unique_ptr<DSP::JIT::x86::DSPEmitter> g_dsp_jit;
std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
static Common::Event step_event;
@ -148,7 +148,7 @@ bool DSPCore_Init(const DSPInitOptions& opts)
// Initialize JIT, if necessary
if (opts.core_type == DSPInitOptions::CORE_JIT)
g_dsp_jit = std::make_unique<DSPEmitter>();
g_dsp_jit = std::make_unique<DSP::JIT::x86::DSPEmitter>();
g_dsp_cap.reset(opts.capture_logger);
@ -251,7 +251,7 @@ int DSPCore_RunCycles(int cycles)
}
g_cycles_left = cycles;
auto exec_addr = (DSPEmitter::DSPCompiledCode)g_dsp_jit->enterDispatcher;
auto exec_addr = (DSP::JIT::x86::DSPEmitter::DSPCompiledCode)g_dsp_jit->enterDispatcher;
exec_addr();
if (g_dsp.reset_dspjit_codespace)

View File

@ -14,7 +14,16 @@
#include "Core/DSP/DSPBreakpoints.h"
#include "Core/DSP/DSPCaptureLogger.h"
namespace DSP
{
namespace JIT
{
namespace x86
{
class DSPEmitter;
}
}
}
enum : u32
{
@ -302,7 +311,7 @@ extern SDSP g_dsp;
extern DSPBreakpoints g_dsp_breakpoints;
extern u16 g_cycles_left;
extern bool g_init_hax;
extern std::unique_ptr<DSPEmitter> g_dsp_jit;
extern std::unique_ptr<DSP::JIT::x86::DSPEmitter> g_dsp_jit;
extern std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
struct DSPInitOptions

View File

@ -12,6 +12,8 @@
#include "Core/DSP/Interpreter/DSPInterpreter.h"
#include "Core/DSP/Jit/DSPEmitter.h"
using DSP::JIT::x86::DSPEmitter;
// clang-format off
const DSPOPCTemplate opcodes[] =
{

View File

@ -66,7 +66,7 @@ struct param2_t
struct DSPOPCTemplate
{
using InterpreterFunction = void (*)(UDSPInstruction);
using JITFunction = void (DSPEmitter::*)(UDSPInstruction);
using JITFunction = void (DSP::JIT::x86::DSPEmitter::*)(UDSPInstruction);
const char* name;
u16 opcode;

View File

@ -18,12 +18,18 @@
#include "Core/DSP/DSPMemoryMap.h"
#include "Core/DSP/DSPTables.h"
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
constexpr size_t COMPILED_CODE_SIZE = 2097152;
constexpr size_t MAX_BLOCK_SIZE = 250;
constexpr u16 DSP_IDLE_SKIP_CYCLES = 0x1000;
using namespace Gen;
DSPEmitter::DSPEmitter()
: blockLinks(MAX_BLOCKS), blockSize(MAX_BLOCKS), blocks(MAX_BLOCKS),
compileSR{SR_INT_ENABLE | SR_EXT_INT_ENABLE}
@ -415,3 +421,7 @@ void DSPEmitter::CompileDispatcher()
ABI_PopRegistersAndAdjustStack(registers_used, 8);
RET();
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -15,6 +15,12 @@
#include "Core/DSP/DSPCommon.h"
#include "Core/DSP/Jit/DSPJitRegCache.h"
namespace DSP
{
namespace JIT
{
namespace x86
{
class DSPEmitter : public Gen::X64CodeBlock
{
public:
@ -281,3 +287,7 @@ private:
void get_ax_h(int _reg, Gen::X64Reg acc = Gen::EAX);
void get_long_acc(int _reg, Gen::X64Reg acc = Gen::EAX);
};
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -12,6 +12,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// CLR $acR
// 1000 r001 xxxx xxxx
// Clears accumulator $acR
@ -1672,6 +1678,6 @@ void DSPEmitter::asrnr(const UDSPInstruction opc)
}
}
//} // namespace
//
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -12,6 +12,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
template <void (*jitCode)(const UDSPInstruction, DSPEmitter&)>
static void ReJitConditional(const UDSPInstruction opc, DSPEmitter& emitter)
{
@ -452,3 +458,7 @@ void DSPEmitter::bloopi(const UDSPInstruction opc)
WriteBranchExit(*this);
}
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -9,6 +9,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// In: RAX: s64 _Value
// Clobbers RDX
void DSPEmitter::Update_SR_Register(Gen::X64Reg val)
@ -164,3 +170,7 @@ void DSPEmitter::Update_SR_Register16_OverS32(Gen::X64Reg val)
// AND(32, R(val), Imm32(0xc0000000));
Update_SR_Register16(val);
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -25,6 +25,12 @@ using namespace Gen;
sign extension.
*/
namespace DSP
{
namespace JIT
{
namespace x86
{
// DR $arR
// xxxx xxxx 0000 01rr
// Decrement addressing register $arR.
@ -691,3 +697,7 @@ void DSPEmitter::popExtValueToReg()
storeIndex2 = -1;
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -13,6 +13,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// SRS @M, $(0x18+S)
// 0010 1sss mmmm mmmm
// Move value from register $(0x18+D) to data memory pointed by address
@ -349,3 +355,7 @@ void DSPEmitter::ilrrn(const UDSPInstruction opc)
dsp_conditional_extend_accum(dreg + DSP_REG_ACM0);
increase_addr_reg(reg, reg);
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -11,6 +11,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// MRR $D, $S
// 0001 11dd ddds ssss
// Move value from register $S to register $D.
@ -191,3 +197,7 @@ void DSPEmitter::srbith(const UDSPInstruction opc)
break;
}
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -13,6 +13,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// Returns s64 in RAX
// In: RCX = s16 a, RAX = s16 b
void DSPEmitter::multiply()
@ -770,3 +776,7 @@ void DSPEmitter::msub(const UDSPInstruction opc)
// dsp_set_long_prod(prod);
set_long_prod();
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -15,6 +15,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// Ordered in order of prefered use.
// Not all of these are actually available
const std::array<X64Reg, 15> DSPJitRegCache::m_allocation_order = {
@ -1008,3 +1014,7 @@ void DSPJitRegCache::PutXReg(X64Reg reg)
xregs[reg].guest_reg = DSP_REG_NONE;
}
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -7,6 +7,12 @@
#include <array>
#include "Common/x64Emitter.h"
namespace DSP
{
namespace JIT
{
namespace x86
{
class DSPEmitter;
enum DSPJitRegSpecial
@ -179,3 +185,7 @@ private:
int use_ctr;
};
} // namespace x86
} // namespace JIT
} // namespace DSP

View File

@ -10,6 +10,12 @@
using namespace Gen;
namespace DSP
{
namespace JIT
{
namespace x86
{
// clobbers:
// EAX = (s8)g_dsp.reg_stack_ptr[stack_reg]
// expects:
@ -806,3 +812,7 @@ void DSPEmitter::get_ax_h(int _reg, X64Reg axh)
// return (s16)g_dsp.r[DSP_REG_AXH0 + _reg];
gpr.ReadReg(_reg + DSP_REG_AXH0, axh, SIGN);
}
} // namespace x86
} // namespace JIT
} // namespace DSP