SOP2M

Integer and 8-bit color instructions

fixed bit field field the encoding fixes should be

Encoding

6362616059585756555453525150494847464544434241403938373635343332
10010predmod1skipinvnoschedcopdest_extendsrc1_extsrc2_extmod2wmaskaopsel1sel2dest_bank
313029282726252423222120191817161514131211109876543210
src1_banksrc2_bankdest_nsrc1_nsrc2_n

bits 63:0: 1001 0xxx xxxx xxxx xxxx xxxx xxxx x-xx xxxx xxxx xxx- ---- --xx xxxx xxxx xxxx

Runs execute_SOP2M with Form() 0.

Fields

FieldBitsThe Sail reads it in
pred58:57
mod156Bit(56)
skipinv55
nosched54
cop53:52execute_SOP2M
dest_ext51Bit(51)
end50
src1_ext49Bit(49)
src2_ext48Bit(48)
mod247Bit(47)
wmask46:43execute_SOP2M
aop42:41execute_SOP2M
sel140:38execute_SOP2M
sel237:35execute_SOP2M
dest_bank33:32execute_SOP2M
src1_bank31:30execute_SOP2M
src2_bank29:28execute_SOP2M
dest_n27:21execute_SOP2M
src1_n13:7execute_SOP2M
src2_n6:0execute_SOP2M

Operation Sail

SOP2M: SOP2's operations on the components the write mask enables (its first bit the alpha), each source's factor one of 0, src1's component, src1's alpha, src2's component and src2's alpha (sel1 and sel2: 0, 2, 3, 6, 7)

let sel1 = UInt(Field(38, 3));
let sel2 = UInt(Field(35, 3));
if sel1 == 1 | sel1 == 4 | sel1 == 5 | sel2 == 1 | sel2 == 4 | sel2 == 5 then
    throw(Refuse("SOP2M selectors %u %u", sel1, sel2));
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);
SetType(SRC1, T_U8);
SetType(SRC2, T_U8);
SetType(DEST, T_U8);
Load(A, SRC1, 15, 0);
ToFloat(A, T_U8, 1);
Load(B, SRC2, 15, 0);
ToFloat(B, T_U8, 1);
if Failed() then throw(Stop());
let w = UInt(Field(43, 4));
let wmask = DIV(w, 2) + 8 * MOD(w, 2);
Reset(R, 0, K_FLOAT);
foreach (i from 0 to 3) {
    if MOD(DIV(wmask, 2 ^ i), 2) == 1 then {
        let zero = Zero();
        let a = At(A, i);
        let b = At(B, i);
        let x = FMul(Complement(match sel1 { 0 => zero, 2 => a, 3 => At(A, 3), 6 => b, _ => At(B, 3) }, Bit(56)), a);
        let y = FMul(Complement(match sel2 { 0 => zero, 2 => a, 3 => At(A, 3), 6 => b, _ => At(B, 3) }, Bit(47)), b);
        Push(R, SopApply(if i == 3 then UInt(Field(41, 2)) else UInt(Field(52, 2)), x, y))
    }
};
ToInt(R, T_U8, 1);
Store(DEST, R, wmask, 0)

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