diff options
Diffstat (limited to 'riscv/insns/shlr.h')
| -rw-r--r-- | riscv/insns/shlr.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/riscv/insns/shlr.h b/riscv/insns/shlr.h new file mode 100644 index 00000000..29801fa9 --- /dev/null +++ b/riscv/insns/shlr.h @@ -0,0 +1,19 @@ +require_extension('P'); +require_rv64; +sreg_t sshamt = P_FIELD(RS2, 0, 8); +if (sshamt < 0) { + __uint128_t shx; + if (sshamt < -64) + shx = 0; + else if (sshamt == -64) + shx = (RS1 >> 63) & 1; + else + shx = ((__uint128_t)RS1 << 1) >> (-sshamt); + WRITE_RD((uint64_t)((shx + 1) >> 1)); +} else { + if (sshamt >= 64) + WRITE_RD(0); + else + WRITE_RD(RS1 << sshamt); +} + |
