aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/sshar.h
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/insns/sshar.h')
-rw-r--r--riscv/insns/sshar.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/riscv/insns/sshar.h b/riscv/insns/sshar.h
new file mode 100644
index 00000000..2ebea187
--- /dev/null
+++ b/riscv/insns/sshar.h
@@ -0,0 +1,13 @@
+require_extension('P');
+require_rv32;
+sreg_t sshamt = P_FIELD(RS2, 0, 8);
+if (RS1 == 0)
+ WRITE_RD(0);
+else if (sshamt >= 32) {
+ WRITE_RD((RS1 & 0x80000000) ? 0x80000000 : 0x7fffffff);
+ P.VU.vxsat->write(1);
+}
+else if (sshamt <= -32)
+ WRITE_RD(0);
+else
+ WRITE_RD(sshamt >= 0 ? P_SAT(32, static_cast<sreg_t> (RS1) << sshamt) : ((RS1 >> -sshamt) + ((RS1 >> (-sshamt - 1)) & 1))); \ No newline at end of file