User's Guide
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.
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 requires
one word and appears in that word exactly as it would appear in a GPR.
It is right-justified, 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 appear in successive words as they
would anywhere in storage, satisfying all appropriate alignment
requirements. Structures are aligned to a fullword and occupy
(sizeof(struct X)+3)/4 fullwords with any padding at the
end. A structure that is smaller than a word is left-justified within
its word 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.)
|
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, the parameter list is a conceptually contiguous
piece of storage that contains a list of words. For efficiency, the
first 8 words of the list are not actually stored in the space that is
reserved for them, but are passed in GPR3-GPR10. Further, the first 13
floating-point value parameters are passed in FPR1-FPR13. Those beyond
the first 8 words of the parameter list are also in storage. Those
within the first 8 words of the parameter list have GPRs reserved for them,
but they are not used.
- In a 64-bit environment, the preceding information holds true if
references to words are replaced with doublewords.
- 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.
- 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(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 36. Storage Mapping of Parm Area On the Stack in 32-Bit Environment

Figure 37. 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 (5)
- "Present" indicators for optional arguments that are passed by value
- Length arguments for strings (5)
Footnotes:
(5)
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.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
© Copyright IBM Corporation 1990, 1998.