idx = b << 1 | a
return imm[idx] # idx by LSB0 order
-dorow(imm8, step_i, chunksize):
- for j in 0 to 63:
+dorow(imm8, step_i, chunksize, us32b):
+ for j in 0 to 31 if is32b else 63:
if (j&chunk_size) == 0
imm = imm8[0..3]
else
step_o[j] = lut2(imm, step_i[j], step_i[j ^ chunk_size])
return step_o
-uint64_t grevlut64(uint64_t RA, uint64_t RB, uint8 imm, bool iv)
+uint64_t grevlut(uint64_t RA, uint64_t RB, uint8 imm, bool iv, bool is32b)
{
uint64_t x = 0x5555_5555_5555_5555;
if (RA != 0) x = GPR(RA);
if (iv) x = ~x;
- int shamt = RB & 63;
- for i in 0 to 6
+ int shamt = RB & 31 if is32b else 63
+ for i in 0 to (6-is32b)
step = 1<<i
- if (shamt & step) x = dorow(imm, x, step)
+ if (shamt & step) x = dorow(imm, x, step, is32b)
return x;
}