I16MAD

Integer and 8-bit color instructions

fixed bit field field the encoding fixes should be

Encoding

6362616059585756555453525150494847464544434241403938373635343332
10100predabsskipinvnoschedsrc2_negsel1hdest_extendsrc1_extsrc2_extrepeat_countmodesrc2_formatsrc1_formatsel2hor_shiftsrc0_bankdest_bank
313029282726252423222120191817161514131211109876543210
src1_banksrc2_bankdest_nsrc0_nsrc1_nsrc2_n

bits 63:0: 1010 0xxx xxxx xxxx -xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx

Runs execute_I16MAD with Form() 0.

Fields

FieldBitsThe Sail reads it in
pred58:57
abs56
skipinv55
nosched54
src2_neg53
sel1h52Bit(52)
dest_ext51Bit(51)
end50
src1_ext49Bit(49)
src2_ext48Bit(48)
repeat_count46:44execute_I16MAD
mode43:42execute_I16MAD
src2_format41:40execute_I16MAD
src1_format39:38execute_I16MAD
sel2h37Bit(37)
or_shift36:35
src0_bank34Bit(34)
dest_bank33:32execute_I16MAD
src1_bank31:30execute_I16MAD
src2_bank29:28execute_I16MAD
dest_n27:21execute_I16MAD
src0_n20:14execute_I16MAD
src1_n13:7execute_I16MAD
src2_n6:0execute_I16MAD

Operation Sail

I16MAD: src0 * src1 + src2 of 16-bit integers (mode 2 and 3 signed), src1 and src2 a byte of theirs (the high one with sel1h, sel2h) where their format says. A repeat at a time

let signed = UInt(Field(42, 2)) >= 2;
let type = if signed then T_I16 else T_U16;
let bytes = if signed then T_I8 else T_U8;
Dest(DEST, UInt(Field(21, 7)), UInt(Field(32, 2)), Bit(51), 0, 7);
Src0(SRC0, UInt(Field(14, 7)), Bit(34), 0, 0, 7);
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);
SetType(DEST, type);
SetType(SRC0, type);
SetType(SRC1, type);
SetType(SRC2, type);
let f1 = UInt(Field(38, 2));
let f2 = UInt(Field(40, 2));
if f1 > 1 | f2 > 1 then throw(Refuse("I16MAD of sign-extended bytes"));
if f1 == 1 then SetType(SRC1, bytes);
if f2 == 1 then SetType(SRC2, bytes);
let m1 = if f1 == 1 & Bit(52) == 1 then 2 else 1;
let m2 = if f2 == 1 & Bit(37) == 1 then 2 else 1;
foreach (r from 0 to UInt(Field(44, 3))) {
    if not_bool(Failed()) then {
        Load(A, SRC0, 1, Rep(SRC0, r, O_SRC0, R_SLMSI));
        Load(B, SRC1, m1, Rep(SRC1, r, O_SRC1, R_SLMSI));
        Load(C, SRC2, m2, Rep(SRC2, r, O_SRC2, R_SLMSI));
        if not_bool(Failed()) then {
            Imad();
            Store(DEST, R, 1, Rep(DEST, r, O_DEST, R_SLMSI))
        }
    }
}

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