pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11- 2
Pictorial Overview of pTAL Structure Alignment
Alignment guidelines for native processes:
Accessing data in memory takes the least amount of time if the data is well-aligned
and either the compiler has allocated the data or you reference the data with a
pointer that specifies REFALIGNED(8). A data item is well-aligned if its byte
address is an integral multiple of its length. For example, an INT is well-aligned if it
begins at an even-byte address, an INT(32) at an address that is a multiple of four,
and so forth.
Accessing data in memory takes the least amount of time when the data is well-
aligned and the compiler knows that it is well-aligned. A data item is well-aligned if
its byte address is an integral multiple of its length. For example, an INT is well-
aligned if it begins at an even-byte address, an INT(32) at an address that is a
multiple of four, and so forth.
Accessing data is somewhat slower if the data is not well-aligned and you
reference the data using a pointer that specifies REFALIGNED(2).
Accessing data is significantly slower if the data is not well-aligned, but pTAL
generates code that functions as if the data is well-aligned. In this case, your
program traps to the millicode exception handler, which completes the data access
and returns to your program.
To comply with these guidelines, some structures require that you explicitly add filler to
ensure that:
Each field begins at an address that is a multiple of its length.
The total length of a structure is a multiple of the widest field in the structure.
Terms used in this topic:
FIELDALIGN is a clause that you can specify when you declare a structure:
°
FIELDALIGN(SHARED2) tells pTAL to align the fields of the structure
according to the same rules used by TAL. In a SHARED2 structure, pTAL
treats all fields that are greater than 16 bits as misaligned.
°
FIELDALIGN(SHARED8) tells pTAL to align the fields of the structure for
optimal performance on native architecture. When you declare a structure with
FIELDALIGN(SHARED8), you must explicitly declare filler to ensure that the
preceding rules for well-aligned data are satisfied. You do not need to add filler
to a SHARED2 structure unless your application requires it.
The base alignment of a structure is the greater of the widest field in the structure
and the structure’s field alignment—the value you specified for the FIELDALIGN
clause. Table 11-1 on page 11-3 summarizes how the base alignment of a structure
is related to its field alignment.