diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index c41635c7e6..b4ba4e777d 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -120,13 +120,13 @@ int Interpreter::SingleStepInner() // TODO: Does it make sense to use m_prev_inst here? // It seems like we should use the num_cycles for the instruction at PC instead // (m_prev_inst has not yet been updated) - return PPCTables::GetOpInfo(m_prev_inst)->num_cycles; + return PPCTables::GetOpInfo(m_prev_inst, m_ppc_state.pc)->num_cycles; } m_ppc_state.npc = m_ppc_state.pc + sizeof(UGeckoInstruction); m_prev_inst.hex = m_mmu.Read_Opcode(m_ppc_state.pc); - const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(m_prev_inst); + const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(m_prev_inst, m_ppc_state.pc); // Uncomment to trace the interpreter // if ((m_ppc_state.pc & 0x00FFFFFF) >= 0x000AB54C && diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBase.h b/Source/Core/Core/PowerPC/JitCommon/JitBase.h index fe9c7341b8..70c72ef105 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBase.h +++ b/Source/Core/Core/PowerPC/JitCommon/JitBase.h @@ -32,7 +32,7 @@ struct PowerPCState; // Use these to control the instruction selection // #define INSTRUCTION_START FallBackToInterpreter(inst); return; -// #define INSTRUCTION_START PPCTables::CountInstruction(inst); +// #define INSTRUCTION_START PPCTables::CountInstruction(inst, m_ppc_state.pc); #define INSTRUCTION_START #define FALLBACK_IF(cond) \ diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index 750d3b6d65..7ca17cbffc 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -297,7 +297,7 @@ void JitInterface::CompileExceptionCheck(ExceptionType type) // Check in case the code has been replaced since: do we need to do this? const OpType optype = - PPCTables::GetOpInfo(PowerPC::MMU::HostRead_U32(guard, ppc_state.pc))->type; + PPCTables::GetOpInfo(PowerPC::MMU::HostRead_U32(guard, ppc_state.pc), ppc_state.pc)->type; if (optype != OpType::Store && optype != OpType::StoreFP && optype != OpType::StorePS) return; } diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index 1d4f5fab2f..029aecb87b 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -114,7 +114,7 @@ bool AnalyzeFunction(const Core::CPUThreadGuard& guard, u32 startAddr, Common::S } const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(addr); const UGeckoInstruction instr = read_result.hex; - if (read_result.valid && PPCTables::IsValidInstruction(instr)) + if (read_result.valid && PPCTables::IsValidInstruction(instr, addr)) { // BLR or RFI // 4e800021 is blrl, not the end of a function @@ -274,7 +274,7 @@ static void FindFunctionsFromBranches(const Core::CPUThreadGuard& guard, u32 sta const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(addr); const UGeckoInstruction instr = read_result.hex; - if (read_result.valid && PPCTables::IsValidInstruction(instr)) + if (read_result.valid && PPCTables::IsValidInstruction(instr, addr)) { switch (instr.OPCD) { @@ -323,7 +323,7 @@ static void FindFunctionsFromHandlers(const Core::CPUThreadGuard& guard, PPCSymb for (const auto& entry : handlers) { const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(entry.first); - if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex)) + if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex, entry.first)) { // Check if this function is already mapped Common::Symbol* f = func_db->AddFunction(guard, entry.first); @@ -357,7 +357,7 @@ static void FindFunctionsAfterReturnInstruction(const Core::CPUThreadGuard& guar location += 4; read_result = mmu.TryReadInstruction(location); } - if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex)) + if (read_result.valid && PPCTables::IsValidInstruction(read_result.hex, location)) { // check if this function is already mapped Common::Symbol* f = func_db->AddFunction(guard, location); @@ -778,7 +778,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, num_inst++; const UGeckoInstruction inst = result.hex; - const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(inst); + const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(inst, address); code[i] = {}; code[i].opinfo = opinfo; code[i].address = address; diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index dcd4d8417e..bf9392516b 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -613,7 +613,7 @@ constexpr Tables s_tables = []() consteval } (); -const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst) +const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst, u32 pc) { const GekkoOPInfo* info = &s_tables.all_instructions[s_tables.primary_table[inst.OPCD]]; if (info->type == OpType::Subtable) @@ -631,8 +631,7 @@ const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst) case 63: return &s_tables.all_instructions[s_tables.table63[inst.SUBOP10]]; default: - ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op {:08x} @ {:08x}", inst.hex, - PowerPC::ppcState.pc); + ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op {:08x} @ {:08x}", inst.hex, pc); return &s_tables.all_instructions[s_tables.unknown_op_info]; } } @@ -640,8 +639,7 @@ const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst) { if (info->type == OpType::Invalid) { - ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op {:08x} @ {:08x}", inst.hex, - PowerPC::ppcState.pc); + ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op {:08x} @ {:08x}", inst.hex, pc); return &s_tables.all_instructions[s_tables.unknown_op_info]; } return info; @@ -658,21 +656,21 @@ std::vector rsplocations; } #endif -const char* GetInstructionName(UGeckoInstruction inst) +const char* GetInstructionName(UGeckoInstruction inst, u32 pc) { - const GekkoOPInfo* info = GetOpInfo(inst); + const GekkoOPInfo* info = GetOpInfo(inst, pc); return info->opname; } -bool IsValidInstruction(UGeckoInstruction inst) +bool IsValidInstruction(UGeckoInstruction inst, u32 pc) { - const GekkoOPInfo* info = GetOpInfo(inst); + const GekkoOPInfo* info = GetOpInfo(inst, pc); return info->type != OpType::Invalid && info->type != OpType::Unknown; } -void CountInstruction(UGeckoInstruction inst) +void CountInstruction(UGeckoInstruction inst, u32 pc) { - const GekkoOPInfo* info = GetOpInfo(inst); + const GekkoOPInfo* info = GetOpInfo(inst, pc); info->stats->run_count++; } diff --git a/Source/Core/Core/PowerPC/PPCTables.h b/Source/Core/Core/PowerPC/PPCTables.h index 8d92f1811e..33a6e2a9fb 100644 --- a/Source/Core/Core/PowerPC/PPCTables.h +++ b/Source/Core/Core/PowerPC/PPCTables.h @@ -118,13 +118,13 @@ struct GekkoOPInfo namespace PPCTables { -const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst); +const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst, u32 pc); -bool IsValidInstruction(UGeckoInstruction inst); +bool IsValidInstruction(UGeckoInstruction inst, u32 pc); -void CountInstruction(UGeckoInstruction inst); +void CountInstruction(UGeckoInstruction inst, u32 pc); void CountInstructionCompile(const GekkoOPInfo* info, u32 pc); void PrintInstructionRunCounts(); void LogCompiledInstructions(); -const char* GetInstructionName(UGeckoInstruction inst); +const char* GetInstructionName(UGeckoInstruction inst, u32 pc); } // namespace PPCTables diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 2677ac27d0..4d764f2fac 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -1699,7 +1699,7 @@ void MenuBar::SearchInstruction() addr += 4) { const auto ins_name = QString::fromStdString( - PPCTables::GetInstructionName(PowerPC::MMU::HostRead_U32(guard, addr))); + PPCTables::GetInstructionName(PowerPC::MMU::HostRead_U32(guard, addr), addr)); if (op == ins_name) { NOTICE_LOG_FMT(POWERPC, "Found {} at {:08x}", op.toStdString(), addr);