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]

Re: fix INIT_CUMULATIVE_ARGS for split_complex on rs6000


On Thu, Jun 03, 2004 at 08:40:53PM +0100, Joern Rennecke wrote:
> > n_named_args is comuted using args_so_far.  You have moved the initialization
> > of that variable below the first use.
> > I don't see any sane way to implement your new INIT_CUMULATIVE_ARGS semantics.
> 
> P.S.: One way you could fix your patch is if you change
> targetm.calls.strict_argument_naming and
> targetm.calls.pretend_outgoing_varargs_named to take a function type as
> argument, instead of a CUMULATIVE_ARGS argument.

I'm sorry.  My only excuse, and a poor one, is that I developed the
INIT_CUMULATIVE_ARGS change on the 3.3 branch and obviously wasn't
careful enough in porting to mainline.  In 3.3, STRICT_ARGUMENT_NAMING
and PRETEND_OUTGOING_VARARGS_NAMED are macros that don't take a
CUMULATIVE_ARGS param.

I agree that your suggestion of passing the function type makes sense,
and will allow an easy fix for SH, the only target affected by my change
since it is the only target (at least in the public tree) that makes use
of the new parameter of targetm.calls.strict_argument_naming and/or
targetm.calls.pretend_outgoing_varargs_named.  I have a patch to
implement this fix, but then thought of another way.  :)

The CUMULATIVE_ARGS parameter is a natural way to pass information
around amongst the function arg machinery, so it might be better to keep
the two targetm.calls predicates as they are.  Instead, we can move the
INIT_CUMULATIVE_ARGS call back to where it was in expand_call, and pass
the raw number of named function parms to INIT_CUMULATIVE_ARGS,
ie. the arg count without adjusting for strict_argument_naming and
pretend_outgoing_varargs_named.  This will work fine for rs6000, which
needs the number of args post complex splitting.

	* calls.c (expand_call): Call INIT_CUMULATIVE_ARGS earlier, and
	pass raw n_named_args to it.
	* targhooks.c: Formatting.
	(hook_bool_CUMULATIVE_ARGS_false): Correct comment.

Bootstrap and regression test powerpc64-linux and i686-linux in
progress.  OK for mainline and 3.4?  (Even assuming a speedy review, I
probably won't commit this until I get home from Ottawa, Tues morning
Australian time - errm, probably even later than that considering I'll
likely be sleep deprived on arriving home..)

diff -urp -x'*~' gcc-mainline.orig/gcc/calls.c gcc-mainline/gcc/calls.c
--- gcc-mainline.orig/gcc/calls.c	2004-05-30 20:44:19.000000000 +0930
+++ gcc-mainline/gcc/calls.c	2004-06-06 01:45:05.000000000 +0930
@@ -2275,6 +2275,26 @@ expand_call (tree exp, rtx target, int i
     num_actuals++;
 
   /* Compute number of named args.
+     First, do a raw count of the args for INIT_CUMULATIVE_ARGS.  */
+
+  if (type_arg_types != 0)
+    n_named_args
+      = (list_length (type_arg_types)
+	 /* Count the struct value address, if it is passed as a parm.  */
+	 + structure_value_addr_parm);
+  else
+    /* If we know nothing, treat all args as named.  */
+    n_named_args = num_actuals;
+
+  /* Start updating where the next arg would go.
+
+     On some machines (such as the PA) indirect calls have a different
+     calling convention than normal calls.  The fourth argument in
+     INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
+     or not.  */
+  INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, fndecl, n_named_args);
+
+  /* Now possibly adjust the number of named args.
      Normally, don't include the last named arg if anonymous args follow.
      We do include the last named arg if
      targetm.calls.strict_argument_naming() returns nonzero.
@@ -2292,27 +2312,17 @@ expand_call (tree exp, rtx target, int i
      we do not have any reliable way to pass unnamed args in
      registers, so we must force them into memory.  */
 
-  if ((targetm.calls.strict_argument_naming (&args_so_far)
-       || ! targetm.calls.pretend_outgoing_varargs_named (&args_so_far))
-      && type_arg_types != 0)
-    n_named_args
-      = (list_length (type_arg_types)
-	 /* Don't include the last named arg.  */
-	 - (targetm.calls.strict_argument_naming (&args_so_far) ? 0 : 1)
-	 /* Count the struct value address, if it is passed as a parm.  */
-	 + structure_value_addr_parm);
+  if (type_arg_types != 0
+      && targetm.calls.strict_argument_naming (&args_so_far))
+    ;
+  else if (type_arg_types != 0
+	   && ! targetm.calls.pretend_outgoing_varargs_named (&args_so_far))
+    /* Don't include the last named arg.  */
+    --n_named_args;
   else
-    /* If we know nothing, treat all args as named.  */
+    /* Treat all args as named.  */
     n_named_args = num_actuals;
 
-  /* Start updating where the next arg would go.
-
-     On some machines (such as the PA) indirect calls have a different
-     calling convention than normal calls.  The fourth argument in
-     INIT_CUMULATIVE_ARGS tells the backend if this is an indirect call
-     or not.  */
-  INIT_CUMULATIVE_ARGS (args_so_far, funtype, NULL_RTX, fndecl, n_named_args);
-
   /* Make a vector to hold all the information about each arg.  */
   args = alloca (num_actuals * sizeof (struct arg_data));
   memset (args, 0, num_actuals * sizeof (struct arg_data));
diff -urp -x'*~' gcc-mainline.orig/gcc/targhooks.c gcc-mainline/gcc/targhooks.c
--- gcc-mainline.orig/gcc/targhooks.c	2004-03-04 14:13:10.000000000 +1030
+++ gcc-mainline/gcc/targhooks.c	2004-06-06 01:53:35.000000000 +0930
@@ -113,7 +113,7 @@ default_builtin_setjmp_frame_value (void
   return virtual_stack_vars_rtx;
 }
 
-/* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true.  */
+/* Generic hook that takes a CUMULATIVE_ARGS pointer and returns false.  */
 
 bool
 hook_bool_CUMULATIVE_ARGS_false (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
@@ -122,9 +122,10 @@ hook_bool_CUMULATIVE_ARGS_false (CUMULAT
 }
 
 bool
-default_pretend_outgoing_varargs_named(CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
+default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
 {
-  return (targetm.calls.setup_incoming_varargs != default_setup_incoming_varargs);
+  return (targetm.calls.setup_incoming_varargs
+	  != default_setup_incoming_varargs);
 }
 
 /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true.  */


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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