Re: [AArch64][1/4] Enable tree-stdarg pass for AArch64 by defining counter fields

2016-05-26 Thread James Greenhalgh
On Fri, May 06, 2016 at 04:00:13PM +0100, Jiong Wang wrote:
> This patch initialize va_list_gpr_counter_field and
> va_list_fpr_counter_field properly for AArch64 backend that tree-stdarg
> pass will be enabled.
> 
> The "required register" analysis is largely target independent, but the
> user might operate on the inner offset field in vaarg structure directly,
> for example:
> 
>   d = __builtin_va_arg (ap, int);
>   ap.__gr_offs += 0x20;
>   e = __builtin_va_arg (ap, int);
> 
> in which case tree-stdarg require us to tell him what's the backend offset
> field inside vaarg structure that it can still figure out we actually need
> to save 6 general registers.
> 
> ok for upstream?

I have a small comment issue for you to fix, otherwise this is OK.

> 2016-05-06  Jiong Wang  
> gcc/
>   * config/aarch64/aarch64.c (aarch64_build_builtin_va_list): Initialize
>   va_list_gpr_counter_field and va_list_fpr_counter_field.
> 
> gcc/testsuite/
>   * gcc.dg/tree-ssa/stdarg-2.c: Enable all testcases for AArch64.
>   * gcc.dg/tree-ssa/stdarg-3.c: Likewise.
>   * gcc.dg/tree-ssa/stdarg-4.c: Likewise.
>   * gcc.dg/tree-ssa/stdarg-5.c: Likewise.
>   * gcc.dg/tree-ssa/stdarg-6.c: Likewise.
> 
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 9995494..aff4a95 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -9463,6 +9463,13 @@ aarch64_build_builtin_va_list (void)
>   FIELD_DECL, get_identifier ("__vr_offs"),
>   integer_type_node);
>  
> +  /* Tell tree-stdarg pass what's our internal offset fields.

This doesn't read quite right, how about something like:

  "Tell tree-stdarg pass about our internal offset fields."

Thanks,
James



[AArch64][1/4] Enable tree-stdarg pass for AArch64 by defining counter fields

2016-05-06 Thread Jiong Wang

This patch initialize va_list_gpr_counter_field and
va_list_fpr_counter_field properly for AArch64 backend that tree-stdarg
pass will be enabled.

The "required register" analysis is largely target independent, but the
user might operate on the inner offset field in vaarg structure directly,
for example:

  d = __builtin_va_arg (ap, int);
  ap.__gr_offs += 0x20;
  e = __builtin_va_arg (ap, int);

in which case tree-stdarg require us to tell him what's the backend offset
field inside vaarg structure that it can still figure out we actually need
to save 6 general registers.

ok for upstream?

2016-05-06  Jiong Wang  
gcc/
  * config/aarch64/aarch64.c (aarch64_build_builtin_va_list): Initialize
  va_list_gpr_counter_field and va_list_fpr_counter_field.

gcc/testsuite/
  * gcc.dg/tree-ssa/stdarg-2.c: Enable all testcases for AArch64.
  * gcc.dg/tree-ssa/stdarg-3.c: Likewise.
  * gcc.dg/tree-ssa/stdarg-4.c: Likewise.
  * gcc.dg/tree-ssa/stdarg-5.c: Likewise.
  * gcc.dg/tree-ssa/stdarg-6.c: Likewise.

>From 93485b0163bbaddf7fdf472aac2d3a96823bd63a Mon Sep 17 00:00:00 2001
From: "Jiong.Wang" 
Date: Fri, 6 May 2016 14:36:12 +0100
Subject: [PATCH 1/4] 1

---
 gcc/config/aarch64/aarch64.c |  7 +++
 gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c | 15 +++
 gcc/testsuite/gcc.dg/tree-ssa/stdarg-3.c | 11 +++
 gcc/testsuite/gcc.dg/tree-ssa/stdarg-4.c |  4 
 gcc/testsuite/gcc.dg/tree-ssa/stdarg-5.c |  7 +++
 gcc/testsuite/gcc.dg/tree-ssa/stdarg-6.c |  1 +
 6 files changed, 45 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 9995494..aff4a95 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -9463,6 +9463,13 @@ aarch64_build_builtin_va_list (void)
 			FIELD_DECL, get_identifier ("__vr_offs"),
 			integer_type_node);
 
+  /* Tell tree-stdarg pass what's our internal offset fields.
+ NOTE: va_list_gpr/fpr_counter_field are only used for tree comparision
+ purpose to identify whether the code is updating va_list internal
+ offset fields through irregular way.  */
+  va_list_gpr_counter_field = f_groff;
+  va_list_fpr_counter_field = f_vroff;
+
   DECL_ARTIFICIAL (f_stack) = 1;
   DECL_ARTIFICIAL (f_grtop) = 1;
   DECL_ARTIFICIAL (f_vrtop) = 1;
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
index c73294a..0224997 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/stdarg-2.c
@@ -25,6 +25,7 @@ f1 (int i, ...)
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target alpha*-*-linux* } } } */
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
+/* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target ia64-*-* } } } */
 /* { dg-final { scan-tree-dump "f1: va_list escapes 0, needs to save 0 GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
@@ -45,6 +46,7 @@ f2 (int i, ...)
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units and 0 FPR units" "stdarg" { target { powerpc*-*-linux* && ilp32 } } } } */
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 8 GPR units and 1" "stdarg" { target alpha*-*-linux* } } } */
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 1 GPR units and 0 FPR units" "stdarg" { target s390*-*-linux* } } } */
+/* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save 8 GPR units and 0 FPR units" "stdarg" { target aarch64*-*-* } } } */
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && ia32 } } } } */
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target ia64-*-* } } } */
 /* { dg-final { scan-tree-dump "f2: va_list escapes 0, needs to save \[148\] GPR units" "stdarg" { target { powerpc*-*-* && lp64 } } } } */
@@ -60,6 +62,7 @@ f3 (int i, ...)
 /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 || llp64 } } } } } } */
 /* { dg-final { scan-tree-dump "f3: va_list escapes 0, needs to save 0 GPR units and \[1-9\]\[0-9\]* FPR units" "stdarg" { target { powerpc*-*-linux* && { powerpc_fprs && ilp32 } }