pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 78 REFALIGNED(8)
STRUCT t1 (*) FIELDALIGN(SHARED2);
BEGIN
INT(32) i;
END;
STRUCT t2 (*) FIELDALIGN(SHARED8);
BEGIN
STRUCT s (t1);
INT(32) i;
END;
INT .EXT p1 (t1) REFALIGNED (8) := extended-address;
INT .EXT p2 (t2) REFALIGNED (2) := extended-address;
INT .EXT p3 (t2) := extended-address;
INT(32) i32;
i32 := p1.i;
i32 := p2.i;
i32 := p3.s.i;
For the assignment i32 := p1.i, pTAL generates fast code to access the field described by t1
because the declaration of pointer p1 specifies REFALIGNED(8). If the field is not well-aligned,
your program will run significantly slower because each reference to elements of p1 will trap to
the millicode exception handler to resolve each memory access.
For the assignment i32 := p2.i, pTAL generates conservative code to access the field described
by t2 because the field might not be well-aligned. The compiler might generate extra instructions
to access the field.
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 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.
Code Generation for Structure References
When pTAL generates code for references to the fields of structures and substructures, it generates
two kinds of code. These are referred to as:
• Fast code
• Conservative code
pTAL generates fast code if you reference fields in a structure compiled with FIELDALIGN(SHARED8).
It generates conservative code if you reference fields in a structure compiled with
FIELDALIGN(SHARED2).
STRUCTALIGN (MAXALIGN) Attribute
NOTE: Use this clause only with the EpTAL compiler. The pTAL compiler reports a syntax error.
The STRUCTALIGN (MAXALIGN) attribute applies only to template structures. If a template structure
has this attribute:
• Each definition structure that uses the template structure is aligned on a 16-byte boundary.
• If this template is used within a SHARED8 or PLATFORM structure, the enclosing structures are
also aligned on 16-byte boundaries.
• If this template is used within a SHARED8 structure, the EpTAL compiler warns you that this
structure is not compatible with the same SHARED8 structure on the TNS/R architecture.
STRUCTALIGN (MAXALIGN) Attribute 137