The calling convention differs for each architecture. You can see this by examining the assembler code generated by the compiler for a simple test function.
The following example is compiled for a 32-bit platform:
% more fptest.c
double sum(double d1,double d2, double d3, double d4)
{
return d1 + d2 + d3 + d4;
}
% cc -O -xarch=sparc -m32 -S fptest.c
% more fptest.s
....
.global sum
sum:
/* 000000 2 */ st %o0,[%sp+68]
/* 0x0004 */ st %o2,[%sp+76]
/* 0x0008 */ st %o1,[%sp+72]
/* 0x000c */ st %o3,[%sp+80]
/* 0x0010 */ st %o4,[%sp+84]
/* 0x0014 */ st %o5,[%sp+88]
! 3 ! return d1 + d2 + d3 + d4;
/* 0x0018 3 */ ld [%sp+68],%f2
/* 0x001c */ ld [%sp+72],%f3
/* 0x0020 */ ld [%sp+76],%f10
/* 0x0024 */ ld [%sp+80],%f11
/* 0x0028 */ ld [%sp+84],%f4
/* 0x002c */ faddd %f2,%f10,%f12
/* 0x0030 */ ld [%sp+88],%f5
/* 0x0034 */ ld [%sp+92],%f6
/* 0x0038 */ ld [%sp+96],%f7
/* 0x003c */ faddd %f12,%f4,%f14
/* 0x0040 */ retl ! Result = %f0
/* 0x0044 */ faddd %f14,%f6,%f0
....In the example code, you can see that the first three floating-point parameters are passed in %o0-%o5, and the fourth is passed on the stack at locations %sp+92 and %sp+96. Note that this location is 4-byte aligned, so it is not possible to use a single floating point load double instruction to load it.
Here is an example for 64-bit code.
% more inttest.c
long sum(long v1,long v2, long v3, long v4, long v5, long v6, long v7)
{
return v1 + v2 + v3 + v4 + v5 + v6 + v7;
}
% cc -O -xarch=sparc -m64 -S inttest.c
% more inttest.s...
/* 000000 2 */ ldx [%sp+2223],%g2
/* 0x0004 3 */ add %o0,%o1,%g1
/* 0x0008 */ add %o3,%o2,%g3
/* 0x000c */ add %g3,%g1,%g4
/* 0x0010 */ add %o5,%o4,%g5
/* 0x0014 */ add %g5,%g4,%o1
/* 0x0018 */ retl ! Result = %o0
/* 0x001c */ add %o1,%g2,%o0
...In the code above, you can see that the first action is to load the seventh integer parameter from the stack.