DSP: Replace x64 JIT pointer with a pointer to an architecture-agnostic base

This adds a base class that is used to replace the concrete instance of
the x64 JIT pointer within DSPCore. This fully removes the direct use
(read: non-ifdefed) usage of x86-64-specifics within the main DSP code.

Said base can also be used for creating JITs for other architectures,
such as AArch64, etc.
This commit is contained in:
Lioncash committed 2018-06-21 05:20:22 -04:00
1 parent 8b68a7d88a
commit b7301bee29
9 files changed
+88 -25

No files matched your search

+3 -4
View File
@@ -22,8 +22,7 @@
#include "Core/DSP/DSPHost.h"
#include "Core/DSP/Interpreter/DSPIntUtil.h"
#include "Core/DSP/Interpreter/DSPInterpreter.h"
#include "Core/DSP/Jit/x64/DSPEmitter.h"
#include "Core/HW/DSP.h"
#include "Core/DSP/Jit/DSPEmitterBase.h"
namespace DSP
{
@@ -31,7 +30,7 @@ SDSP g_dsp;
DSPBreakpoints g_dsp_breakpoints;
static State core_state = State::Stopped;
bool g_init_hax = false;
std::unique_ptr<JIT::x64::DSPEmitter> g_dsp_jit;
std::unique_ptr<JIT::DSPEmitter> g_dsp_jit;
std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
static Common::Event step_event;
@@ -172,7 +171,7 @@ bool DSPCore_Init(const DSPInitOptions& opts)
// Initialize JIT, if necessary
if (opts.core_type == DSPInitOptions::CoreType::JIT64)
g_dsp_jit = std::make_unique<JIT::x64::DSPEmitter>();
g_dsp_jit = JIT::CreateDSPEmitter();
g_dsp_cap.reset(opts.capture_logger);
+1 -4
View File
@@ -20,11 +20,8 @@ class Accelerator;
namespace JIT
{
namespace x64
{
class DSPEmitter;
}
}
enum : u32
{
@@ -317,7 +314,7 @@ struct SDSP
extern SDSP g_dsp;
extern DSPBreakpoints g_dsp_breakpoints;
extern bool g_init_hax;
extern std::unique_ptr<JIT::x64::DSPEmitter> g_dsp_jit;
extern std::unique_ptr<JIT::DSPEmitter> g_dsp_jit;
extern std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
struct DSPInitOptions
@@ -0,0 +1,23 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/DSP/Jit/DSPEmitterBase.h"
#if defined(_M_X86) || defined(_M_X86_64)
#include "Core/DSP/Jit/x64/DSPEmitter.h"
#endif
namespace DSP::JIT
{
DSPEmitter::~DSPEmitter() = default;
std::unique_ptr<DSPEmitter> CreateDSPEmitter()
{
#if defined(_M_X86) || defined(_M_X86_64)
return std::make_unique<x64::DSPEmitter>();
#else
return std::make_unique<DSPEmitterNull>();
#endif
}
} // namespace DSP::JIT
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include "Common/CommonTypes.h"
class PointerWrap;
namespace DSP::JIT
{
class DSPEmitter
{
public:
virtual ~DSPEmitter();
virtual u16 RunCycles(u16 cycles) = 0;
virtual void ClearIRAM() = 0;
virtual void DoState(PointerWrap& p) = 0;
};
class DSPEmitterNull final : public DSPEmitter
{
public:
u16 RunCycles(u16) override { return 0; }
void ClearIRAM() override {}
void DoState(PointerWrap&) override {}
};
std::unique_ptr<DSPEmitter> CreateDSPEmitter();
} // namespace DSP::JIT
+6 -6
View File
@@ -14,6 +14,7 @@
#include "Common/x64Emitter.h"
#include "Core/DSP/DSPCommon.h"
#include "Core/DSP/Jit/DSPEmitterBase.h"
#include "Core/DSP/Jit/x64/DSPJitRegCache.h"
class PointerWrap;
@@ -24,7 +25,7 @@ enum class StackRegister;
namespace JIT::x64
{
class DSPEmitter : public Gen::X64CodeBlock
class DSPEmitter final : public JIT::DSPEmitter, public Gen::X64CodeBlock
{
public:
using DSPCompiledCode = u32 (*)();
@@ -33,14 +34,13 @@ public:
static constexpr size_t MAX_BLOCKS = 0x10000;
DSPEmitter();
~DSPEmitter();
~DSPEmitter() override;
u16 RunCycles(u16 cycles);
void DoState(PointerWrap& p);
u16 RunCycles(u16 cycles) override;
void DoState(PointerWrap& p) override;
void ClearIRAM() override;
void EmitInstruction(UDSPInstruction inst);
void ClearIRAM();
void ClearIRAMandDSPJITCodespaceReset();
void CompileDispatcher();