This is the mail archive of the gcc@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]

Re: PR2076



On Thursday, April 26, 2001, at 10:32  AM, Dale Johannesen wrote:

>
> On Wednesday, April 25, 2001, at 06:30  PM, David Edelsohn wrote:
>
>> 	This does not seem correct to me.  The question is not where the
>> receiver looks for the arguments, but what the ABI says.  The ABI (for 
>> AIX
>> at least) says that it must be placed in both locations.
>
> True, but I don't think that's necessarily an overriding consideration, 
> IF no runtime compatability problems can arise.   According to its 
> docs, anyway, gcc has been willing to tolerate some actual runtime 
> incompatiblities (see the chapter "Interfacing to GCC Output" for 
> examples).  If that's acceptable, this difference [which is harmless, 
> and results in  more efficient code generation in a common case, namely 
> printf("%f")]  should be also, IMHO.  To be sure, my main job at the 
> moment is improving the quality of the generated code, which may bias 
> me a bit.:)
>
> However, I am not the final arbiter.  So I will also do it in full 
> pedantic ABI conformance, and whoever has authority can take their pick.

And here it is.  Bootstrap & check pass on Darwin.  Same caveats as 
previous attempt.

2001-04-26  Dale Johannesen  <dalej@apple.com>

         * config/rs6000/rs6000.h:  enable STRICT_ARGUMENT_NAMING
         * config/rs6000/rs6000.c (function_arg_advance, function_arg,
              function_arg_partial_nregs, setup_incoming_varargs):  change
              code generation around call to be correct for varargs when
              STRICT_ARGUMENT_NAMING is on
Index: rs6000.c
===================================================================
RCS file: /cvs/repository/CoreTools/gcc3/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.18
diff -u -d -b -w -r1.18 rs6000.c
--- rs6000.c    2001/04/17 02:14:18     1.18
+++ rs6000.c    2001/04/26 20:38:15
@@ -2004,12 +2004,9 @@
                    && function_arg_boundary (mode, type) == 64) ? 1 : 0;
        cum->words += align;

-      if (named)
-       {
-         cum->words += RS6000_ARG_SIZE (mode, type, named);
+      cum->words += RS6000_ARG_SIZE (mode, type, 1);
           if (GET_MODE_CLASS (mode) == MODE_FLOAT && TARGET_HARD_FLOAT)
             cum->fregno++;
-       }

        if (TARGET_DEBUG_ARG)
         {
@@ -2113,9 +2110,6 @@
                    && function_arg_boundary (mode, type) == 64) ? 1 : 0;
        int align_words = cum->words + align;

-      if (! named)
-       return NULL_RTX;
-
        if (type && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
          return NULL_RTX;

@@ -2169,9 +2163,6 @@
       tree type;
       int named;
  {
-  if (! named)
-    return 0;
-
    if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
      return 0;

@@ -2182,7 +2173,7 @@
      }

    if (cum->words < GP_ARG_NUM_REG
-      && GP_ARG_NUM_REG < (cum->words + RS6000_ARG_SIZE (mode, type, 
named)))
+      && GP_ARG_NUM_REG < (cum->words + RS6000_ARG_SIZE (mode, type, 
1)))
      {
        int ret = GP_ARG_NUM_REG - cum->words;
        if (ret && TARGET_DEBUG_ARG)
@@ -2249,9 +2240,6 @@
    int reg_size = TARGET_32BIT ? 4 : 8;
    rtx save_area = NULL_RTX, mem;
    int first_reg_offset, set;
-
-  if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
-    {
        tree fntype;
        int stdarg_p;

@@ -2266,6 +2254,8 @@
        if (stdarg_p)
         function_arg_advance (&next_cum, mode, type, 1);

+  if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
+    {
        /* Indicate to allocate space on the stack for varargs save 
area.  */
        /* ??? Does this really have to be located at a magic spot on the
          stack, or can we allocate this with assign_stack_local 
instead.  */
@@ -2278,10 +2268,10 @@
      }
    else
      {
+      first_reg_offset = next_cum.words;
        save_area = virtual_incoming_args_rtx;
        cfun->machine->sysv_varargs_p = 0;

-      first_reg_offset = cum->words;
        if (MUST_PASS_IN_STACK (mode, type))
         first_reg_offset += RS6000_ARG_SIZE (TYPE_MODE (type), type, 1);
      }
Index: rs6000.h
===================================================================
RCS file: /cvs/repository/CoreTools/gcc3/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.6
diff -u -d -b -w -r1.6 rs6000.h
--- rs6000.h    2001/04/03 01:53:17     1.6
+++ rs6000.h    2001/04/26 20:38:15
@@ -205,6 +205,12 @@
  /* Nonzero if we need to schedule the prolog and epilog.  */
  #define MASK_SCHED_PROLOG      0x00040000

+/* This causes the last named parameter to a varargs function to
+   be treated as an ordinary parameter, not as part of the varargs
+   area.  Slightly improves generated code, and fixes a bug that
+   shows up in 980205.c.  Does not affect SVR4 or Solaris. */
+#define STRICT_ARGUMENT_NAMING 1
+
  #define TARGET_POWER           (target_flags & MASK_POWER)
  #define TARGET_POWER2          (target_flags & MASK_POWER2)
  #define TARGET_POWERPC         (target_flags & MASK_POWERPC)


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