summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2023-12-07 09:32:58 -0800
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-02-26 19:38:27 -0800
commit2aa250a68ab8fa35584d3ccb2d3fb2ccf367ef12 (patch)
treec5ce735818b4db331672053685726fc46fcac65d /Source
parent67f60bec7e59dbb24930b23246fa44aa089c9861 (diff)
Interpreter: Install BranchWatch
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp
index 8b5bac0509..1d57d971b4 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp
@@ -7,6 +7,7 @@
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
+#include "Core/Debugger/BranchWatch.h"
#include "Core/HLE/HLE.h"
#include "Core/PowerPC/Interpreter/ExceptionUtils.h"
#include "Core/PowerPC/PowerPC.h"
@@ -19,12 +20,13 @@ void Interpreter::bx(Interpreter& interpreter, UGeckoInstruction inst)
if (inst.LK)
LR(ppc_state) = ppc_state.pc + 4;
- const auto address = u32(SignExt26(inst.LI << 2));
+ u32 destination_addr = u32(SignExt26(inst.LI << 2));
+ if (!inst.AA)
+ destination_addr += ppc_state.pc;
+ ppc_state.npc = destination_addr;
- if (inst.AA)
- ppc_state.npc = address;
- else
- ppc_state.npc = ppc_state.pc + address;
+ if (auto& branch_watch = interpreter.m_branch_watch; branch_watch.GetRecordingActive())
+ branch_watch.HitTrue(ppc_state.pc, destination_addr, inst, ppc_state.msr.IR);
interpreter.m_end_block = true;
}
@@ -33,6 +35,7 @@ void Interpreter::bx(Interpreter& interpreter, UGeckoInstruction inst)
void Interpreter::bcx(Interpreter& interpreter, UGeckoInstruction inst)
{
auto& ppc_state = interpreter.m_ppc_state;
+ auto& branch_watch = interpreter.m_branch_watch;
if ((inst.BO & BO_DONT_DECREMENT_FLAG) == 0)
CTR(ppc_state)--;
@@ -49,12 +52,17 @@ void Interpreter::bcx(Interpreter& interpreter, UGeckoInstruction inst)
if (inst.LK)
LR(ppc_state) = ppc_state.pc + 4;
- const auto address = u32(SignExt16(s16(inst.BD << 2)));
+ u32 destination_addr = u32(SignExt16(s16(inst.BD << 2)));
+ if (!inst.AA)
+ destination_addr += ppc_state.pc;
+ ppc_state.npc = destination_addr;
- if (inst.AA)
- ppc_state.npc = address;
- else
- ppc_state.npc = ppc_state.pc + address;
+ if (branch_watch.GetRecordingActive())
+ branch_watch.HitTrue(ppc_state.pc, destination_addr, inst, ppc_state.msr.IR);
+ }
+ else if (branch_watch.GetRecordingActive())
+ {
+ branch_watch.HitFalse(ppc_state.pc, ppc_state.pc + 4, inst, ppc_state.msr.IR);
}
interpreter.m_end_block = true;
@@ -63,6 +71,7 @@ void Interpreter::bcx(Interpreter& interpreter, UGeckoInstruction inst)
void Interpreter::bcctrx(Interpreter& interpreter, UGeckoInstruction inst)
{
auto& ppc_state = interpreter.m_ppc_state;
+ auto& branch_watch = interpreter.m_branch_watch;
DEBUG_ASSERT_MSG(POWERPC, (inst.BO_2 & BO_DONT_DECREMENT_FLAG) != 0,
"bcctrx with decrement and test CTR option is invalid!");
@@ -72,9 +81,17 @@ void Interpreter::bcctrx(Interpreter& interpreter, UGeckoInstruction inst)
if (condition != 0)
{
- ppc_state.npc = CTR(ppc_state) & (~3);
+ const u32 destination_addr = CTR(ppc_state) & (~3);
+ ppc_state.npc = destination_addr;
if (inst.LK_3)
LR(ppc_state) = ppc_state.pc + 4;
+
+ if (branch_watch.GetRecordingActive())
+ branch_watch.HitTrue(ppc_state.pc, destination_addr, inst, ppc_state.msr.IR);
+ }
+ else if (branch_watch.GetRecordingActive())
+ {
+ branch_watch.HitFalse(ppc_state.pc, ppc_state.pc + 4, inst, ppc_state.msr.IR);
}
interpreter.m_end_block = true;
@@ -83,6 +100,7 @@ void Interpreter::bcctrx(Interpreter& interpreter, UGeckoInstruction inst)
void Interpreter::bclrx(Interpreter& interpreter, UGeckoInstruction inst)
{
auto& ppc_state = interpreter.m_ppc_state;
+ auto& branch_watch = interpreter.m_branch_watch;
if ((inst.BO_2 & BO_DONT_DECREMENT_FLAG) == 0)
CTR(ppc_state)--;
@@ -93,9 +111,17 @@ void Interpreter::bclrx(Interpreter& interpreter, UGeckoInstruction inst)
if ((counter & condition) != 0)
{
- ppc_state.npc = LR(ppc_state) & (~3);
+ const u32 destination_addr = LR(ppc_state) & (~3);
+ ppc_state.npc = destination_addr;
if (inst.LK_3)
LR(ppc_state) = ppc_state.pc + 4;
+
+ if (branch_watch.GetRecordingActive())
+ branch_watch.HitTrue(ppc_state.pc, destination_addr, inst, ppc_state.msr.IR);
+ }
+ else if (branch_watch.GetRecordingActive())
+ {
+ branch_watch.HitFalse(ppc_state.pc, ppc_state.pc + 4, inst, ppc_state.msr.IR);
}
interpreter.m_end_block = true;