From: Richard Sandiford <richard.sandiford@arm.com>
To: Evgeny Karpov <Evgeny.Karpov@microsoft.com>
Cc: "gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"Richard Earnshaw \(lists\)" <Richard.Earnshaw@arm.com>,
"Andrew Pinski \(QUIC\)" <quic_apinski@quicinc.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Radek Barton <radek.barton@microsoft.com>
Subject: Re: [PATCH v2 03/13] aarch64: Mark x18 register as a fixed register for MS ABI
Date: Wed, 10 Apr 2024 19:25:04 +0100 [thread overview]
Message-ID: <mptil0prs73.fsf@arm.com> (raw)
In-Reply-To: <VI1PR83MB0431632F79D188983B296B47F8232@VI1PR83MB0431.EURPRD83.prod.outlook.com> (Evgeny Karpov's message of "Mon, 4 Mar 2024 17:36:57 +0000")
Evgeny Karpov <Evgeny.Karpov@microsoft.com> writes:
> From: Zac Walker <zacwalker@microsoft.com>
> Date: Fri, 1 Mar 2024 09:56:59 +0100
> Subject: [PATCH v2 03/13] aarch64: Mark x18 register as a fixed register for
> MS ABI
>
> Define the MS ABI for aarch64-w64-mingw32.
> Adjust FIXED_REGISTERS, CALL_REALLY_USED_REGISTERS and
> STATIC_CHAIN_REGNUM for AArch64 MS ABI.
> The X18 register is reserved on Windows for the TEB.
>
> gcc/ChangeLog:
>
> * config.gcc: Define TARGET_AARCH64_MS_ABI when
> AArch64 MS ABI is used.
> * config/aarch64/aarch64-abi-ms.h: New file. Adjust
> FIXED_REGISTERS, CALL_REALLY_USED_REGISTERS and
> STATIC_CHAIN_REGNUM for AArch64 MS ABI.
> ---
> gcc/config.gcc | 1 +
> gcc/config/aarch64/aarch64-abi-ms.h | 64 +++++++++++++++++++++++++++++
> 2 files changed, 65 insertions(+)
> create mode 100644 gcc/config/aarch64/aarch64-abi-ms.h
>
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 2756377e50b..b762393b64c 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -1265,6 +1265,7 @@ aarch64*-*-linux*)
> TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
> ;;
> aarch64-*-mingw*)
> + tm_file="${tm_file} aarch64/aarch64-abi-ms.h"
> tmake_file="${tmake_file} aarch64/t-aarch64"
> case ${enable_threads} in
> "" | yes | win32)
> diff --git a/gcc/config/aarch64/aarch64-abi-ms.h b/gcc/config/aarch64/aarch64-abi-ms.h
> new file mode 100644
> index 00000000000..90b0dcc5edf
> --- /dev/null
> +++ b/gcc/config/aarch64/aarch64-abi-ms.h
> @@ -0,0 +1,64 @@
> +/* Machine description for AArch64 MS ABI.
> + Copyright (C) 2024 Free Software Foundation, Inc.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 3, or (at your option)
> +any later version.
> +
> +GCC is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with GCC; see the file COPYING3. If not see
> +<http://www.gnu.org/licenses/>. */
> +
> +#ifndef GCC_AARCH64_ABI_MS_H
> +#define GCC_AARCH64_ABI_MS_H
> +
> +/* X18 reserved for the TEB on Windows. */
> +
> +#undef FIXED_REGISTERS
> +#define FIXED_REGISTERS \
> + { \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* R0 - R7. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* R8 - R15. */ \
> + 0, 0, 1, 0, 0, 0, 0, 0, /* R16 - R23. */ \
> + 0, 0, 0, 0, 0, 1, 0, 1, /* R24 - R30, SP. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* V0 - V7. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* V16 - V23. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* V24 - V31. */ \
> + 1, 1, 1, 1, /* SFP, AP, CC, VG. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* P0 - P7. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* P8 - P15. */ \
> + 1, 1, /* FFR and FFRT. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1 /* Fake registers. */ \
> + }
> +
> +#undef CALL_REALLY_USED_REGISTERS
> +#define CALL_REALLY_USED_REGISTERS \
> + { \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* R0 - R7. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* R8 - R15. */ \
> + 1, 1, 0, 0, 0, 0, 0, 0, /* R16 - R23. */ \
> + 0, 0, 0, 0, 0, 1, 1, 1, /* R24 - R30, SP. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* V0 - V7. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0, /* V8 - V15. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* V16 - V23. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* V24 - V31. */ \
> + 1, 1, 1, 0, /* SFP, AP, CC, VG. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* P0 - P7. */ \
> + 1, 1, 1, 1, 1, 1, 1, 1, /* P8 - P15. */ \
> + 1, 1, /* FFR and FFRT. */ \
> + 0, 0, 0, 0, 0, 0, 0, 0 /* Fake registers. */ \
> + }
> +
> +#undef STATIC_CHAIN_REGNUM
> +#define STATIC_CHAIN_REGNUM R17_REGNUM
> +
> +#endif /* GCC_AARCH64_ABI_MS_H. */
Gah, I think there was a miscommunication, sorry. The way I'd interpreted
Richard's comment:
> +/* X18 reserved for the TEB on Windows. */
> +#ifdef TARGET_ARM64_MS_ABI
> +# define FIXED_X18 1
> +# define CALL_USED_X18 0
> +#else
> +# define FIXED_X18 0
> +# define CALL_USED_X18 1
> +#endif
>
> I'm not overly keen on ifdefs like this (and the one below), it can
> get quite confusing if we have to support more than a couple of ABIs.
> Perhaps we could create a couple of new headers, one for the EABI
> (which all existing targets would then need to include) and one for
> the MS ABI. Then the mingw port would use that instead of the EABI
> header.
was that aarch64.h should have:
#define FIXED_X18 0
#define CALL_USED_X18 1
and then aarch64-abi-ms.h should have:
#undef FIXED_X18
#define FIXED_X18 1
#undef CALL_USED_X18
#define CALL_USED_X18 0
similarly to STATIC_CHAIN_REGNUM. The goal is to keep aarch64.h "generic"
and have the port-specific files define the variations.
At least, that's what I'd prefer. It's certainly better not to
duplicate the whole of FIXED_REGISTERS, since there's a risk that
non-aarch64.h versions could get out of sync.
Thanks,
Richard
next prev parent reply other threads:[~2024-04-10 18:25 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 17:24 [PATCH v2 00/13] Add aarch64-w64-mingw32 target Evgeny Karpov
2024-03-04 17:30 ` [PATCH v2 01/13] Introduce " Evgeny Karpov
2024-03-04 17:33 ` [PATCH v2 02/13] aarch64: The aarch64-w64-mingw32 target implements Evgeny Karpov
2024-04-10 18:17 ` Richard Sandiford
2024-03-04 17:36 ` [PATCH v2 03/13] aarch64: Mark x18 register as a fixed register for MS ABI Evgeny Karpov
2024-04-10 18:25 ` Richard Sandiford [this message]
2024-03-04 17:39 ` [PATCH v2 04/13] aarch64: Add aarch64-w64-mingw32 COFF Evgeny Karpov
2024-04-10 18:31 ` Richard Sandiford
2024-03-04 17:39 ` [PATCH v2 05/13] Reuse MinGW from i386 for AArch64 Evgeny Karpov
2024-03-04 17:41 ` [PATCH v2 06/13] Rename section and encoding functions from i386 which will be used in aarch64 Evgeny Karpov
2024-03-04 17:43 ` [PATCH v2 07/13] Exclude i386 functionality from aarch64 build Evgeny Karpov
2024-03-04 17:44 ` [PATCH v2 08/13] aarch64: Add Cygwin and MinGW environments for AArch64 Evgeny Karpov
2024-03-18 13:26 ` Christophe Lyon
2024-03-18 21:35 ` Evgeny Karpov
2024-03-19 13:40 ` Christophe Lyon
2024-03-20 21:53 ` rep.dot.nop
2024-04-10 18:34 ` Richard Sandiford
2024-03-04 17:45 ` [PATCH v2 09/13] aarch64: Add SEH to machine_function Evgeny Karpov
2024-03-04 17:46 ` [PATCH v2 10/13] Rename "x86 Windows Options" to "Cygwin and MinGW Options" Evgeny Karpov
2024-04-10 18:35 ` Richard Sandiford
2024-03-04 17:49 ` [PATCH v2 11/13] aarch64: Build and add objects for Cygwin and MinGW for AArch64 Evgeny Karpov
2024-03-04 17:50 ` [PATCH v2 12/13] aarch64: Add aarch64-w64-mingw32 target to libatomic Evgeny Karpov
2024-03-04 17:51 ` [PATCH v2 13/13] Add aarch64-w64-mingw32 target to libgcc Evgeny Karpov
2024-03-04 17:55 ` [PATCH v2 00/13] Add aarch64-w64-mingw32 target Evgeny Karpov
2024-03-04 19:25 ` Evgeny Karpov
2024-03-07 20:47 ` Evgeny Karpov
2024-03-18 13:33 ` Christophe Lyon
2024-03-18 22:10 ` Evgeny Karpov
2024-03-18 22:58 ` Fangrui Song
2024-03-18 23:22 ` Andrew Pinski
2024-03-19 7:50 ` Martin Storsjö
2024-03-21 10:28 ` [PING][PATCH " Evgeny Karpov
2024-03-18 21:05 ` [PATCH " Radek Barton
2024-03-20 11:50 ` Radek Barton
2024-03-20 19:37 ` NightStrike
2024-04-10 18:40 ` Richard Sandiford
2024-04-11 14:14 ` Evgeny Karpov
2024-04-11 14:34 ` Richard Sandiford
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=mptil0prs73.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=Evgeny.Karpov@microsoft.com \
--cc=Richard.Earnshaw@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=maxim.kuvyrkov@linaro.org \
--cc=quic_apinski@quicinc.com \
--cc=radek.barton@microsoft.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).