User`s guide

How the MACRO Compiler Functions on Different Platforms
2.11 Preserving VAX Atomicity and Granularity
LDL R28,(R1)
Retry: LDL_L R24,(R28)
ADDL R24,#1,R24
STL_C R24,(R28)
BEQ fail
.
.
.
fail: BR Retry
Here, only the update of the modify data is atomic. The fetch required to obtain
the address of the modify data is not part of the atomic sequence.
On OpenVMS I64 systems, the code sequence would be similar to the following:
ld4 r16 = [r9]
sxt4 r16 = r16
$L5: ld4 r14 = [r16]
mov.m apccv = r14
mov r24 = r14
sxt4 r14 = r14
adds r14 = 1, r14
cmpxchg4.acq r14, [r16] = r14
cmp.eq pr0, pr8 = r24, r14
(pr8) br.cond.dpnt.few $L5
2.11.5 Alignment Considerations for Atomicity
When preserving atomicity, the compiler must assume the modify data is aligned.
An update of a field spanning a quadword boundary cannot occur atomically since
this would require two read-modify-write sequences.
On OpenVMS Alpha systems, since software cannot handle an unaligned LDx_L
or STx_C instruction as it can a normal load or store instruction, a LDx_L or
STx_C instruction to an unaligned address will generate a fatal reserved operand
fault.
On OpenVMS I64 systems, since software cannot handle an unaligned address in
the compare-exchange (cmpxchg) instruction, it will generate an exception at run
time.
On OpenVMS Alpha systems, when /PRESERVE=ATOMICITY (or .PRESERVE
ATOMICITY) is specified, an INCL (R1) instruction generates LDL_L and STL_C
instructions so R1 must be longword aligned.
Assume the following instruction:
INCW (R1)
For this instruction, the compiler generates a code sequence such as the following
on OpenVMS Alpha systems:
BIC R1,#^B0110,R28 ; Compute Aligned Address
Retry: LDQ_L R24,(R28) ; Load the QW with the data
EXTWL R24,R1,R23 ; Extract out the Word
ADDL R23,#1,R23 ; Increment the Word
INSWL R23,R1,R23 ; Correctly position the Word
MSKWL R24,R1,R24 ; Zero the spot for the Word
BIS R23,R24,R23 ; Combine Original and New word
STQ_C R23,(R28) ; Conditionally store result
BEQ fail ; Branch ahead on failure
.
.
2–28 How the MACRO Compiler Functions on Different Platforms