diff mbox series

[3/3] Add power11 tests

Message ID Zl5x4UtZqr80k9kv@cowardly-lion.the-meissners.org
State New
Headers show
Series Add support for -mcpu=power11 | expand

Commit Message

Michael Meissner June 4, 2024, 1:46 a.m. UTC
This patch adds some simple tests for -mcpu=power11 support.  In order to run
these tests, you need an assembler that supports the appropriate option for
supporting the Power11 processor (-mpower11 under Linux or -mpwr11 under AIX).

I have bootstrapped these patches on both little endian and big endian systems.
There were no regressions.  Can I check these patches into the GCC 15 trunk?
After a waiting period to make sure there are no errors, can I check these
patches into the GCC 14 branch?

2024-06-03  Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/

	* gcc.target/powerpc/power11-1.c: New test.
	* gcc.target/powerpc/power11-2.c: Likewise.
	* gcc.target/powerpc/power11-3.c: Likewise.
	* lib/target-supports.exp (check_effective_target_power11_ok): Add new
	effective target.
---
 gcc/testsuite/gcc.target/powerpc/power11-1.c | 13 +++++++++++++
 gcc/testsuite/gcc.target/powerpc/power11-2.c | 20 ++++++++++++++++++++
 gcc/testsuite/gcc.target/powerpc/power11-3.c | 10 ++++++++++
 gcc/testsuite/lib/target-supports.exp        | 17 +++++++++++++++++
 4 files changed, 60 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-1.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-2.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-3.c

Comments

Kewen.Lin June 12, 2024, 6:23 a.m. UTC | #1
Hi Mike,

on 2024/6/4 09:46, Michael Meissner wrote:
> This patch adds some simple tests for -mcpu=power11 support.  In order to run
> these tests, you need an assembler that supports the appropriate option for
> supporting the Power11 processor (-mpower11 under Linux or -mpwr11 under AIX).
> 
> I have bootstrapped these patches on both little endian and big endian systems.
> There were no regressions.  Can I check these patches into the GCC 15 trunk?
> After a waiting period to make sure there are no errors, can I check these
> patches into the GCC 14 branch?
> 
> 2024-06-03  Michael Meissner  <meissner@linux.ibm.com>
> 
> gcc/testsuite/
> 
> 	* gcc.target/powerpc/power11-1.c: New test.
> 	* gcc.target/powerpc/power11-2.c: Likewise.
> 	* gcc.target/powerpc/power11-3.c: Likewise.
> 	* lib/target-supports.exp (check_effective_target_power11_ok): Add new
> 	effective target.
> ---
>  gcc/testsuite/gcc.target/powerpc/power11-1.c | 13 +++++++++++++
>  gcc/testsuite/gcc.target/powerpc/power11-2.c | 20 ++++++++++++++++++++
>  gcc/testsuite/gcc.target/powerpc/power11-3.c | 10 ++++++++++
>  gcc/testsuite/lib/target-supports.exp        | 17 +++++++++++++++++
>  4 files changed, 60 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-1.c
>  create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-2.c
>  create mode 100644 gcc/testsuite/gcc.target/powerpc/power11-3.c
> 
> diff --git a/gcc/testsuite/gcc.target/powerpc/power11-1.c b/gcc/testsuite/gcc.target/powerpc/power11-1.c
> new file mode 100644
> index 00000000000..6a2e802eedf
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/power11-1.c
> @@ -0,0 +1,13 @@
> +/* { dg-do compile { target powerpc*-*-* } } */
> +/* { dg-require-effective-target power11_ok } */
> +/* { dg-options "-mdejagnu-cpu=power11 -O2" } */
> +
> +/* Basic check to see if the compiler supports -mcpu=power11.  */
> +
> +#ifndef _ARCH_PWR11
> +#error "-mcpu=power11 is not supported"
> +#endif
> +
> +void foo (void)
> +{
> +}
> diff --git a/gcc/testsuite/gcc.target/powerpc/power11-2.c b/gcc/testsuite/gcc.target/powerpc/power11-2.c
> new file mode 100644
> index 00000000000..7b9904c1d29
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/power11-2.c
> @@ -0,0 +1,20 @@
> +/* { dg-do compile { target powerpc*-*-* } } */
> +/* { dg-require-effective-target power11_ok } */
> +/* { dg-options "-O2" } */
> +
> +/* Check if we can set the power11 target via a target attribute.  */
> +
> +__attribute__((__target__("cpu=power9")))
> +void foo_p9 (void)
> +{
> +}
> +
> +__attribute__((__target__("cpu=power10")))
> +void foo_p10 (void)
> +{
> +}
> +
> +__attribute__((__target__("cpu=power11")))
> +void foo_p11 (void)
> +{
> +}
> diff --git a/gcc/testsuite/gcc.target/powerpc/power11-3.c b/gcc/testsuite/gcc.target/powerpc/power11-3.c
> new file mode 100644
> index 00000000000..9b2d643cc0f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/power11-3.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target powerpc*-*-* } }  */
> +/* { dg-require-effective-target power11_ok } */
> +/* { dg-options "-mdejagnu-cpu=power8 -O2" }  */
> +
> +/* Check if we can set the power11 target via a target_clones attribute.  */
> +
> +__attribute__((__target_clones__("cpu=power11,cpu=power9,default")))
> +void foo (void)
> +{
> +}
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> index 836545b4e11..9305d63aacc 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -7059,6 +7059,23 @@ proc check_effective_target_power10_ok { } {
>      }
>  }
>  
> +# Return 1 if this is a PowerPC target supporting -mcpu=power11.
> +
> +proc check_effective_target_power11_ok { } {
> +    if { ([istarget powerpc*-*-*]) } {
> +	return [check_no_compiler_messages power11_ok object {
> +	    int main (void) {
> +	        #ifndef _ARCH_PWR11
> +		#error "-mcpu=power11 is not supported"
> +		#endif
> +		return 0;
> +	    }
> +	} "-mcpu=power11"]
> +    } else {
> +	return 0
> +    }
> +}
> +

