From 08ed8b4a116ce5679801573fde8bf448daad018e Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 21 Apr 2021 18:25:04 +0100 Subject: [PATCH] abi: Consolodate ABI information into one place --- src/backend/x64/abi.h | 8 ++++++++ src/backend/x64/block_of_code.cpp | 31 ++++++++++++++++--------------- src/backend/x64/block_of_code.h | 5 +++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/backend/x64/abi.h b/src/backend/x64/abi.h index 1d8e05bc..069e5039 100644 --- a/src/backend/x64/abi.h +++ b/src/backend/x64/abi.h @@ -6,6 +6,7 @@ #include +#include "common/common_types.h" #include "backend/x64/hostloc.h" namespace Dynarmic::Backend::X64 { @@ -16,6 +17,8 @@ class BlockOfCode; constexpr HostLoc ABI_RETURN = HostLoc::RAX; +constexpr size_t ABI_PARAM_COUNT = 4; + constexpr HostLoc ABI_PARAM1 = HostLoc::RCX; constexpr HostLoc ABI_PARAM2 = HostLoc::RDX; constexpr HostLoc ABI_PARAM3 = HostLoc::R8; @@ -63,11 +66,16 @@ constexpr size_t ABI_SHADOW_SPACE = 32; // bytes #else constexpr HostLoc ABI_RETURN = HostLoc::RAX; +constexpr HostLoc ABI_RETURN2 = HostLoc::RDX; + +constexpr size_t ABI_PARAM_COUNT = 6; constexpr HostLoc ABI_PARAM1 = HostLoc::RDI; constexpr HostLoc ABI_PARAM2 = HostLoc::RSI; constexpr HostLoc ABI_PARAM3 = HostLoc::RDX; constexpr HostLoc ABI_PARAM4 = HostLoc::RCX; +constexpr HostLoc ABI_PARAM5 = HostLoc::R8; +constexpr HostLoc ABI_PARAM6 = HostLoc::R9; constexpr std::array ABI_ALL_CALLER_SAVE = { HostLoc::RAX, diff --git a/src/backend/x64/block_of_code.cpp b/src/backend/x64/block_of_code.cpp index 59044e52..169fea74 100644 --- a/src/backend/x64/block_of_code.cpp +++ b/src/backend/x64/block_of_code.cpp @@ -11,6 +11,7 @@ #include "backend/x64/a32_jitstate.h" #include "backend/x64/abi.h" #include "backend/x64/block_of_code.h" +#include "backend/x64/hostloc.h" #include "backend/x64/perf_map.h" #include "common/assert.h" #include "common/bit_util.h" @@ -24,22 +25,22 @@ namespace Dynarmic::Backend::X64 { #ifdef _WIN32 -const Xbyak::Reg64 BlockOfCode::ABI_RETURN = Xbyak::util::rax; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM1 = Xbyak::util::rcx; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM2 = Xbyak::util::rdx; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM3 = Xbyak::util::r8; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM4 = Xbyak::util::r9; -const std::array BlockOfCode::ABI_PARAMS = {BlockOfCode::ABI_PARAM1, BlockOfCode::ABI_PARAM2, BlockOfCode::ABI_PARAM3, BlockOfCode::ABI_PARAM4}; +const Xbyak::Reg64 BlockOfCode::ABI_RETURN = HostLocToReg64(Dynarmic::Backend::X64::ABI_RETURN); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM1 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM1); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM2 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM2); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM3 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM3); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM4 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM4); +const std::array BlockOfCode::ABI_PARAMS = {BlockOfCode::ABI_PARAM1, BlockOfCode::ABI_PARAM2, BlockOfCode::ABI_PARAM3, BlockOfCode::ABI_PARAM4}; #else -const Xbyak::Reg64 BlockOfCode::ABI_RETURN = Xbyak::util::rax; -const Xbyak::Reg64 BlockOfCode::ABI_RETURN2 = Xbyak::util::rdx; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM1 = Xbyak::util::rdi; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM2 = Xbyak::util::rsi; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM3 = Xbyak::util::rdx; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM4 = Xbyak::util::rcx; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM5 = Xbyak::util::r8; -const Xbyak::Reg64 BlockOfCode::ABI_PARAM6 = Xbyak::util::r9; -const std::array BlockOfCode::ABI_PARAMS = {BlockOfCode::ABI_PARAM1, BlockOfCode::ABI_PARAM2, BlockOfCode::ABI_PARAM3, BlockOfCode::ABI_PARAM4, BlockOfCode::ABI_PARAM5, BlockOfCode::ABI_PARAM6}; +const Xbyak::Reg64 BlockOfCode::ABI_RETURN = HostLocToReg64(Dynarmic::Backend::X64::ABI_RETURN); +const Xbyak::Reg64 BlockOfCode::ABI_RETURN2 = HostLocToReg64(Dynarmic::Backend::X64::ABI_RETURN2); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM1 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM1); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM2 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM2); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM3 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM3); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM4 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM4); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM5 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM5); +const Xbyak::Reg64 BlockOfCode::ABI_PARAM6 = HostLocToReg64(Dynarmic::Backend::X64::ABI_PARAM6); +const std::array BlockOfCode::ABI_PARAMS = {BlockOfCode::ABI_PARAM1, BlockOfCode::ABI_PARAM2, BlockOfCode::ABI_PARAM3, BlockOfCode::ABI_PARAM4, BlockOfCode::ABI_PARAM5, BlockOfCode::ABI_PARAM6}; #endif namespace { diff --git a/src/backend/x64/block_of_code.h b/src/backend/x64/block_of_code.h index 596c31bd..d0be0026 100644 --- a/src/backend/x64/block_of_code.h +++ b/src/backend/x64/block_of_code.h @@ -13,6 +13,7 @@ #include #include +#include "backend/x64/abi.h" #include "backend/x64/callback.h" #include "backend/x64/constant_pool.h" #include "backend/x64/jitstate_info.h" @@ -129,7 +130,7 @@ public: static const Xbyak::Reg64 ABI_PARAM2; static const Xbyak::Reg64 ABI_PARAM3; static const Xbyak::Reg64 ABI_PARAM4; - static const std::array ABI_PARAMS; + static const std::array ABI_PARAMS; #else static const Xbyak::Reg64 ABI_RETURN; static const Xbyak::Reg64 ABI_RETURN2; @@ -139,7 +140,7 @@ public: static const Xbyak::Reg64 ABI_PARAM4; static const Xbyak::Reg64 ABI_PARAM5; static const Xbyak::Reg64 ABI_PARAM6; - static const std::array ABI_PARAMS; + static const std::array ABI_PARAMS; #endif JitStateInfo GetJitStateInfo() const { return jsi; }