Re: PowerPC Add has_arch_pwr* checks

2020-02-27 Thread Segher Boessenkool
Hi!

On Tue, Feb 25, 2020 at 05:02:06PM -0600, will schmidt wrote:
>This adds some procs to target-supports.exp that will allow
> our testcases to accurately determine which -mcpu= option
> is enabled at the time of our testcase compile.

Thanks!  I had to think about the names a bit (this will be
*everywhere*), but I think I like it quite well (it is clear, it is
short, other names that do not refer to the somewhat weird macro names
are not as clear what they actually mean; importantly, these effective
target names are clear they mean "at least this version", not "exactly
this version" (to people who know the _ARCH_PWRn macros, at least).

> -/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" } } */
> +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" { target 
> has_arch_pwr8 } } } */

Yeah, I like this :-)

> +# return 1 if our compiler returns the ARCH_PWR defines with the options
> +# as provided by the test.
> +proc check_effective_target_has_arch_pwr5 { } {
> + return [check_no_compiler_messages arch_pwr5 assembly {
> + #ifndef _ARCH_PWR5
> + #error does not have power5 support.
> + #else
> + /* "has power5 support" */
> + #endif
> + }]
> +}
> +proc check_effective_target_has_arch_pwr6 { } {

Please put empty lines between the functions.

With that, okay for trunk.  Thanks!


Segher


PowerPC Add has_arch_pwr* checks

2020-02-25 Thread will schmidt
PowerPC Add has_arch_pwr* checks

Hi,
   This adds some procs to target-supports.exp that will allow
our testcases to accurately determine which -mcpu= option
is enabled at the time of our testcase compile.
For completeness I've added blobs to cover the ARCH_PWR5
through ARCH_PWR9 targets.
With this in place, the existing pr92132-fp-1.c testcase
is updated with a target check such that it now passes
reliably on targets that include power8 support, and skips
(unsupported) those that do not.

Tested on assorted powerpc targets with the incantation
make -k check-gcc-c "RUNTESTFLAGS=powerpc.exp=pr92132-fp-1*.c
   --target_board=unix/'{-mcpu=power5,-mcpu=power6,-mcpu=power7,
   -mcpu=power8,-mcpu=power9}''{-m32,-m64}'"

OK for master?

Thanks
-Will

testsuite/

2020-02-25 Will Schmidt  

  * lib/target_supports.exp (check_effective_target_has_arch_pwr5): New.
  (check_effective_target_has_arch_pwr6): New.
  (check_effective_target_has_arch_pwr7): New.
  (check_effective_target_has_arch_pwr8): New.
  (check_effective_target_has_arch_pwr9): New.
  * gcc.target/powerpc/pr92132-fp-1.c: Add target check.

diff --git a/gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c 
b/gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c
index 1023e8c..c5cbb62 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr92132-fp-1.c
@@ -292,6 +292,6 @@ main (void)
 abort ();
 
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" } } */
+/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 14 "vect" { target 
has_arch_pwr8 } } } */
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index ec46231..038a7bb 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5505,10 +5505,58 @@ proc check_effective_target_powerpc_p9modulo_ok { } {
 } else {
return 0
 }
 }
 
+# return 1 if our compiler returns the ARCH_PWR defines with the options
+# as provided by the test.
+proc check_effective_target_has_arch_pwr5 { } {
+   return [check_no_compiler_messages arch_pwr5 assembly {
+   #ifndef _ARCH_PWR5
+   #error does not have power5 support.
+   #else
+   /* "has power5 support" */
+   #endif
+   }]
+}
+proc check_effective_target_has_arch_pwr6 { } {
+   return [check_no_compiler_messages arch_pwr6 assembly {
+   #ifndef _ARCH_PWR6
+   #error does not have power6 support.
+   #else
+   /* "has power6 support" */
+   #endif
+   }]
+}
+proc check_effective_target_has_arch_pwr7 { } {
+   return [check_no_compiler_messages arch_pwr7 assembly {
+   #ifndef _ARCH_PWR7
+   #error does not have power7 support.
+   #else
+   /* "has power7 support" */
+   #endif
+   }]
+}
+proc check_effective_target_has_arch_pwr8 { } {
+   return [check_no_compiler_messages arch_pwr8 assembly {
+   #ifndef _ARCH_PWR8
+   #error does not have power8 support.
+   #else
+   /* "has power8 support" */
+   #endif
+   }]
+}
+proc check_effective_target_has_arch_pwr9 { } {
+   return [check_no_compiler_messages arch_pwr9 assembly {
+   #ifndef _ARCH_PWR9
+   #error does not have power9 support.
+   #else
+   /* "has power9 support" */
+   #endif
+   }]
+}
+
 # Return 1 if this is a PowerPC target supporting -mfuture.
 # Limit this to 64-bit linux systems for now until other
 # targets support FUTURE.
 
 proc check_effective_target_powerpc_future_ok { } {