This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] PATCH to support PUSH_ARGS_REVERSED


This is a pending patch I've had sitting around for a while.  If we're
going to push the arguments from right to left, it makes sense to evaluate
them in the same order, as we do in the expander.

Tested athlon-pc-linux-gnu.  Applied to tree-ssa.

2003-06-28  Jason Merrill  <jason@redhat.com>

	* defaults.h (PUSH_ARGS_REVERSED): Define default here.
	* calls.c: Not here.
	* gimplify.c (gimplify_call_expr): Use it.

*** calls.c.~1~	2003-06-03 15:55:32.000000000 -0400
--- calls.c	2003-06-27 14:17:18.000000000 -0400
*************** Software Foundation, 59 Temple Place - S
*** 40,65 ****
  #include "cgraph.h"
  #include "except.h"
  
- /* Decide whether a function's arguments should be processed
-    from first to last or from last to first.
- 
-    They should if the stack and args grow in opposite directions, but
-    only if we have push insns.  */
- 
- #ifdef PUSH_ROUNDING
- 
- #ifndef PUSH_ARGS_REVERSED
- #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
- #define PUSH_ARGS_REVERSED  PUSH_ARGS
- #endif
- #endif
- 
- #endif
- 
- #ifndef PUSH_ARGS_REVERSED
- #define PUSH_ARGS_REVERSED 0
- #endif
- 
  #ifndef STACK_POINTER_OFFSET
  #define STACK_POINTER_OFFSET    0
  #endif
--- 40,45 ----
*** defaults.h.~1~	2003-06-03 15:55:35.000000000 -0400
--- defaults.h	2003-06-27 14:17:56.000000000 -0400
*************** do { fputs (integer_asm_op (POINTER_SIZE
*** 411,416 ****
--- 411,436 ----
  #endif
  #endif
  
+ /* Decide whether a function's arguments should be processed
+    from first to last or from last to first.
+ 
+    They should if the stack and args grow in opposite directions, but
+    only if we have push insns.  */
+ 
+ #ifdef PUSH_ROUNDING
+ 
+ #ifndef PUSH_ARGS_REVERSED
+ #if defined (STACK_GROWS_DOWNWARD) != defined (ARGS_GROW_DOWNWARD)
+ #define PUSH_ARGS_REVERSED  PUSH_ARGS
+ #endif
+ #endif
+ 
+ #endif
+ 
+ #ifndef PUSH_ARGS_REVERSED
+ #define PUSH_ARGS_REVERSED 0
+ #endif
+ 
  /* If PREFERRED_STACK_BOUNDARY is not defined, set it to STACK_BOUNDARY.
     STACK_BOUNDARY is required.  */
  #ifndef PREFERRED_STACK_BOUNDARY
*** gimplify.c.~1~	2003-06-26 16:03:08.000000000 -0400
--- gimplify.c	2003-06-27 18:45:11.000000000 -0400
*************** gimplify_call_expr (expr_p, pre_p, post_
*** 1489,1496 ****
--- 1492,1504 ----
  
    gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
  		 is_gimple_id, fb_rvalue);
+ 
+   if (PUSH_ARGS_REVERSED)
+     TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
    gimplify_expr (&TREE_OPERAND (*expr_p, 1), pre_p, post_p,
  		 is_gimple_arglist, fb_rvalue);
+   if (PUSH_ARGS_REVERSED)
+     TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
  
    /* If the function is "const", then clear TREE_SIDE_EFFECTS on its
       decl.  This allows us to eliminate redundant or useless
*** tm.texi.~1~	2003-06-03 15:56:20.000000000 -0400
--- tm.texi	2003-06-28 02:42:44.000000000 -0400
*************** That directs GCC to use an alternate str
*** 3405,3410 ****
--- 3405,3417 ----
  allocate the entire argument block and then store the arguments into
  it.  When @code{PUSH_ARGS} is nonzero, @code{PUSH_ROUNDING} must be defined too.
  
+ @findex PUSH_ARGS_REVERSED
+ @item PUSH_ARGS_REVERSED
+ A C expression.  If nonzero, function arguments will be evaluated from
+ last to first, rather than from first to last.  If this macro is not
+ defined, it defaults to @code{PUSH_ARGS} on targets where the stack
+ and args grow in opposite directions, and 0 otherwise.
+ 
  @findex PUSH_ROUNDING
  @item PUSH_ROUNDING (@var{npushed})
  A C expression that is the number of bytes actually pushed onto the

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]