VMNMX

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

VMNMX

6362616059585756555453525150494847464544434241403938373635343332
0011101maximumsaturatedsigned_formatmodevbbselaselthirdasel
313029282726252423222120191817161514131211109876543210
bselpred.notpredRaRd

bits 63:48: 0011 101- ---- ----

Runs execute_VMNMX with Form() 0.

Fields

FieldBitsFrom
maximum56execute_VMNMX
saturated55execute_VMNMX
signed_format54execute_VMNMX
mode53:51execute_VMNMX
vb50execute_VMNMX
bsel49execute_VMNMX
asel48execute_VMNMX
third46:39execute_VMNMX
asel38:36execute_VMNMX
[35:20]35:20execute_VMNMX
bsel30:28execute_VMNMX
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

VMNMX: the minimum (or with 56 the maximum) of a's and b's selects, each signed or not, saturated to the destination's format (54 signed, 55 saturate), then the secondary operation with c (51-53)

let asel = UInt(Field(36, 3)) + 8 * UInt(Field(48, 1));
let bsel = UInt(Field(28, 3)) + 8 * UInt(Field(49, 1));
let sa = DIV(asel, 8) == 1;
let sb = DIV(bsel, 8) == 1;
let maximum = Field(56, 1) == 0b1;
let va = VmSelect(R_read(RegA()), asel);
let vb = if Field(50, 1) == 0b1 then VmSelect(R_read(RegB()), bsel)
         else Bits32(if sb then SignExtend(Field(20, 16), 32) else ZeroExtend(Field(20, 16), 32));
let less = if sa == sb then (if sa then SGreater(vb, va) else UInt(va) < UInt(vb))
           else if sa then RawOr(Negative(va), UInt(va) < UInt(vb))
           else RawAnd(RawNot(Negative(vb)), UInt(va) < UInt(vb));
let picked = RawSelect(less, if maximum then vb else va, if maximum then va else vb);
let result_signed = if sa == sb then sa else not_bool(maximum);
let signed_format = Field(54, 1) == 0b1;
let saturated = if Field(55, 1) == 0b1 & signed_format & not_bool(result_signed) then {
    let cap = Bits32(0x7fffffff);
    let above = UInt(cap) < UInt(picked);
    RawSelect(above, cap, picked)
} else if Field(55, 1) == 0b1 & not_bool(signed_format) & result_signed then {
    let negative = Negative(picked);
    RawSelect(negative, 0x00000000, picked)
} else picked;
let third = R_read(UInt(Field(39, 8)));
let mode = UInt(Field(51, 3));
let result = if mode < 4 then BitsInsert(third, saturated, to_bits(32, if mode == 0 | mode == 3 then 16 else 0),
                                         to_bits(32, if mode == 2 | mode == 3 then 8 else 16))
             else if mode == 4 then saturated + third
             else if mode == 5 | mode == 6 then {
                 let cmp = if signed_format then SGreater(saturated, third) else UInt(third) < UInt(saturated);
                 RawSelect(cmp, if mode == 5 then third else saturated, if mode == 5 then saturated else third)
             } else saturated;
R_write(Dst(), result)

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 Eden's maxwell.inc (GPL-2.0-or-later).