]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arm: testsuite: make use of -mcpu=unset/-march=unset
authorRichard Earnshaw <rearnsha@arm.com>
Thu, 12 Sep 2024 13:24:55 +0000 (14:24 +0100)
committerRichard Earnshaw <rearnsha@arm.com>
Thu, 12 Sep 2024 15:07:46 +0000 (16:07 +0100)
This patch makes use of the new ability to unset the CPU or
architecture flags on the command line to enable several more tests on
Arm.  It doesn't cover every case and it does enable some tests that
now fail for different reasons when the tests are no-longer skipped;
these were failing anyway for other testsuite configurations, so it's
still an overall improvement.

There's some restructuring required to fully implement this change: we
could previously treat Xscale as an architecture, even though the
option set -mcpu=, we now need to handle this correctly so that we
unset the architecture rather than the CPU.  To do this I've added a
new table for these variants and renamed the template functions to use
'cpu' rather than 'arch'.  This entailed updating the two XScale
related tests accordingly.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Move xscale to new generator table.
(check_effective_target_arm_arch_FUNC_ok): Add -mcpu=unset to the
list of flags.
(add_options_for_arm_arch_FUNC): Likewise.
(check_effective_target_arm_cpu_FUNC_ok): New function.
(add_options_for_arm_cpu_FUNC): Likewise.
(check_effective_target_arm_cpu_FUNC_link): Likewise.
(check_effective_target_arm_cpu_FUNC_multilib): Likewise.
* gcc.target/arm/g2.c: Update dg directives.
* gcc.target/arm/scd42-2.c: Likewise.

gcc/testsuite/gcc.target/arm/g2.c
gcc/testsuite/gcc.target/arm/scd42-2.c
gcc/testsuite/lib/target-supports.exp

index 04334c97713bf8f8f7d7fc4d05560d734133ba97..7e43a907a4c5198666feb6a3c864be9f88cdcf53 100644 (file)
@@ -1,8 +1,8 @@
 /* Verify that hardware multiply is preferred on XScale. */
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
-/* { dg-require-effective-target arm_arch_xscale_arm_ok } */
-/* { dg-add-options arm_arch_xscale_arm } */
+/* { dg-require-effective-target arm_cpu_xscale_arm_ok } */
+/* { dg-add-options arm_cpu_xscale_arm } */
 
 
 /* Brett Gaines' test case. */
index cd416885a8046abce22a96b0faad3cc483b823b2..a263c1fbff92f35f36c5b1cc7854845c6a5a7d38 100644 (file)
@@ -1,8 +1,8 @@
 /* Verify that mov is preferred on XScale for loading a 2 byte constant. */
 /* { dg-do compile } */
-/* { dg-require-effective-target arm_arch_xscale_arm_ok } */
+/* { dg-require-effective-target arm_cpu_xscale_arm_ok } */
 /* { dg-options "-O" } */
-/* { dg-add-options arm_arch_xscale_arm } */
+/* { dg-add-options arm_cpu_xscale_arm } */
 
 unsigned load2(void) __attribute__ ((naked));
 unsigned load2(void)
index cb9971d53980840f7688dbba8210a63322bae829..c4d2c33cf628aaf0669b439f64c9073e9c2c7939 100644 (file)
@@ -5679,6 +5679,9 @@ proc check_effective_target_arm_fp16_hw { } {
 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
 #        /* { dg-add-options arm_arch_v5t } */
 #       /* { dg-require-effective-target arm_arch_v5t_multilib } */
+
+# This table should only be used to set -march= (and associated
+# flags).  See below for setting -mcpu
 foreach { armfunc armflag armdefs } {
        v4 "-march=armv4 -marm" __ARM_ARCH_4__
        v4t "-march=armv4t -mfloat-abi=softfp" __ARM_ARCH_4T__
@@ -5690,7 +5693,6 @@ foreach { armfunc armflag armdefs } {
        v5te "-march=armv5te+fp -mfloat-abi=softfp" __ARM_ARCH_5TE__
        v5te_arm "-march=armv5te+fp -marm" "__ARM_ARCH_5TE__ && !__thumb__"
        v5te_thumb "-march=armv5te+fp -mthumb -mfloat-abi=softfp" "__ARM_ARCH_5TE__ && __thumb__"
-       xscale_arm "-mcpu=xscale -mfloat-abi=soft -marm" "__XSCALE__ && !__thumb__"
        v6 "-march=armv6+fp -mfloat-abi=softfp" __ARM_ARCH_6__
        v6_arm "-march=armv6+fp -marm" "__ARM_ARCH_6__ && !__thumb__"
        v6_thumb "-march=armv6+fp -mthumb -mfloat-abi=softfp" "__ARM_ARCH_6__ && __thumb__"
@@ -5735,11 +5737,11 @@ foreach { armfunc armflag armdefs } {
                {
                    return 0;
                }
-           } "FLAG" ]
+           } "-mcpu=unset FLAG" ]
        }
 
        proc add_options_for_arm_arch_FUNC { flags } {
-           return "$flags FLAG"
+           return "$flags -mcpu=unset FLAG"
        }
 
        proc check_effective_target_arm_arch_FUNC_link { } {
@@ -5762,6 +5764,57 @@ foreach { armfunc armflag armdefs } {
     }]
 }
 
+# Creates a series of routines that return 1 if the given CPU
+# can be selected and a routine to give the flags to select that CPU
+# Note: Extra flags may be added to disable options from newer compilers
+# (Thumb in particular - but others may be added in the future).
+# Usage: /* { dg-require-effective-target arm_cpu_xscale_ok } */
+#        /* { dg-add-options arm_cpu_xscale } */
+#       /* { dg-require-effective-target arm_xscale_multilib } */
+
+# This table should only be used to set -mcpu= (and associated
+# flags).  See above for setting -march=.
+foreach { armfunc armflag armdefs } {
+           xscale_arm "-mcpu=xscale -mfloat-abi=soft -marm" "__XSCALE__ && !__thumb__"
+       } {
+    eval [string map [list FUNC $armfunc FLAG $armflag DEFS $armdefs ] {
+       proc check_effective_target_arm_cpu_FUNC_ok { } {
+           return [check_no_compiler_messages arm_cpu_FUNC_ok assembly {
+               #if !(DEFS)
+               #error !(DEFS)
+               #endif
+               int
+               main (void)
+               {
+                   return 0;
+               }
+           } "-march=unset FLAG" ]
+       }
+
+       proc add_options_for_arm_cpu_FUNC { flags } {
+           return "$flags -march=unset FLAG"
+       }
+
+       proc check_effective_target_arm_cpu_FUNC_link { } {
+           return [check_no_compiler_messages arm_cpu_FUNC_link executable {
+               #include <stdint.h>
+               int dummy;
+               int main (void) { return 0; }
+           } [add_options_for_arm_cpu_FUNC ""]]
+       }
+
+       proc check_effective_target_arm_cpu_FUNC_multilib { } {
+           return [check_runtime arm_cpu_FUNC_multilib {
+               int
+               main (void)
+               {
+                   return 0;
+               }
+           } [add_options_for_arm_cpu_FUNC ""]]
+       }
+    }]
+}
+
 # Return 1 if GCC was configured with --with-mode=
 proc check_effective_target_default_mode { } {