24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Function Values<br />

Functions return their values according to type:<br />

v INTEGER and LOGICAL of kind 1, 2, and 4 are returned (right justified) in R3.<br />

v In 32-bit mode, INTEGER and LOGICAL of kind 8 are returned in R3 and R4.<br />

v In 64-bit mode, INTEGER and LOGICAL of kind 8 are returned in R3.<br />

v<br />

REAL of kind 4 or 8 are returned in FP1. REAL of kind 16 are returned in FP1<br />

and FP2.<br />

v COMPLEX of kind 4 or 8 are returned in FP1 and FP2. COMPLEX of kind 16<br />

are returned in FP1-FP4.<br />

v<br />

v<br />

Character strings are returned in a buffer allocated by the caller. The address<br />

and the length of this buffer are passed in R3 and R4 as hidden parameters. The<br />

first explicit parameter word is in R5, and all subsequent parameters are moved<br />

to the next word.<br />

Structures are returned in a buffer that is allocated by the caller. The address is<br />

passed in R3; there is no length. The first explicit parameter is in R4.<br />

The Stack Floor<br />

The stack floor is a system-defined address below which the stack cannot grow. All<br />

programs in the system must avoid accessing locations in the stack segment that<br />

are below the stack floor.<br />

All programs must maintain other system invariants that are related to the stack:<br />

v<br />

No data is saved or accessed from an address lower than the stack floor.<br />

v The stack pointer is always valid. When the stack frame size is more than 32 767<br />

bytes, you must take care to ensure that its value is changed in a single<br />

instruction. This step ensures that there is no timing window where a signal<br />

handler would either overlay the stack data or erroneously appear to overflow<br />

the stack segment.<br />

Stack Overflow<br />

The linkage convention requires no explicit inline check <strong>for</strong> overflow. The<br />

operating system uses a storage protection mechanism to detect stores past the end<br />

of the stack segment.<br />

Prolog and Epilog<br />

On entry to a procedure, you might have to do some or all of the following steps:<br />

1. Save the link register at offset 8 <strong>for</strong> 32-bit environments (or offset 16 <strong>for</strong> 64-bit<br />

environments) from the stack pointer if necessary.<br />

2. If you use any of the CR bits 8-23 (CR2, CR3, CR4, CR5), save the CR at<br />

displacement 4 <strong>for</strong> 32-bit environments (or displacement 8 <strong>for</strong> 64-bit<br />

environments) from the current stack pointer.<br />

3. Save any nonvolatile FPRs that are used by this procedure in the caller’s FPR<br />

save area. You can use a set of routines: _savef14, _savef15, ... _savef31.<br />

4. Save all nonvolatile GPRs that are used by this procedure in the caller’s GPR<br />

save area.<br />

5. Store back chain and decrement stack pointer by the size of the stack frame.<br />

Note that if a stack overflow occurs, it will be known immediately when the<br />

store of the back chain is done.<br />

366 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!