I guess the previous comment in [1] was escaped from your radar, as that just
one nit on test case, re-posted it as below. :)

> Sorry that I didn't catch this before, this effective target looks useless
> since its users power11-[123].c are all for compiling and the compilation
> doesn't rely on assembler behavior.  power11-1.c has checked for _ARCH_PWR11,
> maybe we want some cases with "dg-do assemble" to adopt this?

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-April/648943.html

BR,
Kewen

>  # Return 1 if this is a PowerPC target supporting -mfloat128 via either
>  # software emulation on power7/power8 systems or hardware support on power9.
>
Michael Meissner June 12, 2024, 6:56 p.m. UTC | #2
On Wed, Jun 12, 2024 at 02:23:18PM +0800, Kewen.Lin wrote:
> Hi Mike,
> 
> > +# Return 1 if this is a PowerPC target supporting -mcpu=power11.
> > +
> > +proc check_effective_target_power11_ok { } {
> > +    if { ([istarget powerpc*-*-*]) } {
> > +	return [check_no_compiler_messages power11_ok object {
> > +	    int main (void) {
> > +	        #ifndef _ARCH_PWR11
> > +		#error "-mcpu=power11 is not supported"
> > +		#endif
> > +		return 0;
> > +	    }
> > +	} "-mcpu=power11"]
> > +    } else {
> > +	return 0
> > +    }
> > +}
> > +
> 
> I guess the previous comment in [1] was escaped from your radar, as that just
> one nit on test case, re-posted it as below. :)
> 
> > Sorry that I didn't catch this before, this effective target looks useless
> > since its users power11-[123].c are all for compiling and the compilation
> > doesn't rely on assembler behavior.  power11-1.c has checked for _ARCH_PWR11,
> > maybe we want some cases with "dg-do assemble" to adopt this?
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-April/648943.html
> 
> BR,
> Kewen

Using 'object' in the check_effective_target_power11_ok' test means it has to
assemble the object.  Thus, if you have an older assembler that does not
support ".machine power11", the testsuite will skip these tests.

I just built a GCC using the system assembler instead of a recent binutils that
includes ".machine power11" support, and the 3 power11 tests are not done due
to them being UNSUPPORTED.
Kewen.Lin June 13, 2024, 5:54 a.m. UTC | #3
Hi,

