From 305ab735bd40b52a451851fa6e2177f184eb05d4 Mon Sep 17 00:00:00 2001 From: Aaron Sawdey Date: Fri, 10 Jul 2020 17:46:17 -0500 Subject: [PATCH] rs6000: add effective-target test ppc_mma_hw Add a test for dejagnu to determine if execution of MMA instructions is supported in the test environment. Add an execution test to make sure that __builtin_cpu_supports("mma") is true if we can execute MMA instructions. gcc/testsuite/ * lib/target-supports.exp (check_ppc_mma_hw_available): New function. (is-effective-target): Add ppc_mma_hw. (is-effective-target-keyword): Add ppc_mma_hw. * gcc.target/powerpc/mma-supported.c: New file. * gcc.target/powerpc/mma-single-test.c: Require ppc_mma_hw. * gcc.target/powerpc/mma-double-test.c: Require ppc_mma_hw. --- .../gcc.target/powerpc/mma-double-test.c | 1 + .../gcc.target/powerpc/mma-single-test.c | 1 + .../gcc.target/powerpc/mma-supported.c | 25 +++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 27 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/mma-supported.c diff --git a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c index 9ba0010978f..ac84ae30004 100755 --- a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target power10_hw } */ +/* { dg-require-effective-target ppc_mma_hw } */ /* { dg-options "-mdejagnu-cpu=power10 -O2" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/mma-single-test.c b/gcc/testsuite/gcc.target/powerpc/mma-single-test.c index aa71fa7f0af..15369a64025 100755 --- a/gcc/testsuite/gcc.target/powerpc/mma-single-test.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-single-test.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target power10_hw } */ +/* { dg-require-effective-target ppc_mma_hw } */ /* { dg-options "-mdejagnu-cpu=power10 -O2" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/mma-supported.c b/gcc/testsuite/gcc.target/powerpc/mma-supported.c new file mode 100644 index 00000000000..92d9a7f4686 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/mma-supported.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target ppc_mma_hw } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2" } */ + +/* This test will only run when the ppc_mma_hw test passes. If that + test passes, then we expect to see that mma feature is supported. + If this is not the case, then the test environment has problems. */ + +#include +#include + +int +main (int argc, char *argv[]) +{ +#ifdef __BUILTIN_CPU_SUPPORTS__ + if ( !__builtin_cpu_supports ("mma")) + { +#ifdef DEBUG + printf ("Error: __builtin_cpu_supports says mma not supported, but ppc_mma_hw test passed.\n"); +#endif + abort(); + } +#endif + exit (0); +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index aeb0351073d..2e4c696fdd1 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2234,6 +2234,31 @@ proc check_power10_hw_available { } { }] } +# Return 1 if the target supports executing MMA instructions, 0 otherwise. +# Cache the result. It is assumed that if a simulator does not support the +# MMA instructions, that it will generate an error and this test will fail. + +proc check_ppc_mma_hw_available { } { + return [check_cached_effective_target ppc_mma_hw_available { + check_runtime_nocache ppc_mma_hw_available { + #include + typedef double v4sf_t __attribute__ ((vector_size (16))); + + int main() + { + __vector_quad acc0; + v4sf_t result[4]; + result[0][0] = 1.0; + __builtin_mma_xxsetaccz (&acc0); + __builtin_mma_disassemble_acc (result, &acc0); + if (result[0][0] != 0.0) + return 1; + return 0; + } + } "-mcpu=power10" + }] +} + # Return 1 if the target supports executing __float128 on PowerPC via software # emulation, 0 otherwise. Cache the result. @@ -7830,6 +7855,7 @@ proc is-effective-target { arg } { "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] } "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] } "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] } + "ppc_mma_hw" { set selected [check_ppc_mma_hw_available] } "dfp_hw" { set selected [check_dfp_hw_available] } "htm_hw" { set selected [check_htm_hw_available] } "named_sections" { set selected [check_named_sections_available] } @@ -7860,6 +7886,7 @@ proc is-effective-target-keyword { arg } { "ppc_float128_sw" { return 1 } "ppc_float128_hw" { return 1 } "ppc_recip_hw" { return 1 } + "ppc_mma_hw" { return 1 } "dfp_hw" { return 1 } "htm_hw" { return 1 } "named_sections" { return 1 } -- 2.30.2