From 2636da8821491bae7e2dc576214b896155b230f4 Mon Sep 17 00:00:00 2001 From: Merry Date: Sat, 4 Feb 2023 14:11:56 +0000 Subject: [PATCH] verbose_debugging_output: Use actual names --- src/dynarmic/backend/arm64/reg_alloc.cpp | 5 ++--- src/dynarmic/backend/arm64/reg_alloc.h | 3 +-- .../backend/arm64/verbose_debugging_output.cpp | 2 +- src/dynarmic/backend/x64/a32_emit_x64.cpp | 2 +- src/dynarmic/backend/x64/a64_emit_x64.cpp | 2 +- src/dynarmic/backend/x64/emit_x64.cpp | 4 ++-- src/dynarmic/backend/x64/emit_x64.h | 2 +- src/dynarmic/backend/x64/reg_alloc.cpp | 10 ++++------ src/dynarmic/backend/x64/reg_alloc.h | 5 ++--- 9 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/dynarmic/backend/arm64/reg_alloc.cpp b/src/dynarmic/backend/arm64/reg_alloc.cpp index 9c01715e..c3cad3d1 100644 --- a/src/dynarmic/backend/arm64/reg_alloc.cpp +++ b/src/dynarmic/backend/arm64/reg_alloc.cpp @@ -242,17 +242,16 @@ void RegAlloc::AssertNoMoreUses() const { ASSERT(std::all_of(spills.begin(), spills.end(), is_empty)); } -void RegAlloc::EmitVerboseDebuggingOutput(EmitContext& ctx) { +void RegAlloc::EmitVerboseDebuggingOutput() { code.MOV(X19, mcl::bit_cast(&PrintVerboseDebuggingOutputLine)); // Non-volatile register const auto do_location = [&](HostLocInfo& info, HostLocType type, size_t index) { using namespace oaknut::util; for (const IR::Inst* value : info.values) { - const auto inst_offset = std::distance(ctx.block.begin(), IR::Block::iterator(const_cast(value))); code.MOV(X0, SP); code.MOV(X1, static_cast(type)); code.MOV(X2, index); - code.MOV(X3, mcl::bit_cast(inst_offset)); + code.MOV(X3, value->GetName()); code.MOV(X4, static_cast(value->GetType())); code.BLR(X19); } diff --git a/src/dynarmic/backend/arm64/reg_alloc.h b/src/dynarmic/backend/arm64/reg_alloc.h index 2a1ddf95..3a2d5388 100644 --- a/src/dynarmic/backend/arm64/reg_alloc.h +++ b/src/dynarmic/backend/arm64/reg_alloc.h @@ -24,7 +24,6 @@ namespace Dynarmic::Backend::Arm64 { -struct EmitContext; class FpsrManager; class RegAlloc; @@ -296,7 +295,7 @@ public: void AssertAllUnlocked() const; void AssertNoMoreUses() const; - void EmitVerboseDebuggingOutput(EmitContext& ctx); + void EmitVerboseDebuggingOutput(); private: friend struct Argument; diff --git a/src/dynarmic/backend/arm64/verbose_debugging_output.cpp b/src/dynarmic/backend/arm64/verbose_debugging_output.cpp index 9fb989ff..e9646885 100644 --- a/src/dynarmic/backend/arm64/verbose_debugging_output.cpp +++ b/src/dynarmic/backend/arm64/verbose_debugging_output.cpp @@ -33,7 +33,7 @@ void EmitVerboseDebuggingOutput(oaknut::CodeGenerator& code, EmitContext& ctx) { code.ADD(X0, SP, sizeof(RegisterData) + offsetof(StackLayout, spill)); code.STR(X0, SP, offsetof(RegisterData, spill)); - ctx.reg_alloc.EmitVerboseDebuggingOutput(ctx); + ctx.reg_alloc.EmitVerboseDebuggingOutput(); code.LDR(X0, SP, offsetof(RegisterData, nzcv)); code.MSR(oaknut::SystemReg::NZCV, X0); diff --git a/src/dynarmic/backend/x64/a32_emit_x64.cpp b/src/dynarmic/backend/x64/a32_emit_x64.cpp index d7385331..ce52c52c 100644 --- a/src/dynarmic/backend/x64/a32_emit_x64.cpp +++ b/src/dynarmic/backend/x64/a32_emit_x64.cpp @@ -150,7 +150,7 @@ A32EmitX64::BlockDescriptor A32EmitX64::Emit(IR::Block& block) { reg_alloc.EndOfAllocScope(); if (conf.very_verbose_debugging_output) { - EmitVerboseDebuggingOutput(reg_alloc, block); + EmitVerboseDebuggingOutput(reg_alloc); } } diff --git a/src/dynarmic/backend/x64/a64_emit_x64.cpp b/src/dynarmic/backend/x64/a64_emit_x64.cpp index 7d430f09..99ee090d 100644 --- a/src/dynarmic/backend/x64/a64_emit_x64.cpp +++ b/src/dynarmic/backend/x64/a64_emit_x64.cpp @@ -121,7 +121,7 @@ A64EmitX64::BlockDescriptor A64EmitX64::Emit(IR::Block& block) { ctx.reg_alloc.EndOfAllocScope(); if (conf.very_verbose_debugging_output) { - EmitVerboseDebuggingOutput(reg_alloc, block); + EmitVerboseDebuggingOutput(reg_alloc); } } diff --git a/src/dynarmic/backend/x64/emit_x64.cpp b/src/dynarmic/backend/x64/emit_x64.cpp index 2d7250ca..fac6c089 100644 --- a/src/dynarmic/backend/x64/emit_x64.cpp +++ b/src/dynarmic/backend/x64/emit_x64.cpp @@ -99,7 +99,7 @@ void EmitX64::PushRSBHelper(Xbyak::Reg64 loc_desc_reg, Xbyak::Reg64 index_reg, I code.mov(dword[r15 + code.GetJitStateInfo().offsetof_rsb_ptr], index_reg.cvt32()); } -void EmitX64::EmitVerboseDebuggingOutput(RegAlloc& reg_alloc, const IR::Block& block) { +void EmitX64::EmitVerboseDebuggingOutput(RegAlloc& reg_alloc) { code.sub(rsp, sizeof(RegisterData)); code.stmxcsr(dword[rsp + offsetof(RegisterData, mxcsr)]); for (int i = 0; i < 16; i++) { @@ -114,7 +114,7 @@ void EmitX64::EmitVerboseDebuggingOutput(RegAlloc& reg_alloc, const IR::Block& b code.lea(rax, ptr[rsp + sizeof(RegisterData) + offsetof(StackLayout, spill)]); code.mov(xword[rsp + offsetof(RegisterData, spill)], rax); - reg_alloc.EmitVerboseDebuggingOutput(block); + reg_alloc.EmitVerboseDebuggingOutput(); for (int i = 0; i < 16; i++) { if (rsp.getIdx() == i) { diff --git a/src/dynarmic/backend/x64/emit_x64.h b/src/dynarmic/backend/x64/emit_x64.h index 228398d8..5a46f04e 100644 --- a/src/dynarmic/backend/x64/emit_x64.h +++ b/src/dynarmic/backend/x64/emit_x64.h @@ -107,7 +107,7 @@ protected: BlockDescriptor RegisterBlock(const IR::LocationDescriptor& location_descriptor, CodePtr entrypoint, size_t size); void PushRSBHelper(Xbyak::Reg64 loc_desc_reg, Xbyak::Reg64 index_reg, IR::LocationDescriptor target); - void EmitVerboseDebuggingOutput(RegAlloc& reg_alloc, const IR::Block& block); + void EmitVerboseDebuggingOutput(RegAlloc& reg_alloc); // Terminal instruction emitters void EmitTerminal(IR::Terminal terminal, IR::LocationDescriptor initial_location, bool is_single_step); diff --git a/src/dynarmic/backend/x64/reg_alloc.cpp b/src/dynarmic/backend/x64/reg_alloc.cpp index c85551cf..f50112a5 100644 --- a/src/dynarmic/backend/x64/reg_alloc.cpp +++ b/src/dynarmic/backend/x64/reg_alloc.cpp @@ -17,7 +17,6 @@ #include "dynarmic/backend/x64/abi.h" #include "dynarmic/backend/x64/stack_layout.h" #include "dynarmic/backend/x64/verbose_debugging_output.h" -#include "dynarmic/ir/basic_block.h" namespace Dynarmic::Backend::X64 { @@ -158,13 +157,12 @@ void HostLocInfo::AddValue(IR::Inst* inst) { max_bit_width = std::max(max_bit_width, GetBitWidth(inst->GetType())); } -void HostLocInfo::EmitVerboseDebuggingOutput(BlockOfCode& code, size_t host_loc_index, const IR::Block& block) const { +void HostLocInfo::EmitVerboseDebuggingOutput(BlockOfCode& code, size_t host_loc_index) const { using namespace Xbyak::util; for (IR::Inst* value : values) { - const auto inst_offset = std::distance(block.begin(), IR::Block::const_iterator(value)); code.mov(code.ABI_PARAM1, rsp); code.mov(code.ABI_PARAM2, host_loc_index); - code.mov(code.ABI_PARAM3, mcl::bit_cast(inst_offset)); + code.mov(code.ABI_PARAM3, value->GetName()); code.mov(code.ABI_PARAM4, GetBitWidth(value->GetType())); code.CallFunction(PrintVerboseDebuggingOutputLine); } @@ -515,9 +513,9 @@ void RegAlloc::AssertNoMoreUses() { ASSERT(std::all_of(hostloc_info.begin(), hostloc_info.end(), [](const auto& i) { return i.IsEmpty(); })); } -void RegAlloc::EmitVerboseDebuggingOutput(const IR::Block& block) { +void RegAlloc::EmitVerboseDebuggingOutput() { for (size_t i = 0; i < hostloc_info.size(); i++) { - hostloc_info[i].EmitVerboseDebuggingOutput(code, i, block); + hostloc_info[i].EmitVerboseDebuggingOutput(code, i); } } diff --git a/src/dynarmic/backend/x64/reg_alloc.h b/src/dynarmic/backend/x64/reg_alloc.h index 957c2b2a..19debf5f 100644 --- a/src/dynarmic/backend/x64/reg_alloc.h +++ b/src/dynarmic/backend/x64/reg_alloc.h @@ -23,7 +23,6 @@ namespace Dynarmic::IR { enum class AccType; -class Block; } // namespace Dynarmic::IR namespace Dynarmic::Backend::X64 { @@ -49,7 +48,7 @@ public: void AddValue(IR::Inst* inst); - void EmitVerboseDebuggingOutput(BlockOfCode& code, size_t host_loc_index, const IR::Block& block) const; + void EmitVerboseDebuggingOutput(BlockOfCode& code, size_t host_loc_index) const; private: // Current instruction state @@ -148,7 +147,7 @@ public: void AssertNoMoreUses(); - void EmitVerboseDebuggingOutput(const IR::Block& block); + void EmitVerboseDebuggingOutput(); private: friend struct Argument;