Skip to content

Commit ad1bb4b

Browse files
luxukernelPaul Walmsley
authored andcommitted
riscv: Introduce Zalasr instructions
Introduce l{b|h|w|d}.{aq|aqrl} and s{b|h|w|d}.{rl|aqrl} instruction encodings. Signed-off-by: Xu Lu <luxu.kernel@bytedance.com> Reviewed-by: Guo Ren <guoren@kernel.org> Link: https://patch.msgid.link/20251020042056.30283-5-luxu.kernel@bytedance.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent f4922b6 commit ad1bb4b

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

arch/riscv/include/asm/insn-def.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
#define RV___RS1(v) __RV_REG(v)
180180
#define RV___RS2(v) __RV_REG(v)
181181

182+
#define RV_OPCODE_AMO RV_OPCODE(47)
182183
#define RV_OPCODE_MISC_MEM RV_OPCODE(15)
183184
#define RV_OPCODE_OP_IMM RV_OPCODE(19)
184185
#define RV_OPCODE_SYSTEM RV_OPCODE(115)
@@ -208,6 +209,84 @@
208209
__ASM_STR(.error "hlv.d requires 64-bit support")
209210
#endif
210211

212+
#define LB_AQ(dest, addr) \
213+
INSN_R(OPCODE_AMO, FUNC3(0), FUNC7(26), \
214+
RD(dest), RS1(addr), __RS2(0))
215+
216+
#define LB_AQRL(dest, addr) \
217+
INSN_R(OPCODE_AMO, FUNC3(0), FUNC7(27), \
218+
RD(dest), RS1(addr), __RS2(0))
219+
220+
#define LH_AQ(dest, addr) \
221+
INSN_R(OPCODE_AMO, FUNC3(1), FUNC7(26), \
222+
RD(dest), RS1(addr), __RS2(0))
223+
224+
#define LH_AQRL(dest, addr) \
225+
INSN_R(OPCODE_AMO, FUNC3(1), FUNC7(27), \
226+
RD(dest), RS1(addr), __RS2(0))
227+
228+
#define LW_AQ(dest, addr) \
229+
INSN_R(OPCODE_AMO, FUNC3(2), FUNC7(26), \
230+
RD(dest), RS1(addr), __RS2(0))
231+
232+
#define LW_AQRL(dest, addr) \
233+
INSN_R(OPCODE_AMO, FUNC3(2), FUNC7(27), \
234+
RD(dest), RS1(addr), __RS2(0))
235+
236+
#define SB_RL(src, addr) \
237+
INSN_R(OPCODE_AMO, FUNC3(0), FUNC7(29), \
238+
__RD(0), RS1(addr), RS2(src))
239+
240+
#define SB_AQRL(src, addr) \
241+
INSN_R(OPCODE_AMO, FUNC3(0), FUNC7(31), \
242+
__RD(0), RS1(addr), RS2(src))
243+
244+
#define SH_RL(src, addr) \
245+
INSN_R(OPCODE_AMO, FUNC3(1), FUNC7(29), \
246+
__RD(0), RS1(addr), RS2(src))
247+
248+
#define SH_AQRL(src, addr) \
249+
INSN_R(OPCODE_AMO, FUNC3(1), FUNC7(31), \
250+
__RD(0), RS1(addr), RS2(src))
251+
252+
#define SW_RL(src, addr) \
253+
INSN_R(OPCODE_AMO, FUNC3(2), FUNC7(29), \
254+
__RD(0), RS1(addr), RS2(src))
255+
256+
#define SW_AQRL(src, addr) \
257+
INSN_R(OPCODE_AMO, FUNC3(2), FUNC7(31), \
258+
__RD(0), RS1(addr), RS2(src))
259+
260+
#ifdef CONFIG_64BIT
261+
#define LD_AQ(dest, addr) \
262+
INSN_R(OPCODE_AMO, FUNC3(3), FUNC7(26), \
263+
RD(dest), RS1(addr), __RS2(0))
264+
265+
#define LD_AQRL(dest, addr) \
266+
INSN_R(OPCODE_AMO, FUNC3(3), FUNC7(27), \
267+
RD(dest), RS1(addr), __RS2(0))
268+
269+
#define SD_RL(src, addr) \
270+
INSN_R(OPCODE_AMO, FUNC3(3), FUNC7(29), \
271+
__RD(0), RS1(addr), RS2(src))
272+
273+
#define SD_AQRL(src, addr) \
274+
INSN_R(OPCODE_AMO, FUNC3(3), FUNC7(31), \
275+
__RD(0), RS1(addr), RS2(src))
276+
#else
277+
#define LD_AQ(dest, addr) \
278+
__ASM_STR(.error "ld.aq requires 64-bit support")
279+
280+
#define LD_AQRL(dest, addr) \
281+
__ASM_STR(.error "ld.aqrl requires 64-bit support")
282+
283+
#define SD_RL(dest, addr) \
284+
__ASM_STR(.error "sd.rl requires 64-bit support")
285+
286+
#define SD_AQRL(dest, addr) \
287+
__ASM_STR(.error "sd.aqrl requires 64-bit support")
288+
#endif
289+
211290
#define SINVAL_VMA(vaddr, asid) \
212291
INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(11), \
213292
__RD(0), RS1(vaddr), RS2(asid))

0 commit comments

Comments
 (0)