[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] target/tricore: Add shuffle insn
From: |
Richard Henderson |
Subject: |
Re: [PATCH 6/6] target/tricore: Add shuffle insn |
Date: |
Sat, 10 Jun 2023 08:41:00 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
On 6/10/23 03:55, Bastian Koppelmann wrote:
+/*
+ * table from
+ * https://graphics.stanford.edu/~seander/bithacks.html#BitReverseTable
+ */
+static const unsigned char BitReverseTable256[256] = {
+# define R2(n) n, n + 2 * 64, n + 1 * 64, n + 3 * 64
+# define R4(n) R2(n), R2(n + 2 * 16), R2(n + 1 * 16), R2(n + 3 * 16)
+# define R6(n) R4(n), R4(n + 2 * 4 ), R4(n + 1 * 4 ), R4(n + 3 * 4 )
+ R6(0), R6(2), R6(1), R6(3)
+};
This is revbit8() from qemu/host-utils.h.
+uint32_t helper_shuffle(uint32_t arg0, uint32_t arg1)
+{
+ uint8_t buf[4];
+ uint8_t resbuf[4];
+ uint32_t byte_select;
+ uint32_t res = 0;
+
+ stl_le_p(buf, arg0);
While storing to a buffer works, it's just as easy to use shifts.
+ byte_select = arg1 & 0x3;
+ resbuf[0] = buf[byte_select];
resb = extract32(arg0, byte_select * 8, 8);
res |= resb << 0;
+ resbuf[1] = buf[byte_select];
res |= resb << 8;
etc.
+ if (arg1 & 0x100) {
+ resbuf[3] = BitReverseTable256[resbuf[3]];
+ }
The bit-reversal is controlled by one bit for all bytes. It can be done for all bytes in
parallel. Use the shifts from bitrev8, applied to the entire uint32_t result.
r~
- Re: [PATCH 1/6] target/tricore: Introduce ISA 1.6.2 feature, (continued)
- [PATCH 2/6] target/tricore: Add popcnt.w insn, Bastian Koppelmann, 2023/06/10
- [PATCH 3/6] target/tricore: Add LHA insn, Bastian Koppelmann, 2023/06/10
- [PATCH 4/6] target/tricore: Add crc32l.w insn, Bastian Koppelmann, 2023/06/10
- [PATCH 5/6] target/tricore: Add crc32.b insn, Bastian Koppelmann, 2023/06/10
- [PATCH 6/6] target/tricore: Add shuffle insn, Bastian Koppelmann, 2023/06/10
- Re: [PATCH 6/6] target/tricore: Add shuffle insn,
Richard Henderson <=