This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][AArch64][12/14] Target attributes and target pragmas tests
- From: James Greenhalgh <james dot greenhalgh at arm dot com>
- To: Kyrill Tkachov <kyrylo dot tkachov at arm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Marcus Shawcroft <Marcus dot Shawcroft at arm dot com>, Richard Earnshaw <Richard dot Earnshaw at arm dot com>
- Date: Mon, 3 Aug 2015 12:32:15 +0100
- Subject: Re: [PATCH][AArch64][12/14] Target attributes and target pragmas tests
- Authentication-results: sourceware.org; auth=none
- References: <55A7CBEB dot 2080601 at arm dot com> <20150721171448 dot GC14953 at arm dot com> <55B1F9FC dot 2090606 at arm dot com>
On Fri, Jul 24, 2015 at 09:40:28AM +0100, Kyrill Tkachov wrote:
>
> On 21/07/15 18:14, James Greenhalgh wrote:
> > On Thu, Jul 16, 2015 at 04:21:15PM +0100, Kyrill Tkachov wrote:
> >> Hi all,
> >>
> >> These are the tests for target attributes and pragmas.
> >> I've tried to test for the inlining rules, some of the possible errors and
> >> the preprocessor macros changed from target pragmas.
> >>
> >> Ok for trunk?
> > Mechanical changes in the pragma tests for the sake of grammar!
> >
> > s/defined but shouldn't/is defined but should not be/
> > s/not defined but should/is not defined but should be/
> >
> > Note that some of the errors have different text, so you'll have to run
> > through by hand and check these are consistent.
> >
> > It would be good to hand some of these target attribute tests off
> > to the assembler to make sure we are also putting out appropriate
> > directives in our output. Perhaps "assemble" is the more appropriate
> > dg-do directive?
> >
> > Some more nits below (mostly missing comments on testcases).
>
> Thanks, here's an updated version.
>
> I've also added a test for the "+nothing" architectural feature
> attribute introduced in patch 10/14 and renamed the tests to use
> underscores in their names.
>
> How's this?
Run
s/is is/is/
To fix typos like this:
> +#pragma GCC push_options
> +#pragma GCC target ("arch=armv8-a+fp+nosimd")
> +#ifndef __ARM_FP
> +#error "__ARM_FP is is not defined but should be!"
> +#endif
> diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_1.c b/gcc/testsuite/gcc.target/aarch64/target_attr_1.c
> new file mode 100644
> index 0000000..72d0838
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/target_attr_1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do assemble } */
> +/* { dg-options "-O2 -mcpu=thunderx -save-temps" } */
> +
> +__attribute__ ((target ("cpu=cortex-a72.cortex-a53")))
> +int
> +foo (int a)
> +{
> + return a + 1;
> +}
> +
> +/* { dg-final { scan-assembler "//.tune cortex-a72.cortex-a53" } } */
> +/* { dg-final { scan-assembler-not "thunderx" } } */
Comment on what we are testing.
> diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_2.c b/gcc/testsuite/gcc.target/aarch64/target_attr_2.c
> new file mode 100644
> index 0000000..0cd6866
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/target_attr_2.c
> @@ -0,0 +1,39 @@
> +/* { dg-do assemble } */
> +/* { dg-options "-O2 -mcpu=cortex-a57 -ftree-vectorize -fdump-tree-vect-all" } */
> +
> +/* The various was to turn off simd availability should
s/was/ways/
> + turn off vectorization. */
> +
> +__attribute__ ((target ("+nosimd")))
> +int
> +baz (int *a)
> +{
> + for (int i = 0; i < 1024; i++)
> + a[i] += 5;
> +}
> +
> +__attribute__ ((target ("arch=armv8-a+nosimd")))
> +int
> +baz2 (int *a)
> +{
> + for (int i = 0; i < 1024; i++)
> + a[i] += 5;
> +}
> +
> +__attribute__ ((target ("cpu=cortex-a53+nosimd")))
> +int
> +baz3 (int *a)
> +{
> + for (int i = 0; i < 1024; i++)
> + a[i] += 5;
> +}
> +
> +__attribute__ ((target ("general-regs-only")))
> +int
> +baz4 (int *a)
> +{
> + for (int i = 0; i < 1024; i++)
> + a[i] += 5;
> +}
> +
> +/* { dg-final { scan-tree-dump-not "vectorized 1 loops" "vect" } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_8.c b/gcc/testsuite/gcc.target/aarch64/target_attr_8.c
> new file mode 100644
> index 0000000..3f32569
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/target_attr_8.c
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -save-temps" } */
> +
> +/* bar has a subset arch of bam. Inlining should be allowed. */
s/arch/set of architectural flags/
Or words to that effect.
> +
> +__attribute__ ((target ("arch=armv8-a+nocrc")))
> +int
> +bar (int a)
> +{
> + return a - 6;
> +}
> +
> +__attribute__ ((target ("arch=armv8-a+crc")))
> +int
> +bam (int a)
> +{
> + return a - bar (a);
> +}
> +
> +
> +/* { dg-final { scan-assembler-not "bl.*bar" } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/target_attr_9.c b/gcc/testsuite/gcc.target/aarch64/target_attr_9.c
> new file mode 100644
> index 0000000..22bd99b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/target_attr_9.c
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -save-temps" } */
> +
> +/* bar is not a subset arch of bam. Inlining should be rejected. */
Likewise.
> +
> +__attribute__ ((target ("arch=armv8-a+crc")))
> +int
> +bar (int a)
> +{
> + return a - 6;
> +}
> +
> +__attribute__ ((target ("arch=armv8-a+nocrc")))
> +int
> +bam (int a)
> +{
> + return a - bar (a);
> +}
> +
> +
> +/* { dg-final { scan-assembler "bl.*bar" } } */
OK with those changes.
Thanks,
James