Permalink
Browse files

Common: Namespace GekkoDisassembler.cpp/.h

Moves more common code into the Common namespace where it belongs
  • Loading branch information...
lioncash committed May 25, 2018
1 parent 3d44dc3 commit b60ad2425d05dc5134de76d0848a5079ad197500
@@ -38,6 +38,8 @@
#include "Common/GekkoDisassembler.h"
#include "Common/StringUtil.h"
namespace Common
{
// version/revision
#define PPCDISASM_VER 1
#define PPCDISASM_REV 6
@@ -2315,3 +2317,4 @@ const char* GekkoDisassembler::GetFPRName(u32 index)
return nullptr;
}
} // namespace Common
@@ -40,6 +40,8 @@
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
namespace Common
{
class GekkoDisassembler final
{
public:
@@ -152,3 +154,4 @@ class GekkoDisassembler final
static unsigned short m_sreg; // Register in load/store instructions
static u32 m_displacement; // Branch- or load/store displacement
};
} // namespace Common
@@ -173,7 +173,7 @@ std::string PPCDebugInterface::Disassemble(unsigned int address)
}
const u32 op = PowerPC::HostRead_Instruction(address);
std::string disasm = GekkoDisassembler::Disassemble(op, address);
std::string disasm = Common::GekkoDisassembler::Disassemble(op, address);
const UGeckoInstruction inst{op};
if (inst.OPCD == 1)
@@ -92,7 +92,7 @@ static void Trace(UGeckoInstruction& inst)
PowerPC::ppcState.ps[i][1]);
}
std::string ppc_inst = GekkoDisassembler::Disassemble(inst.hex, PC);
const std::string ppc_inst = Common::GekkoDisassembler::Disassemble(inst.hex, PC);
DEBUG_LOG(POWERPC,
"INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: "
"%08x %s %08x %s",
@@ -295,15 +295,18 @@ void Interpreter::Run()
void Interpreter::unknown_instruction(UGeckoInstruction inst)
{
std::string disasm = GekkoDisassembler::Disassemble(PowerPC::HostRead_U32(last_pc), last_pc);
const u32 opcode = PowerPC::HostRead_U32(last_pc);
const std::string disasm = Common::GekkoDisassembler::Disassemble(opcode, last_pc);
NOTICE_LOG(POWERPC, "Last PC = %08x : %s", last_pc, disasm.c_str());
Dolphin_Debugger::PrintCallstack();
NOTICE_LOG(POWERPC,
"\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n",
inst.hex, PC, last_pc, LR);
for (int i = 0; i < 32; i += 4)
{
NOTICE_LOG(POWERPC, "r%d: 0x%08x r%d: 0x%08x r%d:0x%08x r%d: 0x%08x", i, rGPR[i], i + 1,
rGPR[i + 1], i + 2, rGPR[i + 2], i + 3, rGPR[i + 3]);
}
ASSERT_MSG(POWERPC, 0,
"\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n",
inst.hex, PC, last_pc, LR);
@@ -931,7 +931,7 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
#if defined(_DEBUG) || defined(DEBUGFAST)
if (gpr.SanityCheck() || fpr.SanityCheck())
{
std::string ppc_inst = GekkoDisassembler::Disassemble(op.inst.hex, em_address);
std::string ppc_inst = Common::GekkoDisassembler::Disassemble(op.inst.hex, em_address);
// NOTICE_LOG(DYNA_REC, "Unflushed register: %s", ppc_inst.c_str());
}
#endif
@@ -133,9 +133,8 @@ void LogGeneratedX86(size_t size, const PPCAnalyst::CodeBuffer& code_buffer, con
for (size_t i = 0; i < size; i++)
{
const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string temp = StringFromFormat(
"%08x %s", op.address, GekkoDisassembler::Disassemble(op.inst.hex, op.address).c_str());
DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %s\n", temp.c_str());
const std::string disasm = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %08x %s\n", op.address, disasm.c_str());
}
disassembler x64disasm;
@@ -163,7 +163,7 @@ void JITWidget::Update()
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string opcode = GekkoDisassembler::Disassemble(op.inst.hex, op.address);
const std::string opcode = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address;
ppc_disasm << " " << opcode << std::endl;
}
@@ -85,6 +85,6 @@ void AssemblerEntryDialog::OnTextChanged(wxCommandEvent& evt)
unsigned long code;
std::string result = "Input text is invalid";
if (evt.GetString().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max())
result = TabsToSpaces(1, GekkoDisassembler::Disassemble(code, m_address));
result = TabsToSpaces(1, Common::GekkoDisassembler::Disassemble(code, m_address));
m_preview->SetLabel(wxString::Format(_("Preview: %s"), result.c_str()));
}
@@ -99,7 +99,7 @@ void CJitWindow::Compare(u32 em_address)
for (u32 i = 0; i < code_block.m_num_instructions; i++)
{
const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string opcode = GekkoDisassembler::Disassemble(op.inst.hex, op.address);
const std::string opcode = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address;
ppc_disasm << " " << opcode << std::endl;
}
@@ -284,11 +284,11 @@ wxString CRegTable::GetValue(int row, int col)
switch (col)
{
case 0:
return StrToWxStr(GekkoDisassembler::GetGPRName(row));
return StrToWxStr(Common::GekkoDisassembler::GetGPRName(row));
case 1:
return FormatGPR(row);
case 2:
return StrToWxStr(GekkoDisassembler::GetFPRName(row));
return StrToWxStr(Common::GekkoDisassembler::GetFPRName(row));
case 3:
return FormatFPR(row, 0);
case 4:

0 comments on commit b60ad24

Please sign in to comment.