lr.d

Load reserved (double word) RV64 only

Loads the double word at the address in the second register into the first and reserves that address for a following sc.d.

RISC-V manual: lr.d

Forms

  • lr.d , ()

Operands

t1
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
t2
An integer register. It may be the same register as t1.

Pair with sc.d to build an atomic read-modify-write that can be retried

This example runs on RV64.

# value is initialized and naturally aligned for this operation.
.data
value: .dword 0x0000000012345678
.text
la t0, value
# Reserve the aligned doubleword at value; t2 receives 305419896.
lr.d t2, (t0)