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]

Re: PATCH: Pass nameless arguments in general registers in 32 bit ABI


  In message <200109241810.f8OIAQk1028484@hiauly1.hia.nrc.ca>you write:
  > A problem was noted with nest-stdar-1.s with the HP assembler.  
  > 
  > #include <stdarg.h>
  > 
  > main ()
  > {
  >   static double f (int x, ...)
  >     {
  >       va_list args;
  >       double a;
  > 
  >       va_start (args, x);
  >       a = va_arg (args, double);
  >       va_end (args);
  >       return a;
  >     }
  > 
  >   if (f (1, (double)1) != 1.0)
  >     abort ();
  >   exit (0);
  > }
  > 
  > The function f ("f__0") expects double in the general registers.  However,
  > the call in main puts "(double)1" in fr7 with the current code.  The test
  > passes with the GNU assembler because there is a .PARAM statement which
  > tells the linker to generate a stub to copy the argument from the floating
  > to general registers.  The function f__0 saves all the general registers
  > to the frame.
Ah.  Yes, the fact that you can't set the parameter location bits for
static functions with the HP assembler problem.


  > HP cc doesn't like nested functions so I can't compare directly.  Pulling
  > the nested function out, I see that gcc and the HP assembler generate
  > identical calls.  However, the HP compiler adds ARGS_SAVED to the .CALLINFO
  > statement and this causes the linker to generate a stub for the call
  > which we don't get with gcc with the HP assembler.
OK.  ARGS_SAVED was a later addition to the HP assembler (well after I
stopped poking at it to see how it dealt with corner cases).  When I
first noticed it show up, I assumed it was merely for setting bits in
the function's unwind descriptor.  But it appears to also set the
argument relocation bits in the symbol table too.

[ What happens for a static varargs function (as opposed to a static stdarg
  function?  Is ARGS_SAVED set for those too? ]


FWIW, do you actually have documentation which describes what ARGS_SAVED does,
or are you relying strictly on observed behavior?

  > It would seem that we need to generate a "ARGS_SAVED" for functions with
  > variable numbers of arguments.
Probably.  Note however that GAS probably doesn't accept ARGS_SAVED since it
was added after the major PA gas work was done.

  > However, it still seems to me that we save
  > a stub copy if we put nameless outgoing arguments (floats in particular)
  > in the general registers.
This may be a technical violation of the ABI which states that parameters
are always placed into registers based on their type, except for indirect
calls where they're placed into general registers.  So while it saves a 
stub, I'd prefer not to do this without seeing some kind of ABI update from
HP which states this is the preferred behavior.

jeff

ps.  I think it's pretty damn funny that HP has two completely different ways
for setting argument relocation bits, one for normal functions, one for
stdarg (and maybe varargs) functions.  Simply amazing.


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