aarch64: Add +lse128 architectural extension command-line flag
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
Given how, at present, the choice of using LSE128 atomic instructions
by the toolchain is delegated to run-time selection in the form of
Libatomic ifuncs, responsible for querying target support, the
`+lse128' target architecture compile-time flag is absent from GCC.
This, however, contrasts with the Binutils implementation, which gates
LSE128 instructions behind the `+lse128' flag. This can lead to
problems in GCC for certain use-cases. One such example is in the use
of inline assembly, whereby the inability of enabling the feature in
the command-line prevents the compiler from automatically issuing the
necessary LSE128 `.arch' directive.
This patch therefore brings GCC into alignment with LLVM and Binutils
in adding support for the `+lse128' architectural extension flag.
gcc/ChangeLog:
* config/aarch64/aarch64-option-extensions.def: Add LSE128
AARCH64_OPT_EXTENSION, adding it as a dependency for the D128
feature.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/lse128-flag.c: New.
* gcc.target/aarch64/cpunative/info_23: Likewise.
* gcc.target/aarch64/cpunative/native_cpu_23.c: Likewise.
---
gcc/config/aarch64/aarch64-option-extensions.def | 4 +++-
gcc/testsuite/gcc.target/aarch64/cpunative/info_23 | 8 ++++++++
.../gcc.target/aarch64/cpunative/native_cpu_23.c | 11 +++++++++++
gcc/testsuite/gcc.target/aarch64/lse128-flag.c | 10 ++++++++++
4 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/info_23
create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
create mode 100644 gcc/testsuite/gcc.target/aarch64/lse128-flag.c
Comments
On Fri, 15 Mar 2024 at 12:15, Victor Do Nascimento
<victor.donascimento@arm.com> wrote:
>
> Given how, at present, the choice of using LSE128 atomic instructions
> by the toolchain is delegated to run-time selection in the form of
> Libatomic ifuncs, responsible for querying target support, the
> `+lse128' target architecture compile-time flag is absent from GCC.
>
> This, however, contrasts with the Binutils implementation, which gates
> LSE128 instructions behind the `+lse128' flag. This can lead to
> problems in GCC for certain use-cases. One such example is in the use
> of inline assembly, whereby the inability of enabling the feature in
> the command-line prevents the compiler from automatically issuing the
> necessary LSE128 `.arch' directive.
>
> This patch therefore brings GCC into alignment with LLVM and Binutils
> in adding support for the `+lse128' architectural extension flag.
>
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-option-extensions.def: Add LSE128
> AARCH64_OPT_EXTENSION, adding it as a dependency for the D128
> feature.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/aarch64/lse128-flag.c: New.
> * gcc.target/aarch64/cpunative/info_23: Likewise.
> * gcc.target/aarch64/cpunative/native_cpu_23.c: Likewise.
> ---
> gcc/config/aarch64/aarch64-option-extensions.def | 4 +++-
> gcc/testsuite/gcc.target/aarch64/cpunative/info_23 | 8 ++++++++
> .../gcc.target/aarch64/cpunative/native_cpu_23.c | 11 +++++++++++
> gcc/testsuite/gcc.target/aarch64/lse128-flag.c | 10 ++++++++++
> 4 files changed, 32 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> create mode 100644 gcc/testsuite/gcc.target/aarch64/lse128-flag.c
>
> diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def
> index 1a3b91c68cf..ac54b899a06 100644
> --- a/gcc/config/aarch64/aarch64-option-extensions.def
> +++ b/gcc/config/aarch64/aarch64-option-extensions.def
> @@ -275,7 +275,9 @@ AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "")
>
> AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc")
>
> -AARCH64_OPT_EXTENSION("d128", D128, (), (), (), "d128")
> +AARCH64_OPT_EXTENSION("lse128", LSE128, (LSE), (), (), "lse128")
> +
> +AARCH64_OPT_EXTENSION("d128", D128, (LSE128), (), (), "d128")
>
FWIW, looks good to me, I noticed that now we'll also have the
dependency of d128 on lse128, although d128 didn't have the (implicit)
dependency on lse before.
Christophe
> AARCH64_OPT_EXTENSION("the", THE, (), (), (), "the")
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_23 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> new file mode 100644
> index 00000000000..d77c25d2f61
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> @@ -0,0 +1,8 @@
> +processor : 0
> +BogoMIPS : 100.00
> +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp atomics lse128
> +CPU implementer : 0xfe
> +CPU architecture: 8
> +CPU variant : 0x0
> +CPU part : 0xd08
> +CPU revision : 2
> \ No newline at end of file
> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> new file mode 100644
> index 00000000000..8a1e235d8ab
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
> +/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_23" } */
> +/* { dg-additional-options "-mcpu=native" } */
> +
> +int main()
> +{
> + return 0;
> +}
> +
> +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+lse128} } } */
> +/* Test one where lse128 is available and so should be emitted. */
> diff --git a/gcc/testsuite/gcc.target/aarch64/lse128-flag.c b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
> new file mode 100644
> index 00000000000..71339c3af6d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target { aarch64*-*-*} } } */
> +/* { dg-additional-options "-march=armv9.4-a+lse128" } */
> +
> +int main()
> +{
> + return 0;
> +}
> +
> +/* { dg-final { scan-assembler {\.arch armv9\.4-a\+crc\+lse128} } } */
> +/* Test a normal looking procinfo. */
> --
> 2.34.1
>
Victor Do Nascimento <victor.donascimento@arm.com> writes:
> Given how, at present, the choice of using LSE128 atomic instructions
> by the toolchain is delegated to run-time selection in the form of
> Libatomic ifuncs, responsible for querying target support, the
> `+lse128' target architecture compile-time flag is absent from GCC.
>
> This, however, contrasts with the Binutils implementation, which gates
> LSE128 instructions behind the `+lse128' flag. This can lead to
> problems in GCC for certain use-cases. One such example is in the use
> of inline assembly, whereby the inability of enabling the feature in
> the command-line prevents the compiler from automatically issuing the
> necessary LSE128 `.arch' directive.
>
> This patch therefore brings GCC into alignment with LLVM and Binutils
> in adding support for the `+lse128' architectural extension flag.
>
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-option-extensions.def: Add LSE128
> AARCH64_OPT_EXTENSION, adding it as a dependency for the D128
> feature.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/aarch64/lse128-flag.c: New.
> * gcc.target/aarch64/cpunative/info_23: Likewise.
> * gcc.target/aarch64/cpunative/native_cpu_23.c: Likewise.
The new extension should be documented in doc/invoke.texi.
> ---
> gcc/config/aarch64/aarch64-option-extensions.def | 4 +++-
> gcc/testsuite/gcc.target/aarch64/cpunative/info_23 | 8 ++++++++
> .../gcc.target/aarch64/cpunative/native_cpu_23.c | 11 +++++++++++
> gcc/testsuite/gcc.target/aarch64/lse128-flag.c | 10 ++++++++++
> 4 files changed, 32 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> create mode 100644 gcc/testsuite/gcc.target/aarch64/lse128-flag.c
>
> diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def
> index 1a3b91c68cf..ac54b899a06 100644
> --- a/gcc/config/aarch64/aarch64-option-extensions.def
> +++ b/gcc/config/aarch64/aarch64-option-extensions.def
> @@ -275,7 +275,9 @@ AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "")
>
> AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc")
>
> -AARCH64_OPT_EXTENSION("d128", D128, (), (), (), "d128")
> +AARCH64_OPT_EXTENSION("lse128", LSE128, (LSE), (), (), "lse128")
> +
> +AARCH64_OPT_EXTENSION("d128", D128, (LSE128), (), (), "d128")
>
> AARCH64_OPT_EXTENSION("the", THE, (), (), (), "the")
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_23 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> new file mode 100644
> index 00000000000..d77c25d2f61
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
> @@ -0,0 +1,8 @@
> +processor : 0
> +BogoMIPS : 100.00
> +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp atomics lse128
> +CPU implementer : 0xfe
> +CPU architecture: 8
> +CPU variant : 0x0
> +CPU part : 0xd08
> +CPU revision : 2
> \ No newline at end of file
> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> new file mode 100644
> index 00000000000..8a1e235d8ab
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
> +/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_23" } */
> +/* { dg-additional-options "-mcpu=native" } */
> +
> +int main()
> +{
> + return 0;
> +}
> +
> +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+lse128} } } */
> +/* Test one where lse128 is available and so should be emitted. */
> diff --git a/gcc/testsuite/gcc.target/aarch64/lse128-flag.c b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
> new file mode 100644
> index 00000000000..71339c3af6d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target { aarch64*-*-*} } } */
> +/* { dg-additional-options "-march=armv9.4-a+lse128" } */
> +
> +int main()
> +{
> + return 0;
> +}
> +
> +/* { dg-final { scan-assembler {\.arch armv9\.4-a\+crc\+lse128} } } */
> +/* Test a normal looking procinfo. */
Not sure I understand the comment. Is procinfo part of this test?
Looks good otherwise.
Thanks,
Richard
On Mär 15 2024, Victor Do Nascimento wrote:
> \ No newline at end of file
Please fix that.
On 3/26/24 12:26, Richard Sandiford wrote:
> Victor Do Nascimento <victor.donascimento@arm.com> writes:
>> Given how, at present, the choice of using LSE128 atomic instructions
>> by the toolchain is delegated to run-time selection in the form of
>> Libatomic ifuncs, responsible for querying target support, the
>> `+lse128' target architecture compile-time flag is absent from GCC.
>>
>> This, however, contrasts with the Binutils implementation, which gates
>> LSE128 instructions behind the `+lse128' flag. This can lead to
>> problems in GCC for certain use-cases. One such example is in the use
>> of inline assembly, whereby the inability of enabling the feature in
>> the command-line prevents the compiler from automatically issuing the
>> necessary LSE128 `.arch' directive.
>>
>> This patch therefore brings GCC into alignment with LLVM and Binutils
>> in adding support for the `+lse128' architectural extension flag.
>>
>> gcc/ChangeLog:
>>
>> * config/aarch64/aarch64-option-extensions.def: Add LSE128
>> AARCH64_OPT_EXTENSION, adding it as a dependency for the D128
>> feature.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.target/aarch64/lse128-flag.c: New.
>> * gcc.target/aarch64/cpunative/info_23: Likewise.
>> * gcc.target/aarch64/cpunative/native_cpu_23.c: Likewise.
>
> The new extension should be documented in doc/invoke.texi.
>
>> ---
>> gcc/config/aarch64/aarch64-option-extensions.def | 4 +++-
>> gcc/testsuite/gcc.target/aarch64/cpunative/info_23 | 8 ++++++++
>> .../gcc.target/aarch64/cpunative/native_cpu_23.c | 11 +++++++++++
>> gcc/testsuite/gcc.target/aarch64/lse128-flag.c | 10 ++++++++++
>> 4 files changed, 32 insertions(+), 1 deletion(-)
>> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/info_23
>> create mode 100644 gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
>> create mode 100644 gcc/testsuite/gcc.target/aarch64/lse128-flag.c
>>
>> diff --git a/gcc/config/aarch64/aarch64-option-extensions.def b/gcc/config/aarch64/aarch64-option-extensions.def
>> index 1a3b91c68cf..ac54b899a06 100644
>> --- a/gcc/config/aarch64/aarch64-option-extensions.def
>> +++ b/gcc/config/aarch64/aarch64-option-extensions.def
>> @@ -275,7 +275,9 @@ AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "")
>>
>> AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc")
>>
>> -AARCH64_OPT_EXTENSION("d128", D128, (), (), (), "d128")
>> +AARCH64_OPT_EXTENSION("lse128", LSE128, (LSE), (), (), "lse128")
>> +
>> +AARCH64_OPT_EXTENSION("d128", D128, (LSE128), (), (), "d128")
>>
>> AARCH64_OPT_EXTENSION("the", THE, (), (), (), "the")
>>
>> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_23 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
>> new file mode 100644
>> index 00000000000..d77c25d2f61
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_23
>> @@ -0,0 +1,8 @@
>> +processor : 0
>> +BogoMIPS : 100.00
>> +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp atomics lse128
>> +CPU implementer : 0xfe
>> +CPU architecture: 8
>> +CPU variant : 0x0
>> +CPU part : 0xd08
>> +CPU revision : 2
>> \ No newline at end of file
>> diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
>> new file mode 100644
>> index 00000000000..8a1e235d8ab
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_23.c
>> @@ -0,0 +1,11 @@
>> +/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
>> +/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_23" } */
>> +/* { dg-additional-options "-mcpu=native" } */
>> +
>> +int main()
>> +{
>> + return 0;
>> +}
>> +
>> +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+lse128} } } */
>> +/* Test one where lse128 is available and so should be emitted. */
>> diff --git a/gcc/testsuite/gcc.target/aarch64/lse128-flag.c b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
>> new file mode 100644
>> index 00000000000..71339c3af6d
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/aarch64/lse128-flag.c
>> @@ -0,0 +1,10 @@
>> +/* { dg-do compile { target { aarch64*-*-*} } } */
>> +/* { dg-additional-options "-march=armv9.4-a+lse128" } */
>> +
>> +int main()
>> +{
>> + return 0;
>> +}
>> +
>> +/* { dg-final { scan-assembler {\.arch armv9\.4-a\+crc\+lse128} } } */
>> +/* Test a normal looking procinfo. */
>
> Not sure I understand the comment. Is procinfo part of this test?
Thank you for catching this, Richard. This was originally a
procinfo-reliant test which ended up being redesigned without reference
to procinfo and this remained. I've now dropped it from the patch.
Cheers!
> Looks good otherwise.
>
> Thanks,
> Richard
@@ -275,7 +275,9 @@ AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "")
AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc")
-AARCH64_OPT_EXTENSION("d128", D128, (), (), (), "d128")
+AARCH64_OPT_EXTENSION("lse128", LSE128, (LSE), (), (), "lse128")
+
+AARCH64_OPT_EXTENSION("d128", D128, (LSE128), (), (), "d128")
AARCH64_OPT_EXTENSION("the", THE, (), (), (), "the")
new file mode 100644
@@ -0,0 +1,8 @@
+processor : 0
+BogoMIPS : 100.00
+Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp atomics lse128
+CPU implementer : 0xfe
+CPU architecture: 8
+CPU variant : 0x0
+CPU part : 0xd08
+CPU revision : 2
\ No newline at end of file
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
+/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_23" } */
+/* { dg-additional-options "-mcpu=native" } */
+
+int main()
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+lse128} } } */
+/* Test one where lse128 is available and so should be emitted. */
new file mode 100644
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { aarch64*-*-*} } } */
+/* { dg-additional-options "-march=armv9.4-a+lse128" } */
+
+int main()
+{
+ return 0;
+}
+
+/* { dg-final { scan-assembler {\.arch armv9\.4-a\+crc\+lse128} } } */
+/* Test a normal looking procinfo. */