RSP: change CRSPSystem::m_Recompiler from a pointer to a member and initialize it at creation of system

This commit is contained in:
zilmar 2024-08-29 07:49:40 +09:30
parent 2b7975280e
commit 96080bfdd2
6 changed files with 9 additions and 26 deletions

View File

@ -47,9 +47,10 @@ CRSPRecompiler::CRSPRecompiler(CRSPSystem & System) :
m_NextInstruction(RSPPIPELINE_NORMAL), m_NextInstruction(RSPPIPELINE_NORMAL),
m_IMEM(System.m_IMEM) m_IMEM(System.m_IMEM)
{ {
BuildRecompilerCPU();
} }
void BuildRecompilerCPU(void) void CRSPRecompiler::BuildRecompilerCPU(void)
{ {
RSP_Recomp_Opcode[0] = &CRSPRecompilerOps::SPECIAL; RSP_Recomp_Opcode[0] = &CRSPRecompilerOps::SPECIAL;
RSP_Recomp_Opcode[1] = &CRSPRecompilerOps::REGIMM; RSP_Recomp_Opcode[1] = &CRSPRecompilerOps::REGIMM;

View File

@ -38,6 +38,7 @@ private:
CRSPRecompiler(const CRSPRecompiler &); CRSPRecompiler(const CRSPRecompiler &);
CRSPRecompiler & operator=(const CRSPRecompiler &); CRSPRecompiler & operator=(const CRSPRecompiler &);
void BuildRecompilerCPU(void);
void CompilerLinkBlocks(void); void CompilerLinkBlocks(void);
void CompilerRSPBlock(void); void CompilerRSPBlock(void);
void LinkBranches(RSP_BLOCK * Block); void LinkBranches(RSP_BLOCK * Block);
@ -64,23 +65,16 @@ extern bool ChangedPC;
#define Low16BitAccum 4 #define Low16BitAccum 4
#define EntireAccum (Low16BitAccum | Middle16BitAccum | High16BitAccum) #define EntireAccum (Low16BitAccum | Middle16BitAccum | High16BitAccum)
bool WriteToAccum(int Location, int PC);
bool WriteToVectorDest(uint32_t DestReg, int PC);
bool UseRspFlags(int PC);
bool DelaySlotAffectBranch(uint32_t PC); bool DelaySlotAffectBranch(uint32_t PC);
bool CompareInstructions(uint32_t PC, RSPOpcode * Top, RSPOpcode * Bottom); bool CompareInstructions(uint32_t PC, RSPOpcode * Top, RSPOpcode * Bottom);
bool IsOpcodeBranch(uint32_t PC, RSPOpcode RspOp); bool IsOpcodeBranch(uint32_t PC, RSPOpcode RspOp);
bool IsOpcodeNop(uint32_t PC); bool IsOpcodeNop(uint32_t PC);
bool IsNextInstructionMmx(uint32_t PC);
bool IsRegisterConstant(uint32_t Reg, uint32_t * Constant); bool IsRegisterConstant(uint32_t Reg, uint32_t * Constant);
#define MainBuffer 0 #define MainBuffer 0
#define SecondaryBuffer 1 #define SecondaryBuffer 1
void BuildRecompilerCPU(void);
void CompilerToggleBuffer(void); void CompilerToggleBuffer(void);
typedef struct typedef struct

View File

@ -14,8 +14,6 @@ class RSPRegisterHandler;
UDWORD EleSpec[16], Indx[16]; UDWORD EleSpec[16], Indx[16];
uint32_t RSP_Running; uint32_t RSP_Running;
void BuildRecompilerCPU(void);
CriticalSection g_CPUCriticalSection; CriticalSection g_CPUCriticalSection;
uint32_t Mfc0Count, SemaphoreExit = 0; uint32_t Mfc0Count, SemaphoreExit = 0;
RSPCpuType g_CPUCore = InterpreterCPU; RSPCpuType g_CPUCore = InterpreterCPU;
@ -24,14 +22,6 @@ void SetCPU(RSPCpuType core)
{ {
CGuard Guard(g_CPUCriticalSection); CGuard Guard(g_CPUCriticalSection);
g_CPUCore = core; g_CPUCore = core;
switch (core)
{
case RecompilerCPU:
BuildRecompilerCPU();
break;
case InterpreterCPU:
break;
}
} }
void Build_RSP(void) void Build_RSP(void)

View File

@ -41,8 +41,8 @@ void RSPRegisterHandlerPlugin::SetHalt(void)
void RSPRegisterHandlerPlugin::DmaReadDone(uint32_t End) void RSPRegisterHandlerPlugin::DmaReadDone(uint32_t End)
{ {
if (g_CPUCore == RecompilerCPU && (*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0 && m_System.m_Recompiler != nullptr) if (g_CPUCore == RecompilerCPU && (*RSPInfo.SP_MEM_ADDR_REG & 0x1000) != 0 && g_CPUCore == RecompilerCPU)
{ {
m_System.m_Recompiler->SetJumpTable(End); m_System.m_Recompiler.SetJumpTable(End);
} }
} }

View File

@ -10,7 +10,7 @@
CRSPSystem RSPSystem; CRSPSystem RSPSystem;
CRSPSystem::CRSPSystem() : CRSPSystem::CRSPSystem() :
m_Recompiler(nullptr), m_Recompiler(*this),
m_RSPRegisterHandler(nullptr), m_RSPRegisterHandler(nullptr),
m_Op(*this), m_Op(*this),
m_NextInstruction(RSPPIPELINE_NORMAL), m_NextInstruction(RSPPIPELINE_NORMAL),
@ -101,10 +101,7 @@ void CRSPSystem::RomClosed(void)
void CRSPSystem::RunRecompiler(void) void CRSPSystem::RunRecompiler(void)
{ {
CRSPRecompiler Recompiler(RSPSystem); m_Recompiler.RunCPU();
m_Recompiler = &Recompiler;
Recompiler.RunCPU();
m_Recompiler = nullptr;
} }
uint32_t CRSPSystem::RunInterpreterCPU(uint32_t Cycles) uint32_t CRSPSystem::RunInterpreterCPU(uint32_t Cycles)

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <Project64-rsp-core/RSPInfo.h> #include <Project64-rsp-core/RSPInfo.h>
#include <Project64-rsp-core/Recompiler/RspRecompilerCPU.h>
#include <Project64-rsp-core/cpu/RSPInterpreterOps.h> #include <Project64-rsp-core/cpu/RSPInterpreterOps.h>
#include <Project64-rsp-core/cpu/RSPRegisters.h> #include <Project64-rsp-core/cpu/RSPRegisters.h>
#include <Project64-rsp-core/cpu/RspPipelineStage.h> #include <Project64-rsp-core/cpu/RspPipelineStage.h>
@ -34,7 +35,7 @@ private:
CRSPSystem(const CRSPSystem &); CRSPSystem(const CRSPSystem &);
CRSPSystem & operator=(const CRSPSystem &); CRSPSystem & operator=(const CRSPSystem &);
CRSPRecompiler * m_Recompiler; CRSPRecompiler m_Recompiler;
RSPRegisterHandlerPlugin * m_RSPRegisterHandler; RSPRegisterHandlerPlugin * m_RSPRegisterHandler;
CRSPRegisters m_Reg; CRSPRegisters m_Reg;
RSPOp m_Op; RSPOp m_Op;