From 0921a4fb0495b7dfe96bb9c04f199ce88d7b4136 Mon Sep 17 00:00:00 2001 From: "Herman S." <429230+has207@users.noreply.github.com> Date: Wed, 15 Oct 2025 10:49:17 +0900 Subject: [PATCH] [x64/Linux] Return __m128i by value in xmm0 rather than a pointer --- src/xenia/cpu/backend/x64/x64_sequences.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index 99e320af2..5f59ada30 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -2855,12 +2855,24 @@ struct SHL_V128 : Sequence> { auto src1 = GetInputRegOrConstant(e, i.src1, e.xmm3); +#if XE_PLATFORM_WIN32 + // Windows x64 ABI: __m128i is passed by implicit pointer + e.lea(e.GetNativeParam(0), e.StashXmm(0, src1)); + if (i.src2.is_constant) { + e.mov(e.GetNativeParam(1), i.src2.constant()); + } else { + // Zero-extend the 8-bit register to avoid garbage in upper bits + e.movzx(e.GetNativeParam(1).cvt32(), i.src2); + } +#else + // Linux/Mac System V ABI: __m128i passed in xmm0, return in xmm0 + e.vmovaps(e.xmm0, src1); if (i.src2.is_constant) { e.mov(e.GetNativeParam(1), i.src2.constant()); } else { e.mov(e.GetNativeParam(1), i.src2); } - e.lea(e.GetNativeParam(0), e.StashXmm(0, src1)); +#endif e.CallNativeSafe(reinterpret_cast(EmulateShlV128)); e.vmovaps(i.dest, e.xmm0); }