ALIGNED n FOR T
ALIGNED FOR can be used to specify a particular alignment
for a type (instead of the default alignment that a particular
compiler may give). However, no arbitrary alignment can be specified:
in particular, a type's alignment may only be boosted (and only when
the boosting does not introduce padding). We have also disabled
automatic alignment boosting in our compiler.
Analogous with BITS FOR, ALIGNED n FOR T is
a subtype of T.
Let d be the most restrictive alignment of T
(under the typical rules that one might expect). n must
be a multiple of d. In addition, n must not
be greater than then size of T; this prevents
ALIGNED FOR from being used to insert padding, which must
be inserted by hand.
Note: ALIGNED FOR works on RECORD and
ARRAY types. Given the above restrictions on the use of
ALIGNED FOR, I don't think it can be usefully used with
other types.
(* In the SRC M3 implementation, this record would be 32-bit aligned. Our compiler aligns it to 8 bits, and type T1 would be used if a 32-bit aligned record were desired. *) TYPE T = RECORD a: BITS 8 FOR [0..255]; b: BITS 8 FOR [0..255]; c: BITS 8 FOR [0..255]; d: BITS 8 FOR [0..255]; END; TYPE T1 = ALIGNED 32 FOR RECORD a: BITS 8 FOR [0..255]; b: BITS 8 FOR [0..255]; c: BITS 8 FOR [0..255]; d: BITS 8 FOR [0..255]; END;