diff options
author | Frank Chang | 2021-05-05 18:06:14 +0200 |
---|---|---|
committer | Alistair Francis | 2021-06-08 01:59:45 +0200 |
commit | c24f0422fbc0924389c1345ee30d8f87730ae633 (patch) | |
tree | d1ccf4d28fb6467b959b0d80eb2a596e23bbe071 /target/riscv/bitmanip_helper.c | |
parent | target/riscv: rvb: generalized reverse (diff) | |
download | qemu-c24f0422fbc0924389c1345ee30d8f87730ae633.tar.gz qemu-c24f0422fbc0924389c1345ee30d8f87730ae633.tar.xz qemu-c24f0422fbc0924389c1345ee30d8f87730ae633.zip |
target/riscv: rvb: generalized or-combine
Signed-off-by: Frank Chang <frank.chang@sifive.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210505160620.15723-14-frank.chang@sifive.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'target/riscv/bitmanip_helper.c')
-rw-r--r-- | target/riscv/bitmanip_helper.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/target/riscv/bitmanip_helper.c b/target/riscv/bitmanip_helper.c index c625adaded..5b2f795d03 100644 --- a/target/riscv/bitmanip_helper.c +++ b/target/riscv/bitmanip_helper.c @@ -62,3 +62,29 @@ target_ulong HELPER(grevw)(target_ulong rs1, target_ulong rs2) { return do_grev(rs1, rs2, 32); } + +static target_ulong do_gorc(target_ulong rs1, + target_ulong rs2, + int bits) +{ + target_ulong x = rs1; + int i, shift; + + for (i = 0, shift = 1; shift < bits; i++, shift <<= 1) { + if (rs2 & shift) { + x |= do_swap(x, adjacent_masks[i], shift); + } + } + + return x; +} + +target_ulong HELPER(gorc)(target_ulong rs1, target_ulong rs2) +{ + return do_gorc(rs1, rs2, TARGET_LONG_BITS); +} + +target_ulong HELPER(gorcw)(target_ulong rs1, target_ulong rs2) +{ + return do_gorc(rs1, rs2, 32); +} |