pTAL Reference Manual (H06.03+)

Structures
HP pTAL Reference Manual523746-005
9-29
Default Reference Alignment
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 9-25 on page 9-29, 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.
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.
Example 9-25. 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