diff options
author | Alex Coplan <alex.coplan@arm.com> | 2023-06-06 15:19:03 +0100 |
---|---|---|
committer | Alex Coplan <alex.coplan@arm.com> | 2023-06-07 17:43:15 +0100 |
commit | 9963029a24f2d2510b82e7106fae3f364da33c5d (patch) | |
tree | e766588877351e1bc6c074f5a796f2b77d25a070 | |
parent | 737a0b749a7bc3e7cb904ea2d4b18dc130514b85 (diff) | |
download | gcc-9963029a24f2d2510b82e7106fae3f364da33c5d.zip gcc-9963029a24f2d2510b82e7106fae3f364da33c5d.tar.gz gcc-9963029a24f2d2510b82e7106fae3f364da33c5d.tar.bz2 |
aarch64: Allow compiler to define ls64 builtins [PR110132]
This patch refactors the ls64 builtins to allow the compiler to define them
directly instead of having wrapper functions in arm_acle.h. This should be not
only easier to maintain, but it makes two important correctness fixes:
- It fixes PR110132, where the builtins ended up getting declared with
invisible bindings in the C FE, so the FE ended up synthesizing
incompatible implicit definitions for these builtins.
- It allows the builtins to be used with LTO, which didn't work previously.
We also take the opportunity to add test coverage from C++ for these
builtins.
gcc/ChangeLog:
PR target/110132
* config/aarch64/aarch64-builtins.cc (aarch64_general_simulate_builtin):
New. Use it ...
(aarch64_init_ls64_builtins): ... here. Switch to declaring public ACLE
names for builtins.
(aarch64_general_init_builtins): Ensure we invoke the arm_acle.h
setup if in_lto_p, just like we do for SVE.
* config/aarch64/arm_acle.h: (__arm_ld64b): Delete.
(__arm_st64b): Delete.
(__arm_st64bv): Delete.
(__arm_st64bv0): Delete.
gcc/testsuite/ChangeLog:
PR target/110132
* lib/target-supports.exp (check_effective_target_aarch64_asm_FUNC_ok):
Extend to ls64.
* g++.target/aarch64/acle/acle.exp: New.
* g++.target/aarch64/acle/ls64.C: New test.
* g++.target/aarch64/acle/ls64_lto.C: New test.
* gcc.target/aarch64/acle/ls64_lto.c: New test.
* gcc.target/aarch64/acle/pr110132.c: New test.
-rw-r--r-- | gcc/config/aarch64/aarch64-builtins.cc | 24 | ||||
-rw-r--r-- | gcc/config/aarch64/arm_acle.h | 33 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/aarch64/acle/acle.exp | 35 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/aarch64/acle/ls64.C | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/aarch64/acle/ls64_lto.C | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/acle/ls64_lto.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/acle/pr110132.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 2 |
8 files changed, 100 insertions, 39 deletions
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc index 1a4507f..04f59fd 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc @@ -956,6 +956,16 @@ aarch64_general_add_builtin (const char *name, tree type, unsigned int code, NULL, attrs); } +static tree +aarch64_general_simulate_builtin (const char *name, tree fntype, + unsigned int code, + tree attrs = NULL_TREE) +{ + code = (code << AARCH64_BUILTIN_SHIFT) | AARCH64_BUILTIN_GENERAL; + return simulate_builtin_function_decl (input_location, name, fntype, + code, NULL, attrs); +} + static const char * aarch64_mangle_builtin_scalar_type (const_tree type) { @@ -1879,23 +1889,24 @@ aarch64_init_ls64_builtins (void) aarch64_init_ls64_builtins_types (); ls64_builtins_data data[4] = { - {"__builtin_aarch64_ld64b", AARCH64_LS64_BUILTIN_LD64B, + {"__arm_ld64b", AARCH64_LS64_BUILTIN_LD64B, build_function_type_list (ls64_arm_data_t, const_ptr_type_node, NULL_TREE)}, - {"__builtin_aarch64_st64b", AARCH64_LS64_BUILTIN_ST64B, + {"__arm_st64b", AARCH64_LS64_BUILTIN_ST64B, build_function_type_list (void_type_node, ptr_type_node, ls64_arm_data_t, NULL_TREE)}, - {"__builtin_aarch64_st64bv", AARCH64_LS64_BUILTIN_ST64BV, + {"__arm_st64bv", AARCH64_LS64_BUILTIN_ST64BV, build_function_type_list (uint64_type_node, ptr_type_node, ls64_arm_data_t, NULL_TREE)}, - {"__builtin_aarch64_st64bv0", AARCH64_LS64_BUILTIN_ST64BV0, + {"__arm_st64bv0", AARCH64_LS64_BUILTIN_ST64BV0, build_function_type_list (uint64_type_node, ptr_type_node, ls64_arm_data_t, NULL_TREE)}, }; for (size_t i = 0; i < ARRAY_SIZE (data); ++i) aarch64_builtin_decls[data[i].code] - = aarch64_general_add_builtin (data[i].name, data[i].type, data[i].code); + = aarch64_general_simulate_builtin (data[i].name, data[i].type, + data[i].code); } static void @@ -2028,6 +2039,9 @@ aarch64_general_init_builtins (void) if (TARGET_MEMTAG) aarch64_init_memtag_builtins (); + + if (in_lto_p) + handle_arm_acle_h (); } /* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group. */ diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h index e0ac591..3b6b63e 100644 --- a/gcc/config/aarch64/arm_acle.h +++ b/gcc/config/aarch64/arm_acle.h @@ -270,40 +270,7 @@ __ttest (void) #endif #ifdef __ARM_FEATURE_LS64 -#pragma GCC push_options -#pragma GCC target ("+nothing+ls64") - typedef __arm_data512_t data512_t; - -__extension__ extern __inline data512_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -__arm_ld64b (const void *__addr) -{ - return __builtin_aarch64_ld64b (__addr); -} - -__extension__ extern __inline void -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -__arm_st64b (void *__addr, data512_t __value) -{ - __builtin_aarch64_st64b (__addr, __value); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -__arm_st64bv (void *__addr, data512_t __value) -{ - return __builtin_aarch64_st64bv (__addr, __value); -} - -__extension__ extern __inline uint64_t -__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) -__arm_st64bv0 (void *__addr, data512_t __value) -{ - return __builtin_aarch64_st64bv0 (__addr, __value); -} - -#pragma GCC pop_options #endif #pragma GCC push_options diff --git a/gcc/testsuite/g++.target/aarch64/acle/acle.exp b/gcc/testsuite/g++.target/aarch64/acle/acle.exp new file mode 100644 index 0000000..9e1cbf4 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/acle/acle.exp @@ -0,0 +1,35 @@ +# Copyright (C) 2014-2023 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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/>. + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't an AArch64 target. +if ![istarget aarch64*-*-*] then { + return +} + +# Load support procs. +load_lib g++-dg.exp + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ + "" "" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.target/aarch64/acle/ls64.C b/gcc/testsuite/g++.target/aarch64/acle/ls64.C new file mode 100644 index 0000000..d900278 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/acle/ls64.C @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8.7-a" } */ +#include <arm_acle.h> +int main() +{ + data512_t d = __arm_ld64b ((const void *)0x1000); + __arm_st64b ((void *)0x2000, d); + uint64_t x = __arm_st64bv ((void *)0x3000, d); + x += __arm_st64bv0 ((void *)0x4000, d); +} diff --git a/gcc/testsuite/g++.target/aarch64/acle/ls64_lto.C b/gcc/testsuite/g++.target/aarch64/acle/ls64_lto.C new file mode 100644 index 0000000..274a477 --- /dev/null +++ b/gcc/testsuite/g++.target/aarch64/acle/ls64_lto.C @@ -0,0 +1,10 @@ +/* { dg-do link { target aarch64_asm_ls64_ok } } */ +/* { dg-additional-options "-march=armv8.7-a -flto" } */ +#include <arm_acle.h> +int main() +{ + data512_t d = __arm_ld64b ((const void *)0x1000); + __arm_st64b ((void *)0x2000, d); + uint64_t x = __arm_st64bv ((void *)0x3000, d); + x += __arm_st64bv0 ((void *)0x4000, d); +} diff --git a/gcc/testsuite/gcc.target/aarch64/acle/ls64_lto.c b/gcc/testsuite/gcc.target/aarch64/acle/ls64_lto.c new file mode 100644 index 0000000..8b4f242 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/ls64_lto.c @@ -0,0 +1,10 @@ +/* { dg-do link { target aarch64_asm_ls64_ok } } */ +/* { dg-additional-options "-march=armv8.7-a -flto" } */ +#include <arm_acle.h> +int main(void) +{ + data512_t d = __arm_ld64b ((const void *)0x1000); + __arm_st64b ((void *)0x2000, d); + uint64_t x = __arm_st64bv ((void *)0x3000, d); + x += __arm_st64bv0 ((void *)0x4000, d); +} diff --git a/gcc/testsuite/gcc.target/aarch64/acle/pr110132.c b/gcc/testsuite/gcc.target/aarch64/acle/pr110132.c new file mode 100644 index 0000000..fb88d63 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/acle/pr110132.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv8.7-a" } */ + +/* Check that ls64 builtins can be invoked using a preprocesed testcase + without triggering bogus builtin warnings, see PR110132. + + Note that this is purely to test GCC internals and user code should + include arm_acle.h to make use of these builtins. */ + +#pragma GCC aarch64 "arm_acle.h" +typedef __arm_data512_t data512_t; +void f(void *p, data512_t d) +{ + __arm_st64b (p, d); +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 431a56f..184fafb 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -10965,7 +10965,7 @@ proc check_effective_target_aarch64_tiny { } { # various architecture extensions via the .arch_extension pseudo-op. foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse" "dotprod" "sve" - "i8mm" "f32mm" "f64mm" "bf16" "sb" "sve2" } { + "i8mm" "f32mm" "f64mm" "bf16" "sb" "sve2" "ls64" } { eval [string map [list FUNC $aarch64_ext] { proc check_effective_target_aarch64_asm_FUNC_ok { } { if { [istarget aarch64*-*-*] } { |