mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-03-21 11:31:39 +00:00
lib: Use proper add opcode on RV32 with Zalrsc
The addw opcode is only defined in RV64, which produces 32-bit results.
On RV32, the default add opcode already produces 32-bit results.
Fixes: 995f226f3f ("lib: Emit lr and sc instructions based on -march flags")
Signed-off-by: Marti Alonso <martialonso11@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260301205421.2074835-1-martialonso11@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#define REG_L __REG_SEL(ld, lw)
|
||||
#define REG_S __REG_SEL(sd, sw)
|
||||
#define REG_ADDW __REG_SEL(addw, add)
|
||||
|
||||
.section .entry, "ax", %progbits
|
||||
.align 3
|
||||
@@ -35,7 +36,7 @@ _start:
|
||||
#elif defined(__riscv_zalrsc)
|
||||
_sc_fail:
|
||||
lr.w t0, (a3)
|
||||
addw t1, t0, a2
|
||||
REG_ADDW t1, t0, a2
|
||||
sc.w t1, t1, (a3)
|
||||
bnez t1, _sc_fail
|
||||
move a3, t0
|
||||
|
||||
Reference in New Issue
Block a user