From e0f091b6a6e0b7a0cb5574822f2428be5e698944 Mon Sep 17 00:00:00 2001 From: Merry Date: Thu, 14 Jul 2022 22:07:50 +0100 Subject: [PATCH] backend/arm64: void* -> CodePtr --- src/dynarmic/backend/arm64/a32_address_space.cpp | 10 +++++----- src/dynarmic/backend/arm64/a32_address_space.h | 8 ++++---- src/dynarmic/backend/arm64/emit_arm64.cpp | 6 +++--- src/dynarmic/backend/arm64/emit_arm64.h | 6 +++++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/dynarmic/backend/arm64/a32_address_space.cpp b/src/dynarmic/backend/arm64/a32_address_space.cpp index 4e5a8e74..429e3c24 100644 --- a/src/dynarmic/backend/arm64/a32_address_space.cpp +++ b/src/dynarmic/backend/arm64/a32_address_space.cpp @@ -37,15 +37,15 @@ IR::Block A32AddressSpace::GenerateIR(IR::LocationDescriptor descriptor) const { return ir_block; } -void* A32AddressSpace::Get(IR::LocationDescriptor descriptor) { +CodePtr A32AddressSpace::Get(IR::LocationDescriptor descriptor) { if (const auto iter = block_entries.find(descriptor.Value()); iter != block_entries.end()) { return iter->second; } return nullptr; } -void* A32AddressSpace::GetOrEmit(IR::LocationDescriptor descriptor) { - if (void* block_entry = Get(descriptor)) { +CodePtr A32AddressSpace::GetOrEmit(IR::LocationDescriptor descriptor) { + if (CodePtr block_entry = Get(descriptor)) { return block_entry; } @@ -96,7 +96,7 @@ void A32AddressSpace::EmitPrelude() { } size_t A32AddressSpace::GetRemainingSize() { - return conf.code_cache_size - (reinterpret_cast(code.ptr()) - reinterpret_cast(mem.ptr())); + return conf.code_cache_size - (code.ptr() - reinterpret_cast(mem.ptr())); } EmittedBlockInfo A32AddressSpace::Emit(IR::Block block) { @@ -119,7 +119,7 @@ void A32AddressSpace::Link(EmittedBlockInfo& block_info) { using namespace oaknut::util; for (auto [ptr_offset, target] : block_info.relocations) { - CodeGenerator c{reinterpret_cast(reinterpret_cast(block_info.entry_point) + ptr_offset)}; + CodeGenerator c{reinterpret_cast(block_info.entry_point + ptr_offset)}; switch (target) { case LinkTarget::ReturnFromRunCode: diff --git a/src/dynarmic/backend/arm64/a32_address_space.h b/src/dynarmic/backend/arm64/a32_address_space.h index c3484e79..2977ca31 100644 --- a/src/dynarmic/backend/arm64/a32_address_space.h +++ b/src/dynarmic/backend/arm64/a32_address_space.h @@ -26,9 +26,9 @@ public: IR::Block GenerateIR(IR::LocationDescriptor) const; - void* Get(IR::LocationDescriptor descriptor); + CodePtr Get(IR::LocationDescriptor descriptor); - void* GetOrEmit(IR::LocationDescriptor descriptor); + CodePtr GetOrEmit(IR::LocationDescriptor descriptor); void ClearCache(); @@ -46,13 +46,13 @@ private: oaknut::CodeBlock mem; oaknut::CodeGenerator code; - tsl::robin_map block_entries; + tsl::robin_map block_entries; tsl::robin_map block_infos; struct PreludeInfo { u32* end_of_prelude; - using RunCodeFuncType = HaltReason (*)(void* entry_point, A32JitState* context, volatile u32* halt_reason); + using RunCodeFuncType = HaltReason (*)(CodePtr entry_point, A32JitState* context, volatile u32* halt_reason); RunCodeFuncType run_code; void* return_from_run_code; } prelude_info; diff --git a/src/dynarmic/backend/arm64/emit_arm64.cpp b/src/dynarmic/backend/arm64/emit_arm64.cpp index ef404f34..6988a23e 100644 --- a/src/dynarmic/backend/arm64/emit_arm64.cpp +++ b/src/dynarmic/backend/arm64/emit_arm64.cpp @@ -18,7 +18,7 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block) { (void)block; EmittedBlockInfo ebi; - ebi.entry_point = code.ptr(); + ebi.entry_point = code.ptr(); code.MOV(W0, 8); code.STR(W0, X1, offsetof(A32JitState, regs) + 0 * sizeof(u32)); @@ -26,10 +26,10 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block) { code.STR(W0, X1, offsetof(A32JitState, regs) + 1 * sizeof(u32)); code.STR(W0, X1, offsetof(A32JitState, regs) + 15 * sizeof(u32)); - ebi.relocations[code.ptr() - reinterpret_cast(ebi.entry_point)] = LinkTarget::ReturnFromRunCode; + ebi.relocations[code.ptr() - ebi.entry_point] = LinkTarget::ReturnFromRunCode; code.NOP(); - ebi.size = reinterpret_cast(code.ptr()) - reinterpret_cast(ebi.entry_point); + ebi.size = code.ptr() - ebi.entry_point; return ebi; } diff --git a/src/dynarmic/backend/arm64/emit_arm64.h b/src/dynarmic/backend/arm64/emit_arm64.h index 1855432d..73f212ea 100644 --- a/src/dynarmic/backend/arm64/emit_arm64.h +++ b/src/dynarmic/backend/arm64/emit_arm64.h @@ -5,6 +5,8 @@ #pragma once +#include + #include #include @@ -21,12 +23,14 @@ class Block; namespace Dynarmic::Backend::Arm64 { +using CodePtr = std::byte*; + enum class LinkTarget { ReturnFromRunCode, }; struct EmittedBlockInfo { - void* entry_point; + CodePtr entry_point; size_t size; tsl::robin_map relocations; };