Skip to content

Commit

Permalink
Core: Add break op to recompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Oct 10, 2022
1 parent fc247fd commit 481f1c5
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ void CAarch64RecompilerOps::SPECIAL_SYSCALL()
g_Notify->BreakPoint(__FILE__, __LINE__);
}

void CAarch64RecompilerOps::SPECIAL_BREAK()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}

void CAarch64RecompilerOps::SPECIAL_MFLO()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class CAarch64RecompilerOps
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_BREAK();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3170,6 +3170,11 @@ void CArmRecompilerOps::SPECIAL_SYSCALL()
m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
}

void CArmRecompilerOps::SPECIAL_BREAK()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}

void CArmRecompilerOps::SPECIAL_MFLO()
{
UnMap_GPR(m_Opcode.rd, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class CArmRecompilerOps :
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_BREAK();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
Expand Down
1 change: 1 addition & 0 deletions Source/Project64-core/N64System/Recompiler/CodeSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test)
case R4300i_SPECIAL_JALR: m_RecompilerOps->SPECIAL_JALR(); break;
case R4300i_SPECIAL_MFLO: m_RecompilerOps->SPECIAL_MFLO(); break;
case R4300i_SPECIAL_SYSCALL: m_RecompilerOps->SPECIAL_SYSCALL(); break;
case R4300i_SPECIAL_BREAK: m_RecompilerOps->SPECIAL_BREAK(); break;
case R4300i_SPECIAL_MTLO: m_RecompilerOps->SPECIAL_MTLO(); break;
case R4300i_SPECIAL_MFHI: m_RecompilerOps->SPECIAL_MFHI(); break;
case R4300i_SPECIAL_MTHI: m_RecompilerOps->SPECIAL_MTHI(); break;
Expand Down
1 change: 1 addition & 0 deletions Source/Project64-core/N64System/Recompiler/ExitInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum ExitReason
ExitReason_DoCPUAction,
ExitReason_COP1Unuseable,
ExitReason_DoSysCall,
ExitReason_Break,
ExitReason_TLBReadMiss,
ExitReason_TLBWriteMiss,
ExitReason_ResetRecompCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ void CX64RecompilerOps::SPECIAL_SYSCALL()
g_Notify->BreakPoint(__FILE__, __LINE__);
}

void CX64RecompilerOps::SPECIAL_BREAK()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}

void CX64RecompilerOps::SPECIAL_MFLO()
{
g_Notify->BreakPoint(__FILE__, __LINE__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class CX64RecompilerOps
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_BREAK();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
Expand Down
29 changes: 18 additions & 11 deletions Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4515,6 +4515,13 @@ void CX86RecompilerOps::SPECIAL_SYSCALL()
m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
}

void CX86RecompilerOps::SPECIAL_BREAK()
{
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, ExitReason_Break, true, nullptr);
m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
}

void CX86RecompilerOps::SPECIAL_MFLO()
{
if (m_Opcode.rd == 0)
Expand Down Expand Up @@ -9492,6 +9499,7 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
UpdateCounters(ExitRegSet, false, reason == ExitReason_Normal);
}

bool InDelaySlot = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
switch (reason)
{
case ExitReason_Normal:
Expand Down Expand Up @@ -9616,30 +9624,29 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
ExitCodeBlock();
break;
case ExitReason_DoSysCall:
{
bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 4);
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 8);
ExitCodeBlock();
break;
case ExitReason_Break:
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoBreakException), "CRegisters::DoBreakException", 8);
ExitCodeBlock();
break;
}
case ExitReason_COP1Unuseable:
{
bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
m_Assembler.PushImm32("1", 1);
m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay);
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException", 12);
ExitCodeBlock();
break;
}
case ExitReason_ResetRecompCode:
g_Notify->BreakPoint(__FILE__, __LINE__);
ExitCodeBlock();
break;
case ExitReason_TLBReadMiss:
m_Assembler.MoveVariableToX86reg(g_TLBLoadAddress, "g_TLBLoadAddress", CX86Ops::x86_EDX);
m_Assembler.Push(CX86Ops::x86_EDX);
m_Assembler.PushImm32(m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT);
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss", 12);
ExitCodeBlock();
break;
Expand All @@ -9648,7 +9655,7 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
ExitCodeBlock();
break;
case ExitReason_ExceptionOverflow:
m_Assembler.PushImm32(m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT);
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoOverflowException), "CRegisters::DoOverflowException", 12);
ExitCodeBlock();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class CX86RecompilerOps :
void SPECIAL_JR();
void SPECIAL_JALR();
void SPECIAL_SYSCALL();
void SPECIAL_BREAK();
void SPECIAL_MFLO();
void SPECIAL_MTLO();
void SPECIAL_MFHI();
Expand Down

0 comments on commit 481f1c5

Please sign in to comment.