From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org
Subject: Re: [PATCH] tcg/aarch64: Apple does not align __int128_t in even registers
Date: Sun, 18 Feb 2024 11:59:54 +0100 [thread overview]
Message-ID: <9fc0c2c7-dd57-459e-aecb-528edb74b4a7@linaro.org> (raw)
In-Reply-To: <20240216214547.10350-1-richard.henderson@linaro.org>
On 16/2/24 22:45, Richard Henderson wrote:
Please include your comment
https://gitlab.com/qemu-project/qemu/-/issues/2169#note_1777369822
---
Apple differs from the standard ABI in the alignment of __int128_t.
From Apple's documentation:
When passing an argument with 16-byte alignment in integer registers,
Apple platforms allow the argument to start in an odd-numbered xN
register. The standard ABI requires it to begin in an even-numbered
xN register.
This is confirmed with a simple test:
void g(int w, __int128_t x, int y);
void h(void)
{
g(-1, 0, 1);
}
which produces
mov w0, #-1
mov x1, #0
mov x2, #0
mov w3, #1
bl _g
using Apple clang version 14.0.0 (clang-1400.0.29.202). Note
that the x argument (the zeros) is loaded into x1 and x2 and
the y argument is loaded into w3.
On Linux, using the standard ARM ABI, this compiles to
mov w4, 1
mov x2, 0
mov x3, 0
mov w0, -1
bl g
Note that the x argument is loaded into x2 and x3, and the y
argument is loaded into w4.
The TCG JIT must be taught about this difference for MacOS.
---
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Cc: qemu-stable@nongnu.org
> Fixes: 5427a9a7604 ("tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2169
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>
> See the gitlab issue for complete discussion of the ABI.
>
> r~
>
> ---
> tcg/aarch64/tcg-target.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h
> index ef5ebe91bd..85d5746e47 100644
> --- a/tcg/aarch64/tcg-target.h
> +++ b/tcg/aarch64/tcg-target.h
> @@ -55,7 +55,11 @@ typedef enum {
> #define TCG_TARGET_CALL_STACK_OFFSET 0
> #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL
> #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL
> -#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN
> +#ifdef CONFIG_DARWIN
> +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL
> +#else
> +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN
> +#endif
> #define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL
>
> #define have_lse (cpuinfo & CPUINFO_LSE)
prev parent reply other threads:[~2024-02-18 11:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 21:45 [PATCH] tcg/aarch64: Apple does not align __int128_t in even registers Richard Henderson
2024-02-18 10:59 ` Philippe Mathieu-Daudé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9fc0c2c7-dd57-459e-aecb-528edb74b4a7@linaro.org \
--to=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).