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: gimplify mn10300 va_arg
Date: Fri, 09 Jul 2004 09:38:00 -0000	[thread overview]
Message-ID: <40EE5BA6.8080209@polimi.it> (raw)
In-Reply-To: <40EE4596.1090008@polimi.it>

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

Here is the first bit.  Tested on a mn10300-elf cross the same as rth 
did; the code looks better except that it uses memmove instead of memcpy 
to move the big struct.

Ok for mainline?

Paolo

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

Index: mn10300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mn10300/mn10300.c,v
retrieving revision 1.69
diff -u -r1.69 mn10300.c
--- mn10300.c	4 Jul 2004 08:07:09 -0000	1.69
+++ mn10300.c	9 Jul 2004 08:42:29 -0000
@@ -43,6 +43,7 @@
 #include "tm_p.h"
 #include "target.h"
 #include "target-def.h"
+#include "tree-gimple.h"
 
 /* This is used by GOTaddr2picreg to uniquely identify
    UNSPEC_INT_LABELs.  */
@@ -71,6 +72,7 @@
 static void mn10300_file_start (void);
 static bool mn10300_return_in_memory (tree, tree);
 static rtx mn10300_builtin_saveregs (void);
+static tree mn10300_gimplify_va_arg_expr (tree, tree, tree *, tree *);
 
 \f
 /* Initialize the GCC target structure.  */
@@ -99,6 +101,9 @@
 #undef TARGET_EXPAND_BUILTIN_SAVEREGS
 #define TARGET_EXPAND_BUILTIN_SAVEREGS mn10300_builtin_saveregs
 
+#undef TARGET_GIMPLIFY_VA_ARG_EXPR
+#define TARGET_GIMPLIFY_VA_ARG_EXPR mn10300_gimplify_va_arg_expr
+
 static void mn10300_encode_section_info (tree, rtx, int);
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
@@ -1457,40 +1462,34 @@
   std_expand_builtin_va_start (valist, nextarg);
 }
 
-rtx
-mn10300_va_arg (tree valist, tree type)
+static tree
+mn10300_gimplify_va_arg_expr (tree valist, tree type,
+			      tree *pre_p ATTRIBUTE_UNUSED,
+			      tree *post_p ATTRIBUTE_UNUSED)
 {
-  HOST_WIDE_INT align, rsize;
+  HOST_WIDE_INT align, rsize, adjust;
   tree t, ptr, pptr;
 
   /* Compute the rounded size of the type.  */
   align = PARM_BOUNDARY / BITS_PER_UNIT;
   rsize = (((int_size_in_bytes (type) + align - 1) / align) * align);
+  adjust = rsize > 8 ? 4 : rsize;
 
-  t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist, 
-	     build_int_2 ((rsize > 8 ? 4 : rsize), 0));
-  TREE_SIDE_EFFECTS (t) = 1;
-
+  t = build2 (POSTINCREMENT_EXPR, TREE_TYPE (valist),
+	      valist, build_int_2 (adjust, 0));
   ptr = build_pointer_type (type);
 
   /* "Large" types are passed by reference.  */
   if (rsize > 8)
     {
       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
-    {
-      t = build1 (NOP_EXPR, ptr, t);
-      TREE_SIDE_EFFECTS (t) = 1;
-    }
+    t = fold_convert (ptr, t);
 
-  /* Calculate!  */
-  return expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+  return build_fold_indirect_ref (t);
 }
 
 /* Return an RTX to represent where a value with mode MODE will be returned
@@ -1843,9 +1842,6 @@
 	  || XINT (x, 1) == UNSPEC_PLT))
       return 1;
 
-  if (GET_CODE (x) == QUEUED)
-    return legitimate_pic_operand_p (QUEUED_VAR (x));
-
   fmt = GET_RTX_FORMAT (GET_CODE (x));
   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
     {

  reply	other threads:[~2004-07-09  8:44 UTC|newest]

Thread overview: 13+ 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     ` Paolo Bonzini [this message]
2004-07-09 11:10       ` gimplify mn10300 va_arg Richard Henderson
2004-07-09  9:43     ` [RFT/RFA] gimplify pa va_arg Paolo Bonzini
2004-07-09  9:44       ` Paolo Bonzini
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

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=40EE5BA6.8080209@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).