Jit64: Refactor WriteIdleExit helper.

This commit is contained in:
degasus 2019-04-16 08:53:44 +02:00
parent b8b4b4a383
commit 55abe1a085
4 changed files with 14 additions and 20 deletions

View File

@ -646,6 +646,15 @@ void Jit64::WriteRfiExitDestInRSCRATCH()
JMP(asm_routines.dispatcher, true); JMP(asm_routines.dispatcher, true);
} }
void Jit64::WriteIdleExit(u32 destination)
{
ABI_PushRegistersAndAdjustStack({}, 0);
ABI_CallFunction(CoreTiming::Idle);
ABI_PopRegistersAndAdjustStack({}, 0);
MOV(32, PPCSTATE(pc), Imm32(destination));
WriteExceptionExit();
}
void Jit64::WriteExceptionExit() void Jit64::WriteExceptionExit()
{ {
Cleanup(); Cleanup();

View File

@ -84,6 +84,7 @@ public:
void WriteExceptionExit(); void WriteExceptionExit();
void WriteExternalExceptionExit(); void WriteExternalExceptionExit();
void WriteRfiExitDestInRSCRATCH(); void WriteRfiExitDestInRSCRATCH();
void WriteIdleExit(u32 destination);
bool Cleanup(); bool Cleanup();
void GenerateConstantOverflow(bool overflow); void GenerateConstantOverflow(bool overflow);

View File

@ -93,11 +93,7 @@ void Jit64::bx(UGeckoInstruction inst)
#endif #endif
if (js.op->branchIsIdleLoop) if (js.op->branchIsIdleLoop)
{ {
ABI_PushRegistersAndAdjustStack({}, 0); WriteIdleExit(js.op->branchTo);
ABI_CallFunction(CoreTiming::Idle);
ABI_PopRegistersAndAdjustStack({}, 0);
MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo));
WriteExceptionExit();
} }
else else
{ {
@ -159,11 +155,7 @@ void Jit64::bcx(UGeckoInstruction inst)
if (js.op->branchIsIdleLoop) if (js.op->branchIsIdleLoop)
{ {
ABI_PushRegistersAndAdjustStack({}, 0); WriteIdleExit(js.op->branchTo);
ABI_CallFunction(CoreTiming::Idle);
ABI_PopRegistersAndAdjustStack({}, 0);
MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo));
WriteExceptionExit();
} }
else else
{ {
@ -288,11 +280,7 @@ void Jit64::bclrx(UGeckoInstruction inst)
if (js.op->branchIsIdleLoop) if (js.op->branchIsIdleLoop)
{ {
ABI_PushRegistersAndAdjustStack({}, 0); WriteIdleExit(js.op->branchTo);
ABI_CallFunction(CoreTiming::Idle);
ABI_PopRegistersAndAdjustStack({}, 0);
MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo));
WriteExceptionExit();
} }
else else
{ {

View File

@ -368,11 +368,7 @@ void Jit64::DoMergedBranch()
if (next.LK) if (next.LK)
MOV(32, PPCSTATE(spr[SPR_LR]), Imm32(nextPC + 4)); MOV(32, PPCSTATE(spr[SPR_LR]), Imm32(nextPC + 4));
ABI_PushRegistersAndAdjustStack({}, 0); WriteIdleExit(js.op[1].branchTo);
ABI_CallFunction(CoreTiming::Idle);
ABI_PopRegistersAndAdjustStack({}, 0);
MOV(32, PPCSTATE(pc), Imm32(js.op[1].branchTo));
WriteExceptionExit();
} }
else if (next.OPCD == 16) // bcx else if (next.OPCD == 16) // bcx
{ {