pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-37
pTAL Code Generation for Structure References
In Example 11-19 on page 11-36:
pTAL generates fast code for a reference to s5.s6.J because s5.s6.j is at a
four-byte offset from s5, which is also well-aligned:
References to p6.j use conservative code because the specified alignment of s6
is SHARED2 and p6 uses default alignment—it does not specify a REFALIGNED
clause. If you add a REFALIGNED clause to p6, the compiler generates fast code:
INT .p6(s3_shared2) REFALIGNED(8);
References to p6.j and p6.l will not trap, but references to p6.m will trap. If you
specify REFALIGNED(2), pTAL generates conservative code if necessary;
otherwise, it generates optimal code.
STRUCT s5 FIELDALIGN(SHARED8);
BEGIN
INT i, k;
STRUCT s6(s3_shared2);
END;
INT .p6(s3_shared2);
Example 11-20. Combining SHARED2 and SHARED8 Structures
PROC p;
BEGIN
STRUCT s1 FIELDALIGN(SHARED8); ! OK
BEGIN
FIXED i;
END;
STRUCT s2 FIELDALIGN(SHARED2); ! OK
BEGIN
INT(32) i; ! OK
STRUCT sub (s1); ! WARNING: SHARED8 substructure in SHARED2
END; ! structure can cause significant loss of
! performance
STRUCT s3 (s1) = s2;
STRUCT s4 FIELDALIGN(SHARED8);
BEGIN
INT i;
STRUCT sub1 (s2); ! OK: SHARED2
STRUCT sub2 (s1) = sub1; ! WARNING: SHARED8 substructure
FILLER 2; ! redefines SHARED2 substructure
END; ! can cause significant loss of
END; ! performance
Example 11-19. Fast Code and Conservative Code (page 2 of 2)