diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.h b/Source/Core/Core/PowerPC/JitArm64/Jit.h index 34f25c04c3..b029f545cc 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.h +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.h @@ -235,7 +235,8 @@ protected: // jumps to the returned FixupBranch. Clobbers tmp and the 17 lower bits of addr_out. Arm64Gen::FixupBranch BATAddressLookup(Arm64Gen::ARM64Reg addr_out, Arm64Gen::ARM64Reg addr_in, Arm64Gen::ARM64Reg tmp, const void* bat_table); - Arm64Gen::FixupBranch CheckIfSafeAddress(Arm64Gen::ARM64Reg addr); + Arm64Gen::FixupBranch CheckIfSafeAddress(Arm64Gen::ARM64Reg addr, Arm64Gen::ARM64Reg tmp1, + Arm64Gen::ARM64Reg tmp2); void DoJit(u32 em_address, JitBlock* b, u32 nextPC); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp index de42f5811f..11da7bb923 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp @@ -10,6 +10,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" +#include "Common/MathUtil.h" #include "Common/StringUtil.h" #include "Common/Swap.h" @@ -62,7 +63,12 @@ void JitArm64::EmitBackpatchRoutine(u32 flags, bool fastmem, bool do_farcode, AR if (fastmem) { if (do_farcode && emitting_routine) - slowmem_fixup = CheckIfSafeAddress(addr); + { + const ARM64Reg temp1 = flags & BackPatchInfo::FLAG_STORE ? ARM64Reg::W0 : ARM64Reg::W3; + const ARM64Reg temp2 = ARM64Reg::W2; + + slowmem_fixup = CheckIfSafeAddress(addr, temp1, temp2); + } if ((flags & BackPatchInfo::FLAG_STORE) && (flags & BackPatchInfo::FLAG_FLOAT)) { diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp index 3d18b977bb..50a727d926 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStore.cpp @@ -288,11 +288,15 @@ FixupBranch JitArm64::BATAddressLookup(ARM64Reg addr_out, ARM64Reg addr_in, ARM6 return fail; } -FixupBranch JitArm64::CheckIfSafeAddress(Arm64Gen::ARM64Reg addr) +FixupBranch JitArm64::CheckIfSafeAddress(Arm64Gen::ARM64Reg addr, Arm64Gen::ARM64Reg tmp1, + Arm64Gen::ARM64Reg tmp2) { - // FIXME: This doesn't correctly account for the BAT configuration. - TST(addr, LogicalImm(0x0c000000, 32)); - FixupBranch pass = B(CC_EQ); + tmp2 = EncodeRegTo64(tmp2); + + MOVP2R(tmp2, PowerPC::dbat_table.data()); + LSR(tmp1, addr, PowerPC::BAT_INDEX_SHIFT); + LDR(tmp1, tmp2, ArithOption(tmp1, true)); + FixupBranch pass = TBNZ(tmp1, IntLog2(PowerPC::BAT_PHYSICAL_BIT)); FixupBranch fail = B(); SetJumpTarget(pass); return fail; diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStorePaired.cpp index dcbbd1b686..141db6f487 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_LoadStorePaired.cpp @@ -40,7 +40,7 @@ void JitArm64::psq_lXX(UGeckoInstruction inst) fpr.Lock(ARM64Reg::Q0); if (!js.assumeNoPairedQuantize) { - gpr.Lock(ARM64Reg::W1, ARM64Reg::W2); + gpr.Lock(ARM64Reg::W1, ARM64Reg::W2, ARM64Reg::W3); fpr.Lock(ARM64Reg::Q1); } @@ -112,7 +112,7 @@ void JitArm64::psq_lXX(UGeckoInstruction inst) fpr.Unlock(ARM64Reg::Q0); if (!js.assumeNoPairedQuantize) { - gpr.Unlock(ARM64Reg::W1, ARM64Reg::W2); + gpr.Unlock(ARM64Reg::W1, ARM64Reg::W2, ARM64Reg::W3); fpr.Unlock(ARM64Reg::Q1); } } diff --git a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp index 095fe14aff..6a427a1ab8 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp @@ -489,12 +489,13 @@ void JitArm64::GenerateQuantizedLoads() // X0 is the address // X1 is the scale // X2 is a temporary + // X3 is a temporary (used in EmitBackpatchRoutine) // X30 is LR // Q0 is the return // Q1 is a temporary ARM64Reg addr_reg = ARM64Reg::X0; ARM64Reg scale_reg = ARM64Reg::X1; - BitSet32 gprs_to_push = CALLER_SAVED_GPRS & ~BitSet32{0, 2}; + BitSet32 gprs_to_push = CALLER_SAVED_GPRS & ~BitSet32{0, 2, 3}; BitSet32 fprs_to_push = BitSet32(0xFFFFFFFF) & ~BitSet32{0, 1}; ARM64FloatEmitter float_emit(this);