mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #4570 from lioncash/dspemit
DSPEmitter: Minor cleanup
This commit is contained in:
commit
cd29d565c4
@ -251,8 +251,8 @@ int DSPCore_RunCycles(int cycles)
|
||||
}
|
||||
|
||||
g_cycles_left = cycles;
|
||||
DSPCompiledCode pExecAddr = (DSPCompiledCode)g_dsp_jit->enterDispatcher;
|
||||
pExecAddr();
|
||||
auto exec_addr = (DSPEmitter::DSPCompiledCode)g_dsp_jit->enterDispatcher;
|
||||
exec_addr();
|
||||
|
||||
if (g_dsp.reset_dspjit_codespace)
|
||||
g_dsp_jit->ClearIRAMandDSPJITCodespaceReset();
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "Core/DSP/Jit/DSPEmitter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
@ -17,40 +18,27 @@
|
||||
#include "Core/DSP/DSPMemoryMap.h"
|
||||
#include "Core/DSP/DSPTables.h"
|
||||
|
||||
#define MAX_BLOCK_SIZE 250
|
||||
#define DSP_IDLE_SKIP_CYCLES 0x1000
|
||||
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() : gpr(*this), storeIndex(-1), storeIndex2(-1)
|
||||
DSPEmitter::DSPEmitter()
|
||||
: blockLinks(MAX_BLOCKS), blockSize(MAX_BLOCKS), blocks(MAX_BLOCKS),
|
||||
compileSR{SR_INT_ENABLE | SR_EXT_INT_ENABLE}
|
||||
{
|
||||
AllocCodeSpace(COMPILED_CODE_SIZE);
|
||||
|
||||
blocks = new DSPCompiledCode[MAX_BLOCKS];
|
||||
blockLinks = new Block[MAX_BLOCKS];
|
||||
blockSize = new u16[MAX_BLOCKS];
|
||||
|
||||
compileSR = 0;
|
||||
compileSR |= SR_INT_ENABLE;
|
||||
compileSR |= SR_EXT_INT_ENABLE;
|
||||
|
||||
CompileDispatcher();
|
||||
stubEntryPoint = CompileStub();
|
||||
|
||||
// clear all of the block references
|
||||
for (int i = 0x0000; i < MAX_BLOCKS; i++)
|
||||
{
|
||||
blocks[i] = (DSPCompiledCode)stubEntryPoint;
|
||||
blockLinks[i] = nullptr;
|
||||
blockSize[i] = 0;
|
||||
}
|
||||
// Clear all of the block references
|
||||
std::fill(blocks.begin(), blocks.end(), (DSPCompiledCode)stubEntryPoint);
|
||||
}
|
||||
|
||||
DSPEmitter::~DSPEmitter()
|
||||
{
|
||||
delete[] blocks;
|
||||
delete[] blockLinks;
|
||||
delete[] blockSize;
|
||||
FreeCodeSpace();
|
||||
}
|
||||
|
||||
@ -408,7 +396,7 @@ void DSPEmitter::CompileDispatcher()
|
||||
|
||||
// Execute block. Cycles executed returned in EAX.
|
||||
MOVZX(64, 16, ECX, M(&g_dsp.pc));
|
||||
MOV(64, R(RBX), ImmPtr(blocks));
|
||||
MOV(64, R(RBX), ImmPtr(blocks.data()));
|
||||
JMPptr(MComplex(RBX, RCX, SCALE_8, 0));
|
||||
|
||||
returnDispatcher = GetCodePtr();
|
||||
|
@ -4,23 +4,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/x64ABI.h"
|
||||
#include "Common/x64Emitter.h"
|
||||
|
||||
#include "Core/DSP/DSPCommon.h"
|
||||
#include "Core/DSP/Jit/DSPJitRegCache.h"
|
||||
|
||||
#define COMPILED_CODE_SIZE 2097152
|
||||
#define MAX_BLOCKS 0x10000
|
||||
|
||||
typedef u32 (*DSPCompiledCode)();
|
||||
typedef const u8* Block;
|
||||
|
||||
class DSPEmitter : public Gen::X64CodeBlock
|
||||
{
|
||||
public:
|
||||
using DSPCompiledCode = u32 (*)();
|
||||
using Block = const u8*;
|
||||
|
||||
static constexpr size_t MAX_BLOCKS = 0x10000;
|
||||
|
||||
DSPEmitter();
|
||||
~DSPEmitter();
|
||||
|
||||
@ -243,20 +245,20 @@ public:
|
||||
const u8* returnDispatcher;
|
||||
u16 compilePC;
|
||||
u16 startAddr;
|
||||
Block* blockLinks;
|
||||
u16* blockSize;
|
||||
std::vector<Block> blockLinks;
|
||||
std::vector<u16> blockSize;
|
||||
std::list<u16> unresolvedJumps[MAX_BLOCKS];
|
||||
|
||||
DSPJitRegCache gpr;
|
||||
DSPJitRegCache gpr{*this};
|
||||
|
||||
private:
|
||||
DSPCompiledCode* blocks;
|
||||
std::vector<DSPCompiledCode> blocks;
|
||||
Block blockLinkEntry;
|
||||
u16 compileSR;
|
||||
|
||||
// The index of the last stored ext value (compile time).
|
||||
int storeIndex;
|
||||
int storeIndex2;
|
||||
int storeIndex = -1;
|
||||
int storeIndex2 = -1;
|
||||
|
||||
// Counts down.
|
||||
// int cycles;
|
||||
|
Loading…
Reference in New Issue
Block a user