From: lai@mips.COM (David Lai)
Subject: Re: ANSI-C style variadic functions on MIPS
Date: 6 Jan 90 19:51:41 GMT [thread overview]
Message-ID: <34218@mips.mips.COM> (raw)
In-Reply-To: 1990Jan6.062805.23863@athena.mit.edu
In article <1990Jan6.062805.23863@athena.mit.edu> raeburn@athena.mit.edu (Ken Raeburn) writes:
>
>Maybe I should point it out again: The troublesome case is a function
>declared:
> foo (double d, ...)
>
>How does it know, when you ask for a "double", that it should look at
>the second FP reg save slot? All that's available to the macros is
>the address of d; but since the macros can't tell the difference
>between foo's declaration above and
> foo2 (double d1, double d2, ...)
>(for which it should start with the first stack argument) how does it
>know when to switch from FP reg save slots to regular stack arguments?
>It needs to know, if they aren't contiguous in memory.
>
>I should rephrase that: How _should_ it know? My claim is that
>(lacking more information from the compiler) it does not.
>
>-- Ken
The MIPS compiler does support full stdarg.h type calls, even if the first
argument is a float (or double). The secret is that the prototype must be
*visible* at the caller side (see ANSI section 4.8.1.3). The compiler
knows where the beginning of the variable part of the argument list is
(the position of the '...' in the prototype), and hence forces arguments
to be passed in the integer registers (even arguments that are
float or double). The actual function must also be *defined* with the
same prototype form, including the '...'.
Example:
main()
{
extern foo(double,...);
foo(2.0,3.0); /* passes 2.0 in fp reg, 3.0 in regular registers */
foo2(2.0,3.0); /* passes 2.0, 3.0 in fp regs */
}
We are aware of limitations of the old style varargs.h type calls when
the first argument is a float or double.
--
"What is a DJ if he can't scratch?" - Uncle Jamms Army
David Lai (lai@mips.com || {ames,prls,pyramid,decwrl}!mips!lai)
next prev parent reply other threads:[~1990-01-06 19:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-01-05 8:52 ANSI-C style variadic functions on MIPS Ken Raeburn
1990-01-05 17:53 ` Dirk Grunwald
1990-01-06 6:28 ` Ken Raeburn
1990-01-06 19:51 ` David Lai [this message]
1990-01-08 4:15 ` Ken Raeburn
1990-01-09 20:07 ` David Lai
1990-01-08 14:31 ` Jim Gettys
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox