Hmul2

sm86.sail

HMUL2 and HMNMX2: two halves multiplied, or the smaller or larger of each pair by the predicate at 87 (FMNMX's). The operands as HADD2's. HMUL2: bit 77 saturate, 76 and 80 the handling of zeros and denormals, which floats of 32 bits don't lose here

function Hmul2(min_max : bool) -> unit = {
    let swa = UInt(Field(74, 2));
    let swb = if SrcIsImm(Second) then 0 else UInt(Field(60, 2));
    if not_bool(min_max) & Field(78, 2) != 0b00 then throw(Unsupported("HMUL2 with mode 0x%x", Field(78, 2)));
    let va = HalfPair(A, swa, SrcAbs(A), SrcNeg(A), OpName());
    let vb = HalfPair(Second, swb, SrcAbs(Second), SrcNeg(Second), OpName());
    let r : half2 = if not_bool(min_max) then {
        let m = NoContract2(Half2Mul(va, vb));
        if Field(77, 1) == 0b1 then Half2Clamp01(m) else m
    } else {
        let min = PredRead(UInt(Field(87, 3)), UInt(Field(90, 1)), 0);
        let lo = Half2MinN(va, vb);
        let hi = Half2MaxN(va, vb);
        let l0 = if min then Half2At(lo, 0) else Half2At(hi, 0);
        let l1 = if min then Half2At(lo, 1) else Half2At(hi, 1);
        Half2(l0, l1)
    };
    D_write(PackHalf(r))
}

Used by


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 Mesa's NAK (sm70_encode.rs, MIT) and CuAssembler's sm_86 records.