backend/arm64: A64: Implement DumpDisassembly

This commit is contained in:
Merry 2024-02-13 02:21:22 +00:00
parent 4ae4750b5a
commit 69dc836977
3 changed files with 14 additions and 1 deletions

View file

@ -149,7 +149,7 @@ struct Jit::Impl final {
} }
void DumpDisassembly() const { void DumpDisassembly() const {
ASSERT_FALSE("Unimplemented"); current_address_space.DumpDisassembly();
} }
std::vector<std::string> Disassemble() const { std::vector<std::string> Disassemble() const {

View file

@ -3,6 +3,10 @@
* SPDX-License-Identifier: 0BSD * SPDX-License-Identifier: 0BSD
*/ */
#include <cstdio>
#include <mcl/bit_cast.hpp>
#include "dynarmic/backend/arm64/a64_address_space.h" #include "dynarmic/backend/arm64/a64_address_space.h"
#include "dynarmic/backend/arm64/a64_jitstate.h" #include "dynarmic/backend/arm64/a64_jitstate.h"
#include "dynarmic/backend/arm64/abi.h" #include "dynarmic/backend/arm64/abi.h"
@ -11,6 +15,7 @@
#include "dynarmic/backend/arm64/stack_layout.h" #include "dynarmic/backend/arm64/stack_layout.h"
#include "dynarmic/common/cast_util.h" #include "dynarmic/common/cast_util.h"
#include "dynarmic/common/fp/fpcr.h" #include "dynarmic/common/fp/fpcr.h"
#include "dynarmic/common/llvm_disassemble.h"
#include "dynarmic/interface/exclusive_monitor.h" #include "dynarmic/interface/exclusive_monitor.h"
namespace Dynarmic::Backend::Arm64 { namespace Dynarmic::Backend::Arm64 {
@ -92,6 +97,12 @@ void AddressSpace::ClearCache() {
code.set_offset(prelude_info.end_of_prelude); code.set_offset(prelude_info.end_of_prelude);
} }
void AddressSpace::DumpDisassembly() const {
for (u32* ptr = mem.ptr(); ptr < code.xptr<u32*>(); ptr++) {
std::printf("%s", Common::DisassembleAArch64(*ptr, mcl::bit_cast<u64>(ptr)).c_str());
}
}
size_t AddressSpace::GetRemainingSize() { size_t AddressSpace::GetRemainingSize() {
return code_cache_size - static_cast<size_t>(code.offset()); return code_cache_size - static_cast<size_t>(code.offset());
} }

View file

@ -43,6 +43,8 @@ public:
void ClearCache(); void ClearCache();
void DumpDisassembly() const;
protected: protected:
virtual EmitConfig GetEmitConfig() = 0; virtual EmitConfig GetEmitConfig() = 0;
virtual void RegisterNewBasicBlock(const IR::Block& block, const EmittedBlockInfo& block_info) = 0; virtual void RegisterNewBasicBlock(const IR::Block& block, const EmittedBlockInfo& block_info) = 0;