Integer and 8-bit color instructions
fixed bit field field the encoding fixes should be
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| 0 | 1 | op_1 | pred | skipinv | nosched | repeat_sel | syncstart | dest_ext | end | src1_ext | src2_ext | repeat_count | invert | rot | exth | op_2 | partial | dest_bank | |||||||||||||
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| src1_bank | src2_bank | dest_n | src2_sel | src1_n | src2_n | ||||||||||||||||||||||||||
bits 63:0: 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
It is in a group of patterns that may match the same word: the decoder tries them in this order, and the first that matches decodes it: VPCK, VTST, VTSTMSK, VBW.
Runs execute_VBW with Form() 0.
| Field | Bits | The Sail reads it in |
|---|---|---|
| op_1 | 61:59 | execute_VBW |
| pred | 58:56 | |
| skipinv | 55 | |
| nosched | 54 | |
| repeat_sel | 53 | |
| syncstart | 52 | |
| dest_ext | 51 | Bit(51) |
| end | 50 | |
| src1_ext | 49 | Bit(49) |
| src2_ext | 48 | Bit(48) |
| repeat_count | 47:44 | execute_VBW |
| invert | 43 | Bit(43) |
| rot | 42:38 | execute_VBW |
| exth | 37:36 | execute_VBW |
| op_2 | 35 | Bit(35) |
| partial | 34 | Bit(34) |
| dest_bank | 33:32 | execute_VBW |
| src1_bank | 31:30 | execute_VBW |
| src2_bank | 29:28 | execute_VBW |
| dest_n | 27:21 | execute_VBW |
| src2_sel | 20:14 | execute_VBW |
| src1_n | 13:7 | execute_VBW |
| src2_n | 6:0 | execute_VBW |
VBW: src1 and, or, xor src2, shifted left, right or arithmetically right by it (its low five bits), or rotated left by it; src2 rotated left by rot and inverted first, or the immediate (src2's number, src2_sel and exth) so, of 32 bits or (partial) of 16. A repeat at a time
let op1 = UInt(Field(59, 3));
let op2 = Bit(35);
if op1 < 2 | op1 > 5 then throw(Refuse("VBW operation %u", op1));
/* 0 and, 1 or, 2 xor, 3 shl, 4 rol, 5 shr, 6 asr */
let op = if op1 == 2 then op2 else if op1 == 3 then 2 else if op1 == 4 then 3 + op2 else 5 + op2;
Src12(SRC1, UInt(Field(7, 7)), UInt(Field(30, 2)), Bit(49), 0, 7);
Src12(SRC2, UInt(Field(0, 7)), UInt(Field(28, 2)), Bit(48), 0, 7);
Dest(DEST, UInt(Field(21, 7)), UInt(Field(32, 2)), Bit(51), 0, 7);
let partial = Bit(34) == 1;
let bits = if partial then 16 else 32;
let type = if partial then T_U16 else T_U32;
SetType(SRC1, type);
SetType(SRC2, type);
SetType(DEST, type);
let rot = UInt(Field(38, 5));
let invert = Bit(43) == 1;
Multiplier(1, 1, 1, 1);
foreach (r from 0 to UInt(Field(44, 4))) {
if not_bool(Failed()) then {
let b = if Bit(48) == 1 & BankOf(SRC2) == B_IMM then {
/* the immediate, rotated and inverted as encoded */
let v0 : bits(32) = ZeroExtend(Field(36, 2) @ Field(14, 7) @ Field(0, 7), 32);
let n = MOD(rot, bits);
let v1 = if n == 0 then v0 else if bits == 16 then
(LSL(v0, n) | LSR(v0 & 0x0000ffff, 16 - n)) & 0x0000ffff
else LSL(v0, n) | LSR(v0, 32 - n);
let v2 = if invert then not_vec(v1) else v1;
UConst(UInt(if bits == 16 then v2 & 0x0000ffff else v2))
} else {
Load(B, SRC2, 1, Rep(SRC2, r, O_SRC2, R_SLMSI));
let b0 = At(B, 0);
let b1 = if rot != 0 then RotateLeft(b0, UConst(rot), bits) else b0;
if invert then {
let b2 = not_vec(b1);
if bits == 16 then AndT(b2, UConst(65535)) else b2
} else b1
};
Load(A, SRC1, 1, Rep(SRC1, r, O_SRC1, R_SLMSI));
if not_bool(Failed()) then {
let a = At(A, 0);
let shift = AndT(b, UConst(31));
Reset(R, 1, K_UINT);
Put(R, 0, match op { 0 => AndT(a, b), 1 => OrT(a, b), 2 => XorT(a, b), 3 => ShlT(a, shift),
5 => ShrT(a, shift), 6 => AsrT(a, shift), _ => RotateLeft(a, b, bits) });
Store(DEST, R, 1, Rep(DEST, r, O_DEST, R_SLMSI))
}
}
};
ResetMultiplier()
Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Vita3K's usse_translator_entry.cpp (GPL-2.0-or-later).