More expand_call cleanups

Jeffrey A Law law@cygnus.com
Wed Feb 24 15:06:00 GMT 1999


In my ongoing effort to make expand_call more readable, I've factored out
several hunks of code into their own funtions.  Here's the first of those
cleanups.

It bootstraps on the x86 and built on the PA too.

More to follow.


	* calls.c (finalize_must_preallocate): New function, extracted from
	expand_call.
	(expand_call): Use finalize_must_preallocate.

	* calls.c (store_one_arg): Mark "variable_size" as possibly unused.

Index: calls.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/calls.c,v
retrieving revision 1.43
diff -c -3 -p -r1.43 calls.c
*** calls.c	1999/02/16 20:42:28	1.43
--- calls.c	1999/02/24 23:01:39
*************** static void store_one_arg	PROTO ((struct
*** 137,143 ****
--- 137,147 ----
  					int));
  static void store_unaligned_arguments_into_pseudos PROTO ((struct arg_data *,
  							   int));
+ static int finalize_must_preallocate		PROTO ((int, int,
+ 							struct arg_data *,
+ 							struct args_size *));
  
+ 
  #if defined(ACCUMULATE_OUTGOING_ARGS) && defined(REG_PARM_STACK_SPACE)
  static rtx save_fixed_argument_area	PROTO ((int, rtx, int *, int *));
  static void restore_fixed_argument_area	PROTO ((rtx, rtx, int, int));
*************** store_unaligned_arguments_into_pseudos (
*** 822,827 ****
--- 826,889 ----
        }
  }
  
+ /* Given the current state of MUST_PREALLOCATE and information about
+    arguments to a function call in NUM_ACTUALS, ARGS and ARGS_SIZE,
+    compute and return the final value for MUST_PREALLOCATE.  */
+ 
+ static int
+ finalize_must_preallocate (must_preallocate, num_actuals, args, args_size)
+      int must_preallocate;
+      int num_actuals;
+      struct arg_data *args;
+      struct args_size *args_size;
+ {
+   /* See if we have or want to preallocate stack space.
+ 
+      If we would have to push a partially-in-regs parm
+      before other stack parms, preallocate stack space instead.
+ 
+      If the size of some parm is not a multiple of the required stack
+      alignment, we must preallocate.
+ 
+      If the total size of arguments that would otherwise create a copy in
+      a temporary (such as a CALL) is more than half the total argument list
+      size, preallocation is faster.
+ 
+      Another reason to preallocate is if we have a machine (like the m88k)
+      where stack alignment is required to be maintained between every
+      pair of insns, not just when the call is made.  However, we assume here
+      that such machines either do not have push insns (and hence preallocation
+      would occur anyway) or the problem is taken care of with
+      PUSH_ROUNDING.  */
+ 
+   if (! must_preallocate)
+     {
+       int partial_seen = 0;
+       int copy_to_evaluate_size = 0;
+       int i;
+ 
+       for (i = 0; i < num_actuals && ! must_preallocate; i++)
+ 	{
+ 	  if (args[i].partial > 0 && ! args[i].pass_on_stack)
+ 	    partial_seen = 1;
+ 	  else if (partial_seen && args[i].reg == 0)
+ 	    must_preallocate = 1;
+ 
+ 	  if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
+ 	      && (TREE_CODE (args[i].tree_value) == CALL_EXPR
+ 		  || TREE_CODE (args[i].tree_value) == TARGET_EXPR
+ 		  || TREE_CODE (args[i].tree_value) == COND_EXPR
+ 		  || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
+ 	    copy_to_evaluate_size
+ 	      += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
+ 	}
+ 
+       if (copy_to_evaluate_size * 2 >= args_size->constant
+ 	  && args_size->constant > 0)
+ 	must_preallocate = 1;
+     }
+   return must_preallocate;
+ }
  /* Generate all the code for a function call
     and return an rtx for its value.
     Store the value in TARGET (specified as an rtx) if convenient.
*************** expand_call (exp, target, ignore)
*** 1568,1618 ****
        args_size.constant -= reg_parm_stack_space;
  #endif
      }
- 
-   /* See if we have or want to preallocate stack space.
- 
-      If we would have to push a partially-in-regs parm
-      before other stack parms, preallocate stack space instead.
- 
-      If the size of some parm is not a multiple of the required stack
-      alignment, we must preallocate.
  
!      If the total size of arguments that would otherwise create a copy in
!      a temporary (such as a CALL) is more than half the total argument list
!      size, preallocation is faster.
! 
!      Another reason to preallocate is if we have a machine (like the m88k)
!      where stack alignment is required to be maintained between every
!      pair of insns, not just when the call is made.  However, we assume here
!      that such machines either do not have push insns (and hence preallocation
!      would occur anyway) or the problem is taken care of with
!      PUSH_ROUNDING.  */
! 
!   if (! must_preallocate)
!     {
!       int partial_seen = 0;
!       int copy_to_evaluate_size = 0;
! 
!       for (i = 0; i < num_actuals && ! must_preallocate; i++)
! 	{
! 	  if (args[i].partial > 0 && ! args[i].pass_on_stack)
! 	    partial_seen = 1;
! 	  else if (partial_seen && args[i].reg == 0)
! 	    must_preallocate = 1;
! 
! 	  if (TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
! 	      && (TREE_CODE (args[i].tree_value) == CALL_EXPR
! 		  || TREE_CODE (args[i].tree_value) == TARGET_EXPR
! 		  || TREE_CODE (args[i].tree_value) == COND_EXPR
! 		  || TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))))
! 	    copy_to_evaluate_size
! 	      += int_size_in_bytes (TREE_TYPE (args[i].tree_value));
! 	}
! 
!       if (copy_to_evaluate_size * 2 >= args_size.constant
! 	  && args_size.constant > 0)
! 	must_preallocate = 1;
!     }
  
    /* If the structure value address will reference the stack pointer, we must
       stabilize it.  We don't need to do this if we know that we are not going
--- 1630,1639 ----
        args_size.constant -= reg_parm_stack_space;
  #endif
      }
  
!   /* Now make final decision about preallocating stack space.  */
!   must_preallocate = finalize_must_preallocate (must_preallocate,
! 						num_actuals, args, &args_size);
  
    /* If the structure value address will reference the stack pointer, we must
       stabilize it.  We don't need to do this if we know that we are not going
*************** store_one_arg (arg, argblock, may_be_all
*** 3481,3487 ****
       struct arg_data *arg;
       rtx argblock;
       int may_be_alloca;
!      int variable_size;
       int reg_parm_stack_space;
  {
    register tree pval = arg->tree_value;
--- 3502,3508 ----
       struct arg_data *arg;
       rtx argblock;
       int may_be_alloca;
!      int variable_size ATTRIBUTE_UNUSED;
       int reg_parm_stack_space;
  {
    register tree pval = arg->tree_value;


More information about the Gcc-patches mailing list