diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-08-11 14:48:11 +0200 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2020-10-22 17:00:11 -0700 |
commit | 70d7081acb5be54ea7fa4c3f9ef9a6134a43519e (patch) | |
tree | 6bf1c33283d13b4b197047f225d45cd253ceaccf /riscv/insns/unshflw.h | |
parent | f1c24eff543e6f41980993f41ae1ab5ab80a7340 (diff) | |
download | spike-70d7081acb5be54ea7fa4c3f9ef9a6134a43519e.zip spike-70d7081acb5be54ea7fa4c3f9ef9a6134a43519e.tar.gz spike-70d7081acb5be54ea7fa4c3f9ef9a6134a43519e.tar.bz2 |
[riscv-bitmanip] Add bitmanip instructions
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'riscv/insns/unshflw.h')
-rw-r--r-- | riscv/insns/unshflw.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/riscv/insns/unshflw.h b/riscv/insns/unshflw.h new file mode 100644 index 0000000..de5ceb5 --- /dev/null +++ b/riscv/insns/unshflw.h @@ -0,0 +1,9 @@ +require_rv64; +require_extension('B'); +reg_t x = RS1; +int shamt = RS2 & 15; +if (shamt & 1) x = (x & 0x9999999999999999LL) | ((x & 0x4444444444444444LL) >> 1) | ((x & 0x2222222222222222LL) << 1); +if (shamt & 2) x = (x & 0xC3C3C3C3C3C3C3C3LL) | ((x & 0x3030303030303030LL) >> 2) | ((x & 0x0C0C0C0C0C0C0C0CLL) << 2); +if (shamt & 4) x = (x & 0xF00FF00FF00FF00FLL) | ((x & 0x0F000F000F000F00LL) >> 4) | ((x & 0x00F000F000F000F0LL) << 4); +if (shamt & 8) x = (x & 0xFF0000FFFF0000FFLL) | ((x & 0x00FF000000FF0000LL) >> 8) | ((x & 0x0000FF000000FF00LL) << 8); +WRITE_RD(sext32(x)); |