Core: Have R4300iInstruction in CRecompilerOpsBase

This commit is contained in:
zilmar 2023-12-21 10:34:03 +10:30
parent 8e3fb3e302
commit 6610ae3058
6 changed files with 43 additions and 18 deletions

View File

@ -11,6 +11,25 @@ R4300iInstruction::R4300iInstruction(uint32_t Address, uint32_t Instruction) :
m_Instruction.Value = Instruction;
}
R4300iInstruction & R4300iInstruction::operator=(const R4300iInstruction & Instr)
{
m_Address = Instr.m_Address;
m_Instruction.Value = Instr.m_Instruction.Value;
m_Name[0] = '\0';
m_Param[0] = '\0';
return *this;
}
const uint32_t & R4300iInstruction::Address() const
{
return m_Address;
}
const R4300iOpcode & R4300iInstruction::Opcode() const
{
return m_Instruction;
}
const char * R4300iInstruction::Name()
{
if (m_Name[0] == '\0')

View File

@ -6,7 +6,10 @@ class R4300iInstruction
{
public:
R4300iInstruction(uint32_t Address, uint32_t Instruction);
R4300iInstruction & operator=(const R4300iInstruction &);
const uint32_t & Address() const;
const R4300iOpcode & Opcode() const;
const char * Name();
const char * Param();
std::string NameAndParam();
@ -23,7 +26,6 @@ public:
private:
R4300iInstruction(void);
R4300iInstruction(const R4300iInstruction &);
R4300iInstruction & operator=(const R4300iInstruction &);
static const char * FPR_Type(uint32_t COP1OpCode);

View File

@ -10,6 +10,8 @@ CRecompilerOpsBase::CRecompilerOpsBase(CN64System & System, CCodeBlock & CodeBlo
m_TLB(System.m_TLB),
m_MMU(System.m_MMU_VM),
m_CodeBlock(CodeBlock),
m_Instruction(0, 0),
m_Opcode(m_Instruction.Opcode()),
m_Section(nullptr)
{
}

View File

@ -1,6 +1,6 @@
#pragma once
#include <Project64-core\N64System\Mips\R4300iOpcode.h>
#include <Project64-core\Settings\DebugSettings.h>
#include <Project64-core/N64System/Mips/R4300iInstruction.h>
#include <Project64-core/Settings/DebugSettings.h>
enum RecompilerBranchType
{
@ -58,7 +58,8 @@ protected:
CRegisters & m_Reg;
CTLB & m_TLB;
CCodeBlock & m_CodeBlock;
R4300iOpcode m_Opcode;
R4300iInstruction m_Instruction;
const R4300iOpcode & m_Opcode;
CCodeSection * m_Section;
private:

View File

@ -184,7 +184,7 @@ CX86RecompilerOps::CX86RecompilerOps(CN64System & m_System, CCodeBlock & CodeBlo
CRecompilerOpsBase(m_System, CodeBlock),
m_Assembler(CodeBlock),
m_RegWorkingSet(CodeBlock, m_Assembler),
m_CompilePC(0),
m_CompilePC(m_Instruction.Address()),
m_RegBeforeDelay(CodeBlock, m_Assembler),
m_EffectDelaySlot(false)
{
@ -198,7 +198,7 @@ void CX86RecompilerOps::PreCompileOpcode(void)
{
if (m_PipelineStage != PIPELINE_STAGE_DELAY_SLOT_DONE)
{
m_CodeBlock.Log(" %X %s", m_CompilePC, R4300iInstruction(m_CompilePC, m_Opcode.Value).NameAndParam().c_str());
m_CodeBlock.Log(" %X %s", m_CompilePC, m_Instruction.NameAndParam().c_str());
}
/*if (m_CompilePC == 0x803275F4 && m_PipelineStage == PIPELINE_STAGE_NORMAL)
{
@ -9477,11 +9477,12 @@ void CX86RecompilerOps::JumpToUnknown(CJumpInfo * JumpInfo)
void CX86RecompilerOps::SetCurrentPC(uint32_t ProgramCounter)
{
m_CompilePC = ProgramCounter;
if (!g_MMU->MemoryValue32(m_CompilePC, m_Opcode.Value))
uint32_t Value;
if (!g_MMU->MemoryValue32(ProgramCounter, Value))
{
g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD));
}
m_Instruction = R4300iInstruction(ProgramCounter, Value);
}
uint32_t CX86RecompilerOps::GetCurrentPC(void)
@ -9509,6 +9510,11 @@ const R4300iOpcode & CX86RecompilerOps::GetOpcode(void) const
return m_Opcode;
}
const R4300iInstruction & CX86RecompilerOps::GetInstruction(void) const
{
return m_Instruction;
}
void CX86RecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles)
{
if (!g_SyncSystem)
@ -9590,7 +9596,7 @@ void CX86RecompilerOps::CompileExecuteBP(void)
m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet, true, true);
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", CompilePC());
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", m_CompilePC);
if (g_SyncSystem)
{
m_Assembler.CallThis((uint32_t)g_BaseSystem, AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem", 4);
@ -9610,7 +9616,7 @@ void CX86RecompilerOps::CompileExecuteDelaySlotBP(void)
m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet, true, true);
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", CompilePC());
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", m_CompilePC);
if (g_SyncSystem)
{
m_Assembler.CallThis((uint32_t)g_BaseSystem, AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem", 4);
@ -9634,7 +9640,7 @@ void CX86RecompilerOps::OverflowDelaySlot(bool TestTimer)
}
else
{
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", CompilePC() + 4);
m_Assembler.MoveConstToVariable(&m_Reg.m_PROGRAM_COUNTER, "PROGRAM_COUNTER", m_CompilePC + 4);
}
m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "System->m_PipelineStage", PIPELINE_STAGE_JUMP);
if (g_SyncSystem)

View File

@ -241,6 +241,7 @@ public:
void SetNextStepType(PIPELINE_STAGE StepType);
PIPELINE_STAGE GetNextStepType(void);
const R4300iOpcode & GetOpcode(void) const;
const R4300iInstruction & GetInstruction(void) const;
void PreCompileOpcode(void);
void PostCompileOpcode(void);
void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason Reason);
@ -261,12 +262,6 @@ public:
return m_Assembler;
}
public:
uint32_t CompilePC()
{
return m_CompilePC;
}
private:
CX86RecompilerOps(const CX86RecompilerOps &);
CX86RecompilerOps & operator=(const CX86RecompilerOps &);
@ -304,7 +299,7 @@ private:
EXIT_LIST m_ExitInfo;
CX86Ops m_Assembler;
PIPELINE_STAGE m_PipelineStage;
uint32_t m_CompilePC;
const uint32_t & m_CompilePC;
CX86RegInfo m_RegWorkingSet;
CRegInfo m_RegBeforeDelay;
bool m_EffectDelaySlot;