Core: Convert GenerateOverflowException to TriggerException

This commit is contained in:
zilmar 2023-05-18 11:05:27 +09:30
parent 69fd74ba56
commit 59a1277bed
5 changed files with 10 additions and 36 deletions

View File

@ -795,7 +795,7 @@ void R4300iOp::ADDI()
int32_t sum = rs + imm;
if ((~(rs ^ imm) & (rs ^ sum)) & 0x80000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rt].DW = sum;
@ -930,7 +930,7 @@ void R4300iOp::DADDI()
int64_t sum = rs + imm;
if ((~(rs ^ imm) & (rs ^ sum)) & 0x8000000000000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rt].DW = sum;
@ -1479,7 +1479,7 @@ void R4300iOp::SPECIAL_ADD()
int32_t sum = rs + rt;
if ((~(rs ^ rt) & (rs ^ sum)) & 0x80000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rd].DW = sum;
@ -1498,7 +1498,7 @@ void R4300iOp::SPECIAL_SUB()
if (((rs ^ rt) & (rs ^ sub)) & 0x80000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rd].DW = sub;
@ -1566,7 +1566,7 @@ void R4300iOp::SPECIAL_DADD()
int64_t sum = rs + rt;
if ((~(rs ^ rt) & (rs ^ sum)) & 0x8000000000000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rd].DW = sum;
@ -1585,7 +1585,7 @@ void R4300iOp::SPECIAL_DSUB()
if (((rs ^ rt) & (rs ^ sub)) & 0x8000000000000000)
{
GenerateOverflowException();
g_Reg->TriggerException(EXC_OV);
return;
}
_GPR[m_Opcode.rd].DW = sub;
@ -3118,13 +3118,6 @@ void R4300iOp::GenerateAddressErrorException(uint64_t VAddr, bool FromRead)
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);
}
void R4300iOp::GenerateOverflowException(void)
{
g_Reg->DoOverflowException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP);
g_System->m_PipelineStage = PIPELINE_STAGE_JUMP;
g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);
}
void R4300iOp::GenerateTLBReadException(uint64_t VAddr, const char * function)
{
if (bShowTLBMisses())

View File

@ -251,7 +251,6 @@ protected:
static Func Jump_CoP1_L[64];
static void GenerateAddressErrorException(uint64_t VAddr, bool FromRead);
static void GenerateOverflowException(void);
static void GenerateTLBReadException(uint64_t VAddr, const char * function);
static void GenerateTLBWriteException(uint64_t VAddr, const char * function);
static bool TestCop1UsableException(void);

View File

@ -730,24 +730,6 @@ void CRegisters::DoIllegalInstructionException(bool DelaySlot)
STATUS_REGISTER |= STATUS_EXL;
}
void CRegisters::DoOverflowException(bool DelaySlot)
{
CAUSE_REGISTER.ExceptionCode = EXC_OV;
CAUSE_REGISTER.CoprocessorUnitNumber = 0;
if (DelaySlot)
{
CAUSE_REGISTER.BranchDelay = 1;
EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER - 4);
}
else
{
CAUSE_REGISTER.BranchDelay = 0;
EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER);
}
m_PROGRAM_COUNTER = 0x80000180;
STATUS_REGISTER |= STATUS_EXL;
}
void CRegisters::DoTLBReadMiss(bool DelaySlot, uint64_t BadVaddr)
{
CAUSE_REGISTER.ExceptionCode = EXC_RMISS;

View File

@ -406,11 +406,9 @@ public:
void DoAddressError(bool DelaySlot, uint64_t BadVaddr, bool FromRead);
void DoBreakException(bool DelaySlot);
void DoFloatingPointException(bool DelaySlot);
void DoTrapException(bool DelaySlot);
void DoCopUnusableException(bool DelaySlot, int32_t Coprocessor);
bool DoIntrException(bool DelaySlot);
void DoIllegalInstructionException(bool DelaySlot);
void DoOverflowException(bool DelaySlot);
void DoTLBReadMiss(bool DelaySlot, uint64_t BadVaddr);
void DoTLBWriteMiss(bool DelaySlot, uint64_t BadVaddr);
void FixFpuLocations();

View File

@ -9505,8 +9505,10 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
ExitCodeBlock();
break;
case ExitReason_ExceptionOverflow:
m_Assembler.PushImm32(InDelaySlot ? "true" : "false", InDelaySlot);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoOverflowException), "CRegisters::DoOverflowException", 12);
m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "System->m_PipelineStage", m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT ? PIPELINE_STAGE_JUMP : PIPELINE_STAGE_NORMAL);
m_Assembler.push(0);
m_Assembler.PushImm32("EXC_OV", EXC_OV);
m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12);
ExitCodeBlock();
break;
case ExitReason_AddressErrorExceptionRead32: