aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/sshlr.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/sshlr.h')
-rw-r--r--riscv/insns/sshlr.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/riscv/insns/sshlr.h b/riscv/insns/sshlr.h
new file mode 100644
index 00000000..d36b0052
--- /dev/null
+++ b/riscv/insns/sshlr.h
@@ -0,0 +1,22 @@
+require_extension('P');
+require_rv32;
+sreg_t sshamt = P_FIELD(RS2, 0, 8);
+if (sshamt < 0) {
+ uint64_t shx;
+ if (sshamt < -32)
+ shx = 0;
+ else if (sshamt == -32)
+ shx = (RS1 >> 31) & 1;
+ else
+ shx = ((uint64_t)RS1 << 1) >> (-sshamt);
+ WRITE_RD((uint32_t)((shx + 1) >> 1));
+} else {
+ uint64_t shx = (sshamt >= 32) ? ((uint64_t)RS1 << 32) : ((uint64_t)RS1 << sshamt);
+ if (shx > 0xFFFFFFFFULL) {
+ P.VU.vxsat->write(1);
+ WRITE_RD(0xFFFFFFFF);
+ } else {
+ WRITE_RD((uint32_t)shx);
+ }
+}
+