aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vrol_vx.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/vrol_vx.h')
-rw-r--r--riscv/insns/vrol_vx.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/riscv/insns/vrol_vx.h b/riscv/insns/vrol_vx.h
new file mode 100644
index 0000000..b0c89a2
--- /dev/null
+++ b/riscv/insns/vrol_vx.h
@@ -0,0 +1,18 @@
+// vrol.vx vd, vs2, rs1, vm
+
+#include "zvk_ext_macros.h"
+
+require_zvbb;
+
+// 'mask' selects the low log2(vsew) bits of the shift amount,
+// to limit the maximum shift to "vsew - 1" bits.
+const reg_t mask = P.VU.vsew - 1;
+
+// For .vx, the shift amount comes from rs1.
+const reg_t lshift = ((reg_t)RS1) & mask;
+const reg_t rshift = (-lshift) & mask;
+
+VI_V_ULOOP
+({
+ vd = (vs2 << lshift) | (vs2 >> rshift);
+})