backend/arm64: void* -> CodePtr
This commit is contained in:
parent
f6e80f1e0e
commit
e0f091b6a6
4 changed files with 17 additions and 13 deletions
|
@ -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<uintptr_t>(code.ptr<void*>()) - reinterpret_cast<uintptr_t>(mem.ptr()));
|
||||
return conf.code_cache_size - (code.ptr<CodePtr>() - reinterpret_cast<CodePtr>(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<u32*>(reinterpret_cast<char*>(block_info.entry_point) + ptr_offset)};
|
||||
CodeGenerator c{reinterpret_cast<u32*>(block_info.entry_point + ptr_offset)};
|
||||
|
||||
switch (target) {
|
||||
case LinkTarget::ReturnFromRunCode:
|
||||
|
|
|
@ -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<u64, void*> block_entries;
|
||||
tsl::robin_map<u64, CodePtr> block_entries;
|
||||
tsl::robin_map<u64, EmittedBlockInfo> 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;
|
||||
|
|
|
@ -18,7 +18,7 @@ EmittedBlockInfo EmitArm64(oaknut::CodeGenerator& code, IR::Block block) {
|
|||
(void)block;
|
||||
|
||||
EmittedBlockInfo ebi;
|
||||
ebi.entry_point = code.ptr<void*>();
|
||||
ebi.entry_point = code.ptr<CodePtr>();
|
||||
|
||||
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<char*>() - reinterpret_cast<char*>(ebi.entry_point)] = LinkTarget::ReturnFromRunCode;
|
||||
ebi.relocations[code.ptr<CodePtr>() - ebi.entry_point] = LinkTarget::ReturnFromRunCode;
|
||||
code.NOP();
|
||||
|
||||
ebi.size = reinterpret_cast<size_t>(code.ptr<void*>()) - reinterpret_cast<size_t>(ebi.entry_point);
|
||||
ebi.size = code.ptr<CodePtr>() - ebi.entry_point;
|
||||
return ebi;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <mcl/stdint.hpp>
|
||||
#include <tsl/robin_map.h>
|
||||
|
||||
|
@ -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<std::ptrdiff_t, LinkTarget> relocations;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue