From e7c40662b790b037a5a5bad89cb84cb26cbe70b8 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 6 Dec 2025 02:40:12 +0000 Subject: [PATCH] [dynarmic] remove hostloc.cpp --- src/dynarmic/src/dynarmic/CMakeLists.txt | 1 - .../dynarmic/backend/x64/emit_x64_crc32.cpp | 3 + .../backend/x64/emit_x64_floating_point.cpp | 60 +++++++++---------- .../dynarmic/backend/x64/emit_x64_packed.cpp | 3 + .../src/dynarmic/backend/x64/emit_x64_sha.cpp | 3 + .../src/dynarmic/backend/x64/emit_x64_sm4.cpp | 3 + .../src/dynarmic/backend/x64/hostloc.cpp | 25 -------- .../src/dynarmic/backend/x64/hostloc.h | 11 +++- 8 files changed, 51 insertions(+), 58 deletions(-) delete mode 100644 src/dynarmic/src/dynarmic/backend/x64/hostloc.cpp diff --git a/src/dynarmic/src/dynarmic/CMakeLists.txt b/src/dynarmic/src/dynarmic/CMakeLists.txt index 5d52637ec3..9575eaab6f 100644 --- a/src/dynarmic/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/src/dynarmic/CMakeLists.txt @@ -175,7 +175,6 @@ if ("x86_64" IN_LIST ARCHITECTURE) backend/x64/exclusive_monitor.cpp backend/x64/exclusive_monitor_friend.h backend/x64/host_feature.h - backend/x64/hostloc.cpp backend/x64/hostloc.h backend/x64/jitstate_info.h backend/x64/oparg.h diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_crc32.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_crc32.cpp index 67bd792da0..48983fa513 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_crc32.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_crc32.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2018 MerryMage * SPDX-License-Identifier: 0BSD diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_floating_point.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_floating_point.cpp index 2a07fcc4d2..6e618130c4 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_floating_point.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_floating_point.cpp @@ -410,8 +410,8 @@ void EmitX64::EmitFPDiv64(EmitContext& ctx, IR::Inst* inst) { FPThreeOp<64>(code, ctx, inst, &Xbyak::CodeGenerator::divsd); } -template -static void EmitFPMinMax(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { +template +static void EmitFPMinMax(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, bool is_max) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm result = ctx.reg_alloc.UseScratchXmm(code, args[0]); @@ -425,7 +425,7 @@ static void EmitFPMinMax(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { FCODE(ucomis)(result, operand); code.jz(*equal, code.T_NEAR); - if constexpr (is_max) { + if (is_max) { FCODE(maxs)(result, operand); } else { FCODE(mins)(result, operand); @@ -437,7 +437,7 @@ static void EmitFPMinMax(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { code.L(*equal); code.jp(nan); - if constexpr (is_max) { + if (is_max) { code.andps(result, operand); } else { code.orps(result, operand); @@ -458,8 +458,8 @@ static void EmitFPMinMax(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { ctx.reg_alloc.DefineValue(code, inst, result); } -template -static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) noexcept { +template +static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, bool is_max) noexcept { using FPT = mcl::unsigned_integer_of_size; constexpr FPT default_nan = FP::FPInfo::DefaultNaN(); @@ -473,7 +473,7 @@ static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR:: if (code.HasHostFeature(HostFeature::AVX512_OrthoFloat)) { // vrangep{s,d} will already correctly handle comparing // signed zeros and propagating NaNs similar to ARM - constexpr FpRangeSelect range_select = is_max ? FpRangeSelect::Max : FpRangeSelect::Min; + FpRangeSelect const range_select = is_max ? FpRangeSelect::Max : FpRangeSelect::Min; FCODE(vranges)(op2, op1, op2, FpRangeLUT(range_select, FpRangeSign::Preserve)); if (ctx.FPCR().DN()) { @@ -496,7 +496,7 @@ static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR:: FCODE(ucomis)(op1, op2); code.jz(*z, code.T_NEAR); - if constexpr (is_max) { + if (is_max) { FCODE(maxs)(op2, op1); } else { FCODE(mins)(op2, op1); @@ -510,7 +510,7 @@ static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR:: code.L(*z); code.jp(nan); - if constexpr (is_max) { + if (is_max) { code.andps(op2, op1); } else { code.orps(op2, op1); @@ -571,35 +571,35 @@ static inline void EmitFPMinMaxNumeric(BlockOfCode& code, EmitContext& ctx, IR:: } void EmitX64::EmitFPMax32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMax<32, true>(code, ctx, inst); + EmitFPMinMax<32>(code, ctx, inst, true); } void EmitX64::EmitFPMax64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMax<64, true>(code, ctx, inst); + EmitFPMinMax<64>(code, ctx, inst, true); } void EmitX64::EmitFPMaxNumeric32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMaxNumeric<32, true>(code, ctx, inst); + EmitFPMinMaxNumeric<32>(code, ctx, inst, true); } void EmitX64::EmitFPMaxNumeric64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMaxNumeric<64, true>(code, ctx, inst); + EmitFPMinMaxNumeric<64>(code, ctx, inst, true); } void EmitX64::EmitFPMin32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMax<32, false>(code, ctx, inst); + EmitFPMinMax<32>(code, ctx, inst, false); } void EmitX64::EmitFPMin64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMax<64, false>(code, ctx, inst); + EmitFPMinMax<64>(code, ctx, inst, false); } void EmitX64::EmitFPMinNumeric32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMaxNumeric<32, false>(code, ctx, inst); + EmitFPMinMaxNumeric<32>(code, ctx, inst, false); } void EmitX64::EmitFPMinNumeric64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMinMaxNumeric<64, false>(code, ctx, inst); + EmitFPMinMaxNumeric<64>(code, ctx, inst, false); } void EmitX64::EmitFPMul32(EmitContext& ctx, IR::Inst* inst) { @@ -610,8 +610,8 @@ void EmitX64::EmitFPMul64(EmitContext& ctx, IR::Inst* inst) { FPThreeOp<64>(code, ctx, inst, &Xbyak::CodeGenerator::mulsd); } -template -static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { +template +static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, bool negate_product) { using FPT = mcl::unsigned_integer_of_size; const auto fallback_fn = negate_product ? &FP::FPMulSub : &FP::FPMulAdd; @@ -626,7 +626,7 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { const Xbyak::Xmm operand2 = ctx.reg_alloc.UseXmm(code, args[1]); const Xbyak::Xmm operand3 = ctx.reg_alloc.UseXmm(code, args[2]); - if constexpr (negate_product) { + if (negate_product) { FCODE(vfnmadd231s)(result, operand2, operand3); } else { FCODE(vfmadd231s)(result, operand2, operand3); @@ -648,7 +648,7 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { const Xbyak::Xmm result = ctx.reg_alloc.ScratchXmm(code); code.movaps(result, operand1); - if constexpr (negate_product) { + if (negate_product) { FCODE(vfnmadd231s)(result, operand2, operand3); } else { FCODE(vfmadd231s)(result, operand2, operand3); @@ -752,7 +752,7 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { code.ptest(operand2, xmm0); code.jnz(op2_done); code.vorps(result, operand2, xmm0); - if constexpr (negate_product) { + if (negate_product) { code.xorps(result, code.Const(xword, FP::FPInfo::sign_mask)); } code.jmp(*end); @@ -768,7 +768,7 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { // at this point, all SNaNs have been handled // if op1 was not a QNaN and op2 is, negate the result - if constexpr (negate_product) { + if (negate_product) { FCODE(ucomis)(operand1, operand1); code.jp(*end); FCODE(ucomis)(operand2, operand2); @@ -789,7 +789,7 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { const Xbyak::Xmm operand2 = ctx.reg_alloc.UseScratchXmm(code, args[1]); const Xbyak::Xmm operand3 = ctx.reg_alloc.UseXmm(code, args[2]); - if constexpr (negate_product) { + if (negate_product) { code.xorps(operand2, code.Const(xword, FP::FPInfo::sign_mask)); } FCODE(muls)(operand2, operand3); @@ -815,27 +815,27 @@ static void EmitFPMulAdd(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) { } void EmitX64::EmitFPMulAdd16(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<16, false>(code, ctx, inst); + EmitFPMulAdd<16>(code, ctx, inst, false); } void EmitX64::EmitFPMulAdd32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<32, false>(code, ctx, inst); + EmitFPMulAdd<32>(code, ctx, inst, false); } void EmitX64::EmitFPMulAdd64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<64, false>(code, ctx, inst); + EmitFPMulAdd<64>(code, ctx, inst, false); } void EmitX64::EmitFPMulSub16(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<16, true>(code, ctx, inst); + EmitFPMulAdd<16>(code, ctx, inst, true); } void EmitX64::EmitFPMulSub32(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<32, true>(code, ctx, inst); + EmitFPMulAdd<32>(code, ctx, inst, true); } void EmitX64::EmitFPMulSub64(EmitContext& ctx, IR::Inst* inst) { - EmitFPMulAdd<64, true>(code, ctx, inst); + EmitFPMulAdd<64>(code, ctx, inst, true); } template diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_packed.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_packed.cpp index d09dea7ddb..c29d7d2648 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_packed.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_packed.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2016 MerryMage * SPDX-License-Identifier: 0BSD diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sha.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sha.cpp index 099670173b..cd166f0cb8 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sha.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sha.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2022 MerryMage * SPDX-License-Identifier: 0BSD diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp index 756d909039..e121e3119e 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_sm4.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + /* This file is part of the dynarmic project. * Copyright (c) 2018 MerryMage * SPDX-License-Identifier: 0BSD diff --git a/src/dynarmic/src/dynarmic/backend/x64/hostloc.cpp b/src/dynarmic/src/dynarmic/backend/x64/hostloc.cpp deleted file mode 100644 index b5e2a5f18b..0000000000 --- a/src/dynarmic/src/dynarmic/backend/x64/hostloc.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* This file is part of the dynarmic project. - * Copyright (c) 2016 MerryMage - * SPDX-License-Identifier: 0BSD - */ - -#include "dynarmic/backend/x64/hostloc.h" - -#include - -#include "dynarmic/backend/x64/abi.h" -#include "dynarmic/backend/x64/stack_layout.h" - -namespace Dynarmic::Backend::X64 { - -Xbyak::Reg64 HostLocToReg64(HostLoc loc) { - ASSERT(HostLocIsGPR(loc)); - return Xbyak::Reg64(static_cast(loc)); -} - -Xbyak::Xmm HostLocToXmm(HostLoc loc) { - ASSERT(HostLocIsXMM(loc)); - return Xbyak::Xmm(static_cast(loc) - static_cast(HostLoc::XMM0)); -} - -} // namespace Dynarmic::Backend::X64 diff --git a/src/dynarmic/src/dynarmic/backend/x64/hostloc.h b/src/dynarmic/src/dynarmic/backend/x64/hostloc.h index d6fb88554e..65eeb11b55 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/hostloc.h +++ b/src/dynarmic/src/dynarmic/backend/x64/hostloc.h @@ -152,7 +152,14 @@ const HostLocList any_xmm = { HostLoc::XMM15, }; -Xbyak::Reg64 HostLocToReg64(HostLoc loc); -Xbyak::Xmm HostLocToXmm(HostLoc loc); +inline Xbyak::Reg64 HostLocToReg64(HostLoc loc) noexcept { + ASSERT(HostLocIsGPR(loc)); + return Xbyak::Reg64(int(loc)); +} + +inline Xbyak::Xmm HostLocToXmm(HostLoc loc) noexcept { + ASSERT(HostLocIsXMM(loc)); + return Xbyak::Xmm(int(loc) - int(HostLoc::XMM0)); +} } // namespace Dynarmic::Backend::X64