pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Similarly, if the data type of a nonpointer field in a SHARED2 and SHARED8 structure is an address
type, its type must be SGBADDR, SGWADDR, EXTADDR, EXT32ADDR, EXT64ADDR, PROC32ADDR,
or PROC64ADDR.
NOTE: The address types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are
available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR
T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality”
(page 531).
Example 75 REFALIGNED Clause
STRUCT s FIELDALIGN(SHARED2);
BEGIN
INT i; ! OK: i is a simple variable
INT .j; ! ERROR: j's address type is WADDR
BADDR b; ! ERROR: b's data type is BADDR
END;
Default Reference Alignment
If you do not specify a REFALIGNED clause in a structure pointer declaration, the reference alignment
for the pointer is the alignment of the structure that the pointer references in its declaration. In
Example 76 (page 135), none of the pointers p1, p2, or p3 specifies an alignment. Their alignment,
therefore, is the field alignment of the structures s1, s2, and s3 that they reference.
Example 76 Default Reference Alignment
STRUCT s1 FIELDALIGN(SHARED2);
BEGIN
INT i;
INT(32) j;
END;
STRUCT s2 FIELDALIGN(SHARED8);
BEGIN
INT i;
FILLER 2;
INT(32) j;
END;
STRUCT s3 FIELDALIGN(AUTO);
BEGIN
INT i;
INT(32) j;
END;
INT .p1(s1); ! Reference alignment is 2
INT .p2(s2); ! Reference alignment is 8
INT .p3(s3); ! Reference alignment is 8
REFALIGNED(2)
When a structure pointer specifies REFALIGNED(2), the base of the structure might or might not
be well-aligned for RISC and Itanium access. When you reference the pointer in an expression,
pTAL generates conservative code that might not be as optimal as the code it generates when you
specify REFALIGNED(8).
When you use a structure pointer in an executable statement, the field to which the pointer refers
might not be well-aligned. For example, if you are accessing a structure whose address was passed
as a parameter to a procedure, you might not know whether the field is well-aligned. Although the
fields of the structure are well-aligned from the base of the structure, the base of the structure might
not be well-aligned in memory.
Similarly, if you reference a field in a structure that is stored at an arbitrary address on a heap,
you might not know in advance whether the fields in the structure are well aligned.
Reference Alignment With Structure Pointers 135