VBW

Integer and 8-bit color instructions

fixed bit field field the encoding fixes should be

Encoding

6362616059585756555453525150494847464544434241403938373635343332
01op_1predskipinvnoschedrepeat_selsyncstartdest_extendsrc1_extsrc2_extrepeat_countinvertrotexthop_2partialdest_bank
313029282726252423222120191817161514131211109876543210
src1_banksrc2_bankdest_nsrc2_selsrc1_nsrc2_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.

Fields

FieldBitsThe Sail reads it in
op_161:59execute_VBW
pred58:56
skipinv55
nosched54
repeat_sel53
syncstart52
dest_ext51Bit(51)
end50
src1_ext49Bit(49)
src2_ext48Bit(48)
repeat_count47:44execute_VBW
invert43Bit(43)
rot42:38execute_VBW
exth37:36execute_VBW
op_235Bit(35)
partial34Bit(34)
dest_bank33:32execute_VBW
src1_bank31:30execute_VBW
src2_bank29:28execute_VBW
dest_n27:21execute_VBW
src2_sel20:14execute_VBW
src1_n13:7execute_VBW
src2_n6:0execute_VBW

Operation Sail

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).