public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <paolo.bonzini@polimi.it>
To: Paolo Bonzini <paolo.bonzini@polimi.it>
Cc: Richard Henderson <rth@redhat.com>,
	Paolo Bonzini <bonzini@gnu.org>,
	gcc-patches@gcc.gnu.org
Subject: Re: [RFT/RFA] gimplify pa va_arg
Date: Fri, 09 Jul 2004 09:44:00 -0000	[thread overview]
Message-ID: <40EE6589.8000506@polimi.it> (raw)
In-Reply-To: <40EE6551.6090603@polimi.it>

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Paolo Bonzini wrote:

> And here is the second.  This gives several differences for both PA and 
> PA64 in the struct case.  For PA64, it looks like awful optimization on 
> part of the current mainline GCC (but HPPA assembly is not my forte). 
> For PA, the only important change is that the frame grows from 64 to 128 
> bytes, but again I cannot figure it out.
> 
> I attach two sdiffs to help review.
> 
> Ok for mainline?
> 
> Paolo
> 
> 2004-07-09  Paolo Bonzini  <bonzini@gnu.org>
> 
>     * config/pa/pa.h (EXPAND_BUILTIN_VA_ARG): Do not define.
>     * config/pa/pa.c (hppa_gimplify_va_arg_expr): New, based on
>     hppa_va_arg.  Produce GIMPLE in the pre-queue instead of
>     expanding trees to RTL.

ENOPATCH

Paolo


[-- Attachment #2: gimplify-va-arg-pa.patch --]
[-- Type: text/plain, Size: 4263 bytes --]

Index: pa.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.h,v
retrieving revision 1.221
diff -u -r1.221 pa.h
--- pa.h	5 Jul 2004 19:49:16 -0000	1.221
+++ pa.h	9 Jul 2004 09:22:56 -0000
@@ -1141,10 +1141,6 @@
 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
   hppa_va_start (valist, nextarg)
 
-/* Implement `va_arg'.  */
-
-#define EXPAND_BUILTIN_VA_ARG(valist, type) \
-  hppa_va_arg (valist, type)
 \f
 /* Addressing modes, and classification of registers for them. 
 
Index: pa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.c,v
retrieving revision 1.255
diff -u -r1.255 pa.c
--- pa.c	7 Jul 2004 19:24:34 -0000	1.255
+++ pa.c	9 Jul 2004 09:22:57 -0000
@@ -47,6 +47,7 @@
 #include "tm_p.h"
 #include "target.h"
 #include "target-def.h"
+#include "tree-gimple.h"
 
 #undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE 
 #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE hook_int_void_1
@@ -142,6 +143,7 @@
 static void pa_hpux_init_libfuncs (void);
 #endif
 static rtx pa_struct_value_rtx (tree, int);
+static tree hppa_gimplify_va_arg_expr (tree, tree, tree *, tree *);
 
 /* Save the operands last given to a compare for use when we
    generate a scc or bcc insn.  */
@@ -268,6 +270,9 @@
 #undef TARGET_EXPAND_BUILTIN_SAVEREGS
 #define TARGET_EXPAND_BUILTIN_SAVEREGS hppa_builtin_saveregs
 
+#undef TARGET_GIMPLIFY_VA_ARG_EXPR
+#define TARGET_GIMPLIFY_VA_ARG_EXPR hppa_gimplify_va_arg_expr
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 void
@@ -5948,8 +5953,8 @@
   std_expand_builtin_va_start (valist, nextarg);
 }
 
-rtx
-hppa_va_arg (tree valist, tree type)
+static tree
+hppa_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p)
 {
   HOST_WIDE_INT size = int_size_in_bytes (type);
   HOST_WIDE_INT ofs;
@@ -5975,27 +5980,21 @@
           t = build (BIT_AND_EXPR, TREE_TYPE (t), t,
                      build_int_2 (-2 * UNITS_PER_WORD, -1));
           t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
-          TREE_SIDE_EFFECTS (t) = 1;
-	  expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
+	  gimplify_and_add (t, pre_p);
         }
 
       if (size > 0)
