JitArm64: Merge WriteExceptionExit.

This commit is contained in:
degasus 2016-03-02 09:05:20 +01:00
parent 55b9ce9b5b
commit 57d76cefb0
3 changed files with 39 additions and 63 deletions

View File

@ -133,7 +133,7 @@ void JitArm64::HLEFunction(UGeckoInstruction inst)
ARM64Reg WA = gpr.GetReg(); ARM64Reg WA = gpr.GetReg();
LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(npc)); LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(npc));
WriteExitDestInR(WA); WriteExit(WA);
} }
void JitArm64::DoNothing(UGeckoInstruction inst) void JitArm64::DoNothing(UGeckoInstruction inst)
@ -206,61 +206,7 @@ void JitArm64::WriteExit(u32 destination)
b->linkData.push_back(linkData); b->linkData.push_back(linkData);
} }
void JitArm64::WriteExceptionExit(ARM64Reg dest) void JitArm64::WriteExit(ARM64Reg Reg)
{
Cleanup();
DoDownCount();
ARM64Reg WA = gpr.GetReg();
LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(Exceptions));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
FixupBranch no_exceptions = CBZ(WA);
gpr.Unlock(WA);
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
MOVI2R(EncodeRegTo64(dest), (u64)&PowerPC::CheckExceptions);
BLR(EncodeRegTo64(dest));
LDR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
SetJumpTarget(no_exceptions);
if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock);
MOVI2R(EncodeRegTo64(dest), (u64)asm_routines.dispatcher);
BR(EncodeRegTo64(dest));
gpr.Unlock(dest);
}
void JitArm64::WriteExternalExceptionExit(ARM64Reg dest)
{
Cleanup();
DoDownCount();
ARM64Reg WA = gpr.GetReg();
LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(Exceptions));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
FixupBranch no_exceptions = CBZ(WA);
gpr.Unlock(WA);
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
MOVI2R(EncodeRegTo64(dest), (u64)&PowerPC::CheckExternalExceptions);
BLR(EncodeRegTo64(dest));
LDR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
SetJumpTarget(no_exceptions);
if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock);
MOVI2R(EncodeRegTo64(dest), (u64)asm_routines.dispatcher);
BR(EncodeRegTo64(dest));
gpr.Unlock(dest);
}
void JitArm64::WriteExitDestInR(ARM64Reg Reg)
{ {
STR(INDEX_UNSIGNED, Reg, X29, PPCSTATE_OFF(pc)); STR(INDEX_UNSIGNED, Reg, X29, PPCSTATE_OFF(pc));
Cleanup(); Cleanup();
@ -274,6 +220,37 @@ void JitArm64::WriteExitDestInR(ARM64Reg Reg)
gpr.Unlock(Reg); gpr.Unlock(Reg);
} }
void JitArm64::WriteExceptionExit(ARM64Reg dest, bool only_external)
{
Cleanup();
DoDownCount();
ARM64Reg WA = gpr.GetReg();
LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(Exceptions));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
FixupBranch no_exceptions = CBZ(WA);
gpr.Unlock(WA);
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
if (only_external)
MOVI2R(EncodeRegTo64(dest), (u64)&PowerPC::CheckExternalExceptions);
else
MOVI2R(EncodeRegTo64(dest), (u64)&PowerPC::CheckExceptions);
BLR(EncodeRegTo64(dest));
LDR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(npc));
STR(INDEX_UNSIGNED, dest, X29, PPCSTATE_OFF(pc));
SetJumpTarget(no_exceptions);
if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock);
MOVI2R(EncodeRegTo64(dest), (u64)asm_routines.dispatcher);
BR(EncodeRegTo64(dest));
gpr.Unlock(dest);
}
void JitArm64::DumpCode(const u8* start, const u8* end) void JitArm64::DumpCode(const u8* start, const u8* end)
{ {
std::string output = ""; std::string output = "";
@ -517,7 +494,7 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
gpr.Flush(FLUSH_MAINTAIN_STATE); gpr.Flush(FLUSH_MAINTAIN_STATE);
fpr.Flush(FLUSH_MAINTAIN_STATE); fpr.Flush(FLUSH_MAINTAIN_STATE);
MOVI2R(W30, ops[i].address); MOVI2R(W30, ops[i].address);
WriteExternalExceptionExit(W30); WriteExceptionExit(W30, true);
SwitchToNearCode(); SwitchToNearCode();
SetJumpTarget(exit); SetJumpTarget(exit);
gpr.Unlock(W30); gpr.Unlock(W30);
@ -549,7 +526,7 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
gpr.Flush(FLUSH_MAINTAIN_STATE); gpr.Flush(FLUSH_MAINTAIN_STATE);
fpr.Flush(FLUSH_MAINTAIN_STATE); fpr.Flush(FLUSH_MAINTAIN_STATE);
MOVI2R(WA, ops[i].address); MOVI2R(WA, ops[i].address);
WriteExternalExceptionExit(WA); WriteExceptionExit(WA, true);
SwitchToNearCode(); SwitchToNearCode();
SetJumpTarget(NoExtException); SetJumpTarget(NoExtException);
SetJumpTarget(exit); SetJumpTarget(exit);

View File

@ -237,9 +237,8 @@ private:
// Exits // Exits
void WriteExit(u32 destination); void WriteExit(u32 destination);
void WriteExceptionExit(Arm64Gen::ARM64Reg dest); void WriteExit(Arm64Gen::ARM64Reg dest);
void WriteExternalExceptionExit(ARM64Reg dest); void WriteExceptionExit(Arm64Gen::ARM64Reg dest, bool only_external = false);
void WriteExitDestInR(Arm64Gen::ARM64Reg dest);
FixupBranch JumpIfCRFieldBit(int field, int bit, bool jump_if_set); FixupBranch JumpIfCRFieldBit(int field, int bit, bool jump_if_set);

View File

@ -213,7 +213,7 @@ void JitArm64::bcctrx(UGeckoInstruction inst)
LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(spr[SPR_CTR])); LDR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(spr[SPR_CTR]));
AND(WA, WA, 30, 29); // Wipe the bottom 2 bits. AND(WA, WA, 30, 29); // Wipe the bottom 2 bits.
WriteExitDestInR(WA); WriteExit(WA);
} }
void JitArm64::bclrx(UGeckoInstruction inst) void JitArm64::bclrx(UGeckoInstruction inst)
@ -261,7 +261,7 @@ void JitArm64::bclrx(UGeckoInstruction inst)
gpr.Flush(FlushMode::FLUSH_MAINTAIN_STATE); gpr.Flush(FlushMode::FLUSH_MAINTAIN_STATE);
fpr.Flush(FlushMode::FLUSH_MAINTAIN_STATE); fpr.Flush(FlushMode::FLUSH_MAINTAIN_STATE);
WriteExitDestInR(WA); WriteExit(WA);
SwitchToNearCode(); SwitchToNearCode();