The system linkage convention takes advantage of the large number of
registers available. The linkage convention passes arguments in both
GPRs and FPRs. Two fixed lists, R3-R10 and FP1-FP13, specify the GPRs
and FPRs available for argument passing.
When there are more argument words than available argument GPRs and FPRs,
the remaining words are passed in storage on the stack. The values in
storage are the same as if they were in registers.
In a 64-bit environment, the size of the parameter area is sufficient to contain all the
arguments passed on any call statement from a procedure that is associated
with the stack frame. Although not all the arguments for a particular
call actually appear in storage, it is convenient to consider them as forming
a list in this area, each one occupying one or more words.
For call by reference (as is the default for Fortran), the address of the
argument is passed in a register. The following information refers to
call by value, as in C or as in Fortran when %VAL is used. For
purposes of their appearance in the list, arguments are classified as
floating-point values or non-floating-point values:
|
---|
In a 32-bit Environment
- Each INTEGER(8) and LOGICAL(8) argument requires two
words.
- Any other non-floating-point scalar argument of intrinsic type or procedure/function pointers requires one word and appears in that word exactly as it would
appear in a GPR. It is signed or unsigned/extended, if language semantics specify, and is word aligned.
- Each single-precision (REAL(4)) value occupies one word.
Each double-precision (REAL(8)) value occupies two successive words
in the list. Each extended-precision (REAL(16)) value occupies
four successive words in the list.
- A COMPLEX value occupies twice as many words as a REAL
value with the same kind type parameter.
- In Fortran and C, structure values are passed
"val-by-ref". That is, the compiler actually passes the address of
a copy of the structure.
|
In a 64-bit Environment |
---|
- All non-floating-point values require one doubleword that is doubleword
aligned.
- Each single-precision (REAL(4)) value and each double-precision
(REAL(8)) value occupies one doubleword in the list. Each
extended-precision (REAL(16)) value occupies two successive
doublewords in the list.
- A COMPLEX value occupies twice as many doublewords as a
REAL value with the same kind type parameter.
- In Fortran and C, structure values appear in successive words as they
would anywhere in storage, satisfying all appropriate alignment
requirements. Structures are aligned to a doubleword and occupy
(sizeof(struct X)+7)/8 doublewords, with any padding at the
end. A structure that is smaller than a doubleword is left-justified
within its doubleword or register. Larger structures can occupy
multiple registers and may be passed partly in storage and partly in
registers.
- Other aggregate values, including Pascal records, are passed
"val-by-ref". That is, the compiler actually passes their address
and arranges for a copy to be made in the invoked program.
- A procedure or function pointer is passed as a pointer to the
routine's function descriptor; its first word contains its entry
point address. (See Pointers to Functions for more information.)
|
From the following illustration, we state these rules:
- In a 32-bit environment, arguments to called functions are passed in
the GPRs and FPRs. Up to eight words are passed in GPR3-GPR10 and up to
eight floating-point arguments in FPR1-FPR8. If fewers arguments are
passed, unneeded registers are not loaded. If the passed arguments will
not fit in registers, only enough space to hold the arguments that do not fit
is allocated in the stack frame.
- In a 64-bit environment, if the called procedure treats the parameter list as a contiguous
piece of storage (for example, if the address of a parameter is taken in C),
the parameter registers are stored in the space reserved for them in the
stack.
- A register image is stored on the stack.
- In a 64-bit environment, the argument area (P1...Pn)
must be large enough to hold the largest parameter list.
Here is an example of a call to a function:
f(%val(l1), %val(l2), %val(l3), %val(l4), %val(l5), %val(l6), %val(l7),
%val(d1), %val(f1), %val(c1), %val(d2), %val(s1), %val(cx2))
where:
- l denotes integer(4) (fullword integer)
- d denotes real(8) (double precision)
- f denotes real(4) (real)
- s denotes integer(2) (halfword integer)
- c denotes character (one character)
- cx denotes complex(8) (double complex)
Figure 4. Storage Mapping of Parm Area On the Stack in 32-Bit Environment

Figure 5. Storage Mapping of Parm Area On the Stack in 64-Bit Environment

The argument list is constructed in the following order. Items in
the same bullet appear in the same order as in the procedure declaration,
whether or not argument keywords are used in the call.
- All addresses or values (or both) of actual arguments 4
- "Present" indicators for optional arguments that are passed by value
- Length arguments for strings 4
Footnotes:
- 4
-
There may be other items in this list during Fortran-Fortran calls.
However, they will not be visible to non-Fortran procedures that follow the
calling rules in this section.
