User`s guide
MACRO Compiler Directives
.SET_REGISTERS
Description
The aligned and unaligned qualifiers to this directive allow you to override the
compiler’s alignment assumptions. Using the directive for this purpose in certain
cases can produce more efficient code. (See Section 4.1.)
The read and written qualifiers to this directive allow implicit reads and writes
of registers to be declared. They are generally used to declare the register usage
of called routines and are useful for documenting your program.
With one exception, the .SET_REGISTERS directive remains in effect (ensuring
proper alignment processing) until the routine ends, unless you change the value
in the register. The exception can occur under certain conditions when a flow
path joins the code following a .SET_REGISTERS directive.
The following example illustrates such an exception. R2 is declared aligned, and
at a subsequent label, 10$, which is before the next write access to the register,
a flow path joins the code. R2 will be treated as unaligned following the label,
because it is unaligned from the other path.
INCL R2 ; R2 is now unaligned
.
.
.
BLBC R0, 10$
.
.
.
MOVL R5, R2
.SET_REGISTERS ALIGNED=R2
MOVL R0, 4(R2)
10$: MOVL 4(R2), R3 ; R2 considered unaligned
; due to BLBC branch
The .SET_REGISTERS directive and its read and written qualifiers are required
on every routine call that passes or returns data in any register from R2 through
R12, if you specify the command line qualifier and option /OPTIMIZE=VAXREGS
(OpenVMS Alpha only). That is because the compiler allows the use of unused
VAX registers as temporary registers when you specify /OPTIMIZE=VAXREGS.
Examples
1.
DIVL R0,R1
.SET_REGISTERS ALIGNED=R1
MOVL 8(R1), R2 ; Compiler will use aligned load.
In this example, the compiler would normally consider R1 unaligned after
the division. Any memory references using R1 as a base register (until it
is changed again) would use unaligned load/stores. If it is known that the
actual value will always be aligned, performance could be improved by adding
a .SET_REGISTERS directive, as shown.
2.
MOV1 4(R0), R1 ;Stored memory addresses assumed
.SET_REGISTERS UNALIGNED=R1 ;aligned so explicitly set it un-
MOVL 4(R1), R2 ;aligned to avoid run-time fault.
In this example, R1 would be considered longword aligned after the MOVL. If
it is actually unaligned, an alignment fault would occur on memory reference
that follows at run time. To prevent this, the .SET_REGISTERS directive can
be used, as shown.
Specialized Directives B–19