Skip to contentSkip to conversation

riscv: insn: add RV_EXTRACT_FUNCT3()

PATCH New Ben Dooks 1 participant 1 message Oct 4, 2024 RISC-V

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 riscv: insn: add RV_EXTRACT_FUNCT3()

Add extraction for the func3 field of most instructions for use with anyone who needs it.

Note, added this for decoding of CSR accesses for work we did looking at the RDCYCLE v RDTIME calls.

---
 arch/riscv/include/asm/insn.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/riscv/include/asm/insn.h +4 -0
index 09fde95a5e8f..c67f44ff2066 100644
@@ -299,6 +299,10 @@ static __always_inline bool riscv_insn_is_c_jalr(u32 code)
 	({typeof(x) x_ = (x); \
 	(RV_X(x_, RVG_RD_OPOFF, RVG_RD_MASK)); })
 
+#define RV_EXTRACT_FUNCT3(x) \
+	({typeof(x) x_ = (x); \
+	(RV_X(x_, RV_INSN_FUNCT3_OPOFF, RV_INSN_FUNCT3_MASK)); })
+
 #define RV_EXTRACT_UTYPE_IMM(x) \
 	({typeof(x) x_ = (x); \
 	(RV_X(x_, RV_U_IMM_31_12_OPOFF, RV_U_IMM_31_12_MASK)); })
Signature · 7 lines
2.37.2.352.g3c44437643


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv