Next | Prev | Up | Top | Contents | Index
Data Alignment Options
The last set of environment options are concerned with the alignment of data:
-align8 / -align16 / -align32 / -align64
The MIPS architectures perform memory references much more efficiently if the data referenced is naturally aligned, that is, if 4-byte objects are at 4-byte-aligned address, etc. By default, the compilers allocate well-aligned data, and that is a requirement of the ABI for C. However, code ported from other architectures without alignment constraints may require less restricted alignment.The ANSI Fortran standard essentially requires maximum alignment of 4 bytes (32 bits), although it is unusual for code to actually depend on this. These options specify a maximum alignment (in bits) to be forced in allocating data. The MIPSpro 64-bit compilers default to -align64 for MIPS3 or MIPS4 Fortran, and to ABI alignment (up to 128 bits for long double) for C.
-TENV:align_aggregates=n
The ABI specifies that aggregates (that is, structs and arrays) be aligned according to the strictest requirements of their components (that is, fields or elements). Thus, an array of short ints (or a struct containing only short ints or chars) is normally 2-byte aligned. However, some non-ANSI-conforming code may reference such objects assuming greater alignment, and some code (for example, struct assignments) may be more efficient if the objects are better aligned). This option specifies that any aggregate of size at least n is at least n-byte aligned. It does not affect the alignment of aggregates which are themselves components of larger aggregates.
-TENV:misalignment=n
This option determines the model (n) the compiler uses in deciding whether or not to assume that the memory references it generates are well-aligned. If n=1, it assumes well-aligned references unless it can determine otherwise (except in circumstances like struct copies where the ABI alignment requirements wouldn't normally imply alignment). If n=2, it always analyzes alignment based on the actual expression used, and trusts casts in the source code to reflect actual alignment. For instance, consider the expression:
*(type_a *) &b
The declared type of b implies a certain minimum alignment, as does the cast to type_a; the compiler uses the maximum of the two. If n=3, the compiler also analyzes alignment, but does not trust casts. In the above example, it assumes the alignment of the declared type of b.
The current default (for the beta release) is model 3. This is expected to change to model 1 or 2 for the full release.
Next | Prev | Up | Top | Contents | Index