XL Fortran for AIX 8.1

User's Guide


Linkage Convention for Argument Passing

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.)

Argument Passing Rules (by Value)

From the following illustration, we state these rules:

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 4. Storage Mapping of Parm Area On the Stack in 32-Bit Environment

REQTEXT

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

REQTEXT

Order of Arguments in Argument List

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.


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 ]