-	return std_expand_builtin_va_arg (valist, type);
+	return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);
       else
 	{
 	  ptr = build_pointer_type (type);
+	  pptr = build_pointer_type (ptr);
 
 	  /* Args grow upward.  */
 	  t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist,
 		     build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0));
-	  TREE_SIDE_EFFECTS (t) = 1;
-
-	  pptr = build_pointer_type (ptr);
-	  t = build1 (NOP_EXPR, pptr, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
-
-	  t = build1 (INDIRECT_REF, ptr, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
+	  t = fold_convert (pptr, t);
+	  t = build_fold_indirect_ref (t);
 	}
     }
   else /* !TARGET_64BIT */
@@ -6006,16 +6005,12 @@
       if (size > 8 || size <= 0)
 	{
 	  /* Args grow downward.  */
-	  t = build (PREDECREMENT_EXPR, TREE_TYPE (valist), valist,
-		     build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0));
-	  TREE_SIDE_EFFECTS (t) = 1;
-
 	  pptr = build_pointer_type (ptr);
-	  t = build1 (NOP_EXPR, pptr, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
 
-	  t = build1 (INDIRECT_REF, ptr, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
+	  t = build2 (PREDECREMENT_EXPR, TREE_TYPE (valist), valist,
+		      build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0));
+	  t = fold_convert (pptr, t);
+	  t = build_fold_indirect_ref (t);
 	}
       else
 	{
@@ -6028,23 +6023,21 @@
 		     build_int_2 ((size > 4 ? -8 : -4), -1));
 
 	  t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
+	  gimplify_and_add (t, pre_p);
 
 	  ofs = (8 - size) % 4;
 	  if (ofs)
-	    {
-	      t = build (PLUS_EXPR, TREE_TYPE (valist), t,
-			 build_int_2 (ofs, 0));
-	      TREE_SIDE_EFFECTS (t) = 1;
-	    }
+	    t = build (PLUS_EXPR, TREE_TYPE (valist), valist,
+		       build_int_2 (ofs, 0));
+	  else
+	    t = valist;
 
-	  t = build1 (NOP_EXPR, ptr, t);
-	  TREE_SIDE_EFFECTS (t) = 1;
+	  t = fold_convert (ptr, t);
 	}
     }
 
   /* Calculate!  */
-  return expand_expr (t, NULL_RTX, VOIDmode, EXPAND_NORMAL);
+  return build_fold_indirect_ref (t);
 }
 
 

  reply	other threads:[~2004-07-09  9:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-08 14:55 [PATCH] Remove the postincrement queue Paolo Bonzini
2004-07-08 21:15 ` Richard Henderson
2004-07-09  8:34   ` Paolo Bonzini
2004-07-09  9:38     ` gimplify mn10300 va_arg Paolo Bonzini
2004-07-09 11:10       ` Richard Henderson
2004-07-09  9:43     ` [RFT/RFA] gimplify pa va_arg Paolo Bonzini
2004-07-09  9:44       ` Paolo Bonzini [this message]
2004-07-09 10:08         ` Paolo Bonzini
2004-07-09 10:13           ` Paolo Bonzini
2004-07-09 10:55     ` [PATCH] Remove the postincrement queue Richard Henderson
2004-07-09 11:15       ` Paolo Bonzini
2004-07-09 15:49         ` [PATCH] Remove the postincrement queue, take 2 Paolo Bonzini
2004-07-09 22:05           ` Richard Henderson
2004-07-09 20:48 [RFT/RFA] gimplify pa va_arg John David Anglin
     [not found] <no.id>
2004-07-09 21:01 ` John David Anglin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40EE6589.8000506@polimi.it \
    --to=paolo.bonzini@polimi.it \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).