pTAL Reference Manual (H06.08+)
Structures
HP pTAL Reference Manual—523746-006
9-32
Code Generation for Structure References
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
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.
Do not use STRUCT(MAXALIGN) within a SHARED2 structure.
Note. Use this clause only with the EpTAL compiler. The pTAL compiler reports a syntax error.










