amoswap.d
Atomic swap double word (64-bit)
Loads the double word at the address in the third register into the first and stores the second register there, atomically.
Forms
amoswap.d , , ()
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. t2- An integer register. It may be the same register as
t1. t3- An integer register. It may be the same register as
t1.
The exchange is indivisible, which makes this the natural way to implement a spinlock
This example runs on RV64.
# value is initialized and naturally aligned for this operation.
.data
value: .dword 0x0000000012345678
.text
la t0, value
# Atomic operation returns the old value 305419896 in t2, then changes value to 5.
li t1, 5
amoswap.d t2, t1, (t0)