pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-34
Alignment Considerations for Structures and
Substructures
For the assignment i32 := p3.s.i, pTAL generates fast code to access the field
because the declaration of p3 does not include a REFALIGNED clause. The reference
alignment therefore defaults to the field alignment of t2, which is SHARED8. Even
though the layout of p3 is based on t2 (which, in turn, incorporates t1, which is
SHARED2), the reference alignment of p3 is 8 because t2 is SHARED8. The access
uses optimal code because, even though substructure s has SHARED2 alignment, its
containing structure has SHARED8 alignment, and pTAL can determine that the offset
of p3.s.i is well-aligned.
Alignment Considerations for Structures and
Substructures
When you declare a substructure, you must be aware of how the base alignment of the
substructure and its containing structure affect references to the fields of the structure
and substructure.
Table 11-2 on page 11-34 summarizes the effects of using substructures with a
different alignment than their containing structures.
Table 11-2. Field Alignment of Substructures
Substructure Field Alignment
Structure Field Alignment
AUTO PLATFORM SHARED8 SHARED2
AUTO AUTO PLATFORM Invalid Invalid
PLATFORM Invalid PLATFORM Invalid Invalid
SHARED8 SHARED8 SHARED8 SHARED8 SHARED8*
SHARED2 SHARED2** SHARED2 SHARED2** SHARED2
Default AUTO PLATFORM SHARED8 SHARED2
* On native architecture, if a SHARED8 substructure is contained in a SHARED2 structure (or in an AUTO
structure), fields in the SHARED8 substructure will be well-aligned with respect to the base of the SHARED8
substructure but might not be well-aligned with respect to the base of the SHARED2 structure. Performance will
be somewhat degraded when fields in the substructure are referenced.
** On native architecture, if a SHARED2 substructure is contained in a SHARED8 structure (or in an AUTO
structure), fields in the SHARED2 substructure will be well-aligned with respect to the base of the SHARED2
substructure but might not be well-aligned with respect to the base of the SHARED8 structure. Performance will
be significantly degraded when fields in the substructure are not well-aligned for SHARED8 access. Each such
reference will cause a trap to the millicode exception handler to resolve the reference. Your program will behave
correctly but will be significantly slower than it would without the trap.