PowerPC/PPCTables: Pass instruction address to GetOpInfo().
This commit is contained in:
parent
6018daa3fa
commit
e5941428d1
|
@ -120,13 +120,13 @@ int Interpreter::SingleStepInner()
|
||||||
// TODO: Does it make sense to use m_prev_inst here?
|
// 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
|
// It seems like we should use the num_cycles for the instruction at PC instead
|
||||||
// (m_prev_inst has not yet been updated)
|
// (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_ppc_state.npc = m_ppc_state.pc + sizeof(UGeckoInstruction);
|
||||||
m_prev_inst.hex = m_mmu.Read_Opcode(m_ppc_state.pc);
|
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
|
// Uncomment to trace the interpreter
|
||||||
// if ((m_ppc_state.pc & 0x00FFFFFF) >= 0x000AB54C &&
|
// if ((m_ppc_state.pc & 0x00FFFFFF) >= 0x000AB54C &&
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct PowerPCState;
|
||||||
|
|
||||||
// Use these to control the instruction selection
|
// Use these to control the instruction selection
|
||||||
// #define INSTRUCTION_START FallBackToInterpreter(inst); return;
|
// #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 INSTRUCTION_START
|
||||||
|
|
||||||
#define FALLBACK_IF(cond) \
|
#define FALLBACK_IF(cond) \
|
||||||
|
|
|
@ -297,7 +297,7 @@ void JitInterface::CompileExceptionCheck(ExceptionType type)
|
||||||
|
|
||||||
// Check in case the code has been replaced since: do we need to do this?
|
// Check in case the code has been replaced since: do we need to do this?
|
||||||
const OpType optype =
|
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)
|
if (optype != OpType::Store && optype != OpType::StoreFP && optype != OpType::StorePS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ bool AnalyzeFunction(const Core::CPUThreadGuard& guard, u32 startAddr, Common::S
|
||||||
}
|
}
|
||||||
const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(addr);
|
const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(addr);
|
||||||
const UGeckoInstruction instr = read_result.hex;
|
const UGeckoInstruction instr = read_result.hex;
|
||||||
if (read_result.valid && PPCTables::IsValidInstruction(instr))
|
if (read_result.valid && PPCTables::IsValidInstruction(instr, addr))
|
||||||
{
|
{
|
||||||
// BLR or RFI
|
// BLR or RFI
|
||||||
// 4e800021 is blrl, not the end of a function
|
// 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 PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(addr);
|
||||||
const UGeckoInstruction instr = read_result.hex;
|
const UGeckoInstruction instr = read_result.hex;
|
||||||
|
|
||||||
if (read_result.valid && PPCTables::IsValidInstruction(instr))
|
if (read_result.valid && PPCTables::IsValidInstruction(instr, addr))
|
||||||
{
|
{
|
||||||
switch (instr.OPCD)
|
switch (instr.OPCD)
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ static void FindFunctionsFromHandlers(const Core::CPUThreadGuard& guard, PPCSymb
|
||||||
for (const auto& entry : handlers)
|
for (const auto& entry : handlers)
|
||||||
{
|
{
|
||||||
const PowerPC::TryReadInstResult read_result = mmu.TryReadInstruction(entry.first);
|
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
|
// Check if this function is already mapped
|
||||||
Common::Symbol* f = func_db->AddFunction(guard, entry.first);
|
Common::Symbol* f = func_db->AddFunction(guard, entry.first);
|
||||||
|
@ -357,7 +357,7 @@ static void FindFunctionsAfterReturnInstruction(const Core::CPUThreadGuard& guar
|
||||||
location += 4;
|
location += 4;
|
||||||
read_result = mmu.TryReadInstruction(location);
|
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
|
// check if this function is already mapped
|
||||||
Common::Symbol* f = func_db->AddFunction(guard, location);
|
Common::Symbol* f = func_db->AddFunction(guard, location);
|
||||||
|
@ -778,7 +778,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
|
||||||
num_inst++;
|
num_inst++;
|
||||||
|
|
||||||
const UGeckoInstruction inst = result.hex;
|
const UGeckoInstruction inst = result.hex;
|
||||||
const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(inst);
|
const GekkoOPInfo* opinfo = PPCTables::GetOpInfo(inst, address);
|
||||||
code[i] = {};
|
code[i] = {};
|
||||||
code[i].opinfo = opinfo;
|
code[i].opinfo = opinfo;
|
||||||
code[i].address = address;
|
code[i].address = address;
|
||||||
|
|
|
@ -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]];
|
const GekkoOPInfo* info = &s_tables.all_instructions[s_tables.primary_table[inst.OPCD]];
|
||||||
if (info->type == OpType::Subtable)
|
if (info->type == OpType::Subtable)
|
||||||
|
@ -631,8 +631,7 @@ const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst)
|
||||||
case 63:
|
case 63:
|
||||||
return &s_tables.all_instructions[s_tables.table63[inst.SUBOP10]];
|
return &s_tables.all_instructions[s_tables.table63[inst.SUBOP10]];
|
||||||
default:
|
default:
|
||||||
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op {:08x} @ {:08x}", inst.hex,
|
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op {:08x} @ {:08x}", inst.hex, pc);
|
||||||
PowerPC::ppcState.pc);
|
|
||||||
return &s_tables.all_instructions[s_tables.unknown_op_info];
|
return &s_tables.all_instructions[s_tables.unknown_op_info];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -640,8 +639,7 @@ const GekkoOPInfo* GetOpInfo(UGeckoInstruction inst)
|
||||||
{
|
{
|
||||||
if (info->type == OpType::Invalid)
|
if (info->type == OpType::Invalid)
|
||||||
{
|
{
|
||||||
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op {:08x} @ {:08x}", inst.hex,
|
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op {:08x} @ {:08x}", inst.hex, pc);
|
||||||
PowerPC::ppcState.pc);
|
|
||||||
return &s_tables.all_instructions[s_tables.unknown_op_info];
|
return &s_tables.all_instructions[s_tables.unknown_op_info];
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
@ -658,21 +656,21 @@ std::vector<u32> rsplocations;
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
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;
|
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++;
|
info->stats->run_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,13 +118,13 @@ struct GekkoOPInfo
|
||||||
|
|
||||||
namespace PPCTables
|
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 CountInstructionCompile(const GekkoOPInfo* info, u32 pc);
|
||||||
void PrintInstructionRunCounts();
|
void PrintInstructionRunCounts();
|
||||||
void LogCompiledInstructions();
|
void LogCompiledInstructions();
|
||||||
const char* GetInstructionName(UGeckoInstruction inst);
|
const char* GetInstructionName(UGeckoInstruction inst, u32 pc);
|
||||||
} // namespace PPCTables
|
} // namespace PPCTables
|
||||||
|
|
|
@ -1699,7 +1699,7 @@ void MenuBar::SearchInstruction()
|
||||||
addr += 4)
|
addr += 4)
|
||||||
{
|
{
|
||||||
const auto ins_name = QString::fromStdString(
|
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)
|
if (op == ins_name)
|
||||||
{
|
{
|
||||||
NOTICE_LOG_FMT(POWERPC, "Found {} at {:08x}", op.toStdString(), addr);
|
NOTICE_LOG_FMT(POWERPC, "Found {} at {:08x}", op.toStdString(), addr);
|
||||||
|
|
Loading…
Reference in New Issue