aboutsummaryrefslogtreecommitdiff
path: root/target/tricore/op_helper.c
diff options
context:
space:
mode:
authorBastian Koppelmann <kbastian@mail.uni-paderborn.de>2023-06-14 12:00:37 +0200
committerBastian Koppelmann <kbastian@mail.uni-paderborn.de>2023-06-21 18:09:48 +0200
commit4e3377bb5abe8914eec0650730536d5d48e22008 (patch)
tree5d94ae4c13a34a65715d31742d8e96a58f12f9d0 /target/tricore/op_helper.c
parent0eaafe33d03447f36ff152010836d501ba68c710 (diff)
target/tricore: Add shuffle insn
this is based on code by volumit (https://github.com/volumit/qemu/). Reported in https://gitlab.com/qemu-project/qemu/-/issues/1667 and https://gitlab.com/qemu-project/qemu/-/issues/1452. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de> Message-Id: <20230614100039.1337971-7-kbastian@mail.uni-paderborn.de>
Diffstat (limited to 'target/tricore/op_helper.c')
-rw-r--r--target/tricore/op_helper.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c
index b6ef1462e4..026e15f3e0 100644
--- a/target/tricore/op_helper.c
+++ b/target/tricore/op_helper.c
@@ -2308,6 +2308,42 @@ uint32_t helper_crc32_le(uint32_t arg0, uint32_t arg1)
return crc32(arg1, buf, 4);
}
+uint32_t helper_shuffle(uint32_t arg0, uint32_t arg1)
+{
+ uint32_t resb;
+ uint32_t byte_select;
+ uint32_t res = 0;
+
+ byte_select = arg1 & 0x3;
+ resb = extract32(arg0, byte_select * 8, 8);
+ res |= resb << 0;
+
+ byte_select = (arg1 >> 2) & 0x3;
+ resb = extract32(arg0, byte_select * 8, 8);
+ res |= resb << 8;
+
+ byte_select = (arg1 >> 4) & 0x3;
+ resb = extract32(arg0, byte_select * 8, 8);
+ res |= resb << 16;
+
+ byte_select = (arg1 >> 6) & 0x3;
+ resb = extract32(arg0, byte_select * 8, 8);
+ res |= resb << 24;
+
+ if (arg1 & 0x100) {
+ /* Assign the correct nibble position. */
+ res = ((res & 0xf0f0f0f0) >> 4)
+ | ((res & 0x0f0f0f0f) << 4);
+ /* Assign the correct bit position. */
+ res = ((res & 0x88888888) >> 3)
+ | ((res & 0x44444444) >> 1)
+ | ((res & 0x22222222) << 1)
+ | ((res & 0x11111111) << 3);
+ }
+
+ return res;
+}
+
/* context save area (CSA) related helpers */
static int cdc_increment(target_ulong *psw)