Is LR.W just LW with a marker?
No. LR.W and LW both read a 32-bit word and sign-extend it into rd, but LR.W also creates a reservation set that a later SC.W uses for its conditional store.
Atomically load a 32-bit word and create a reservation for a later SC.W conditional store
LR.W atomically reads a 32-bit word from the address in rs1, sign-extends the loaded value to XLEN, writes rd, and creates a reservation set covering the accessed bytes. It does not write memory; a later SC.W uses the reservation to decide whether its conditional store succeeds. The aq/rl bits provide memory-ordering constraints only for the address domain accessed by the instruction.
Shows A-extension word atomic field decode, aq/rl ordering bits, memory read, and RMW state update.
A-extension word atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.
This animation shows ISA-visible atomic read-modify-write, compare-and-swap, LR/SC reservation state, and ordering bits, not any specific CPU cache-coherence implementation, pipeline, or timing.
LR.W is the first step in an LR/SC sequence: it reads the old 32-bit memory value and creates a reservation. The key idea is not an ordinary load, but “read old value + create reservation + let a later SC.W consume that reservation.”
Understand this scenario with real code like «lr.w.aq t0, (a0) # load word from *a0 with acquire ordering, set reservation».
No. LR.W and LW both read a 32-bit word and sign-extend it into rd, but LR.W also creates a reservation set that a later SC.W uses for its conditional store.
No. The reservation may be invalidated, and SC.W may fail; software should check the value written by SC.W to rd and retry the LR/SC sequence on failure.