on 2024/6/13 02:56, Michael Meissner wrote:
> On Wed, Jun 12, 2024 at 02:23:18PM +0800, Kewen.Lin wrote:
>> Hi Mike,
>>
>>> +# Return 1 if this is a PowerPC target supporting -mcpu=power11.
>>> +
>>> +proc check_effective_target_power11_ok { } {
>>> +    if { ([istarget powerpc*-*-*]) } {
>>> +	return [check_no_compiler_messages power11_ok object {
>>> +	    int main (void) {
>>> +	        #ifndef _ARCH_PWR11
>>> +		#error "-mcpu=power11 is not supported"
>>> +		#endif
>>> +		return 0;
>>> +	    }
>>> +	} "-mcpu=power11"]
>>> +    } else {
>>> +	return 0
>>> +    }
>>> +}
>>> +
>>
>> I guess the previous comment in [1] was escaped from your radar, as that just
>> one nit on test case, re-posted it as below. :)
>>
>>> Sorry that I didn't catch this before, this effective target looks useless
>>> since its users power11-[123].c are all for compiling and the compilation
>>> doesn't rely on assembler behavior.  power11-1.c has checked for _ARCH_PWR11,
>>> maybe we want some cases with "dg-do assemble" to adopt this?
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-April/648943.html
>>
>> BR,
>> Kewen
> 
> Using 'object' in the check_effective_target_power11_ok' test means it has to
> assemble the object.  Thus, if you have an older assembler that does not
> support ".machine power11", the testsuite will skip these tests.
> 
> I just built a GCC using the system assembler instead of a recent binutils that
> includes ".machine power11" support, and the 3 power11 tests are not done due
> to them being UNSUPPORTED.

But all of them are "dg-do compile", it doesn't require any assembler which supports
.machine power11, in other words, all the associated test cases can be tested well
if compiler itself supports power11 (since assembler isn't involved here).
IMHO, power11_ok is only required for dg-do assemble/run test cases.

BR,
Kewen
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/power11-1.c b/gcc/testsuite/gcc.target/powerpc/power11-1.c
new file mode 100644
index 00000000000..6a2e802eedf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-1.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-mdejagnu-cpu=power11 -O2" } */
+
+/* Basic check to see if the compiler supports -mcpu=power11.  */
+
+#ifndef _ARCH_PWR11
+#error "-mcpu=power11 is not supported"
+#endif
+
+void foo (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/power11-2.c b/gcc/testsuite/gcc.target/powerpc/power11-2.c
new file mode 100644
index 00000000000..7b9904c1d29
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-2.c
@@ -0,0 +1,20 @@ 
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-O2" } */
+
+/* Check if we can set the power11 target via a target attribute.  */
+
+__attribute__((__target__("cpu=power9")))
+void foo_p9 (void)
+{
+}
+
+__attribute__((__target__("cpu=power10")))
+void foo_p10 (void)
+{
+}
+
+__attribute__((__target__("cpu=power11")))
+void foo_p11 (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/power11-3.c b/gcc/testsuite/gcc.target/powerpc/power11-3.c
new file mode 100644
index 00000000000..9b2d643cc0f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/power11-3.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile { target powerpc*-*-* } }  */
+/* { dg-require-effective-target power11_ok } */
+/* { dg-options "-mdejagnu-cpu=power8 -O2" }  */
+
+/* Check if we can set the power11 target via a target_clones attribute.  */
+
+__attribute__((__target_clones__("cpu=power11,cpu=power9,default")))
+void foo (void)
+{
+}
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 836545b4e11..9305d63aacc 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7059,6 +7059,23 @@  proc check_effective_target_power10_ok { } {
     }
 }
 
+# Return 1 if this is a PowerPC target supporting -mcpu=power11.
+
+proc check_effective_target_power11_ok { } {
+    if { ([istarget powerpc*-*-*]) } {
+	return [check_no_compiler_messages power11_ok object {
+	    int main (void) {
+	        #ifndef _ARCH_PWR11
+		#error "-mcpu=power11 is not supported"
+		#endif
+		return 0;
+	    }
+	} "-mcpu=power11"]
+    } else {
+	return 0
+    }
+}
+
 # Return 1 if this is a PowerPC target supporting -mfloat128 via either
 # software emulation on power7/power8 systems or hardware support on power9.