public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alex Coplan <acoplan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1617] aarch64: Allow compiler to define ls64 builtins [PR110132] Date: Wed, 7 Jun 2023 16:45:59 +0000 (GMT) [thread overview] Message-ID: <20230607164559.A8AE23857711@sourceware.org> (raw) https://gcc.gnu.org/g:9963029a24f2d2510b82e7106fae3f364da33c5d commit r14-1617-g9963029a24f2d2510b82e7106fae3f364da33c5d Author: Alex Coplan <alex.coplan@arm.com> Date: Tue Jun 6 15:19:03 2023 +0100 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. Diff: --- gcc/config/aarch64/aarch64-builtins.cc | 24 ++++++++++++---- gcc/config/aarch64/arm_acle.h | 33 ---------------------- gcc/testsuite/g++.target/aarch64/acle/acle.exp | 35 ++++++++++++++++++++++++ gcc/testsuite/g++.target/aarch64/acle/ls64.C | 10 +++++++ gcc/testsuite/g++.target/aarch64/acle/ls64_lto.C | 10 +++++++ gcc/testsuite/gcc.target/aarch64/acle/ls64_lto.c | 10 +++++++ gcc/testsuite/gcc.target/aarch64/acle/pr110132.c | 15 ++++++++++ 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 1a4507f32e6..04f59fd9a54 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 e0ac591d2c8..3b6b63e6805 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 00000000000..9e1cbf4a0c6 --- /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 00000000000..d9002785b57 --- /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 00000000000..274a4771e1c --- /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 00000000000..8b4f2427771 --- /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 00000000000..fb88d633dd2 --- /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 431a56f0be5..184fafb020f 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*-*-*] } {
reply other threads:[~2023-06-07 16:45 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230607164559.A8AE23857711@sourceware.org \ --to=acoplan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.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: linkBe 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).