fix vector varargs parameter passing on darwin

Geoff Keating geoffk@geoffk.org
Tue Nov 11 05:11:00 GMT 2003


Alan Modra <amodra@bigpond.net.au> writes:

> On Thu, Nov 06, 2003 at 01:51:26PM -0800, Geoffrey Keating wrote:
> > 
> > The ABI is still not compatible with the Darwin/AIX ABI for
> > non-varargs functions, but only because the ABI specifies that vector
> > parameters are treated as if they are placed after all other
> > parameters in the argument list.  (Suggestions as how to implement
> > this cleanly are welcome.)
> 
> I suggest changing the ABI.  Seriously.

Oh, I only wish we could.  Unfortunately, we have shipping libraries...

> The main reason being I can't see how this scheme of putting vector
> parameters last can work when considering all the possible combinations
> of prototyped/non-prototyped and varargs/non-varargs functions.
> 
> Now, I haven't actually read the Darwin/AIX ABI, but I'm sure you must
> do something different for varargs functions.  It's not generally
> possible for a varargs function to know when it has come to the end of
> its non-vector parameters, so how can you know where vector params on
> the stack go if they're at the end of other params?  Or else varargs
> functions taking vector params are limited to 12 vector params (or
> whatever the number is), passed in registers.  That might seem a
> sufficient number for most functions, but an ABI needs to cater for all
> the crazy code that people write.
> 
> So given that vector arguments passed on the stack to varargs functions
> are placed in a different location to that for a non-varargs function,
> what to do you for a call to a non-prototyped function?  Either choice
> of location is going to be wrong some of the time.  Set a flag saying
> "expect vector params at end"?  Then functions need to generate code to
> retrieve arguments in either place.  Yuck.

It works by:

1. Having completely separate rules for varargs and non-varargs functions.  
   (That's how GCC can work just fine for varargs functions now, but not
   for non-varargs functions.)
2. Supporting only ISO C; in particular, you must prototype a varargs
   function.  (Therefore, a non-prototyped function is not varargs, and
   when you encounter a call to it you know what the types of its
   parameters are.)

-- 
- Geoffrey Keating <geoffk@geoffk.org>



More information about the Gcc-patches mailing list