Copyright 1998 Lars T Hansen.

$Id: sparc-abi.txt 2543 2005-07-20 21:54:03Z pnkfelix $

		    SPARC calling conventions for C

	   Based on observations of code emitted by gcc 2.7.2
				  and
			  the SPARC v8 manual.


Argument passing
----------------
Scalar arguments are passed contiguously in %o0 .. %05, and then on the
stack in the argument overflow area (see the manual, section D).  In
particular, _double_ values are treated like two scalars when passed
this way, and passed with the most significant word in the first
register and the least significant word in the second register.  If a
double is passed on the memory stack, it is not guaranteed to be aligned
on an 8-byte boundary, so single fp loads must be used to bring it into
registers.  This relatively cretinous mechanism makes it possible to do
varargs with a minimum of mechanism (it's also simple).

When a C procedure is declared with a prototype as receiving a float, e.g.,
   void f( float x ) 
   { ... }
gcc assumes that a float will be passed, in this case in %o0.  If the
procedure is declared with an untyped prototype and types following the
procedure header, e.g., 
   void f( x ) 
   float x;
   { ... }
then gcc assumes that a double will be passed, and converts it internally
to a float before operating on it.


Return values
-------------
Non-floating values are returned in the integer registers, starting with
%o0.  Floating values are returned in the floating-point registers,
starting with %f0.


