HFMA2_32I

Floating point instructions

fixed bit field field the encoding fixes should be

HFMA2_32I

6362616059585756555453525150494847464544434241403938373635343332
0010100
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 0010 100- ---- ----

Runs execute_HARITH with Form() 12.

Fields

The operation reads some of these fields in some forms alone (it chooses by Form()), so the diagrams show only the decoder's.

FieldBitsFrom
[58:57]58:57execute_HARITH
[56:55]56:55execute_HARITH
neg_b56execute_HARITH
abs_b54execute_HARITH
swizzle_b54:53execute_HARITH
neg_c52execute_HARITH
[51:20]51:20execute_HARITH
neg_c51execute_HARITH
[50:49]50:49execute_HARITH
[46:39]46:39execute_HARITH
abs_a44execute_HARITH
neg_a43execute_HARITH
precision38:37execute_HARITH
swizzle_c36:35execute_HARITH
saturate32execute_HARITH
neg_b31execute_HARITH
abs_b30execute_HARITH
swizzle_b29:28execute_HARITH
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

the half instructions: HADD2, HMUL2, HFMA2 and their forms. Each form's operands and fields, as Eden's half_floating_point_*.cpp decode them. A constant buffer operand is one F32 for both halves (swizzle 1). The 32I forms write both halves (no merge), take A's swizzle at 53, and HFMA2_32I adds Rd. FTZ isn't modelled: the halves are computed as F32

let f = Form(); /* 0-3 HADD2 R, C, I, 32I; 4-7 HMUL2 R, C, I, 32I; 8-12 HFMA2 R, RC, CR, I, 32I */
let fma = f >= 8;
let multiply = f >= 4 & f <= 7;
let imm32 = f == 3 | f == 7 | f == 12;
let g = if f <= 7 then MOD(f, 4) else f; /* the HADD2 and HMUL2 forms alike */
let raw_b = if g == 0 | f == 8 then R_read(RegB()) else if g == 1 then CbufWord() else if g == 2 | f == 11 then HalfImmediate()
            else if g == 3 | f == 12 then Bits32(Field(20, 32)) else if f == 9 then R_read(UInt(Field(39, 8))) else CbufWord();
let swizzle_b = if g == 0 | f == 8 then UInt(Field(28, 2)) else if g == 1 then 1 else if f == 9 then UInt(Field(53, 2))
                else if f == 10 then 1 else 0;
let abs_b = if g == 0 & not_bool(fma) then UInt(Field(30, 1)) else if g == 1 & not_bool(fma) then UInt(Field(54, 1)) else 0;
let neg_b = if g == 0 & not_bool(fma) then UInt(Field(31, 1)) else if f == 1 then UInt(Field(56, 1))
            else if f == 8 then UInt(Field(31, 1)) else if f == 9 | f == 10 then UInt(Field(56, 1)) else 0;
let raw_c = if f == 8 then R_read(UInt(Field(39, 8))) else if f == 9 then CbufWord()
            else if f == 10 | f == 11 then R_read(UInt(Field(39, 8))) else if f == 12 then R_read(Dst()) else 0x00000000;
let swizzle_c = if f == 8 then UInt(Field(35, 2)) else if f == 9 then 1 else if f == 10 | f == 11 then UInt(Field(53, 2)) else 0;
let neg_c = if f == 8 then UInt(Field(30, 1)) else if f >= 9 & f <= 11 then UInt(Field(51, 1)) else if f == 12 then UInt(Field(52, 1)) else 0;
let saturate = if g == 0 & not_bool(fma) then UInt(Field(32, 1)) else if f == 8 then UInt(Field(32, 1))
               else if f == 12 then 0 else UInt(Field(52, 1));
let precision = if multiply then UInt(Field(if imm32 then 55 else 39, 2)) else if f == 8 then UInt(Field(37, 2))
                else if f >= 9 & f <= 11 then UInt(Field(57, 2)) else if f == 12 then UInt(Field(55, 2)) else 0;
let neg_a = if f == 3 then UInt(Field(56, 1)) else if not_bool(fma) & not_bool(imm32) then (if f == 4 then 0 else UInt(Field(43, 1))) else 0;
let abs_a = if not_bool(fma) & not_bool(imm32) & f != 3 then UInt(Field(44, 1)) else 0;
let lhs = HalfPairMod(HalfPairOf(R_read(RegA()), UInt(Field(if imm32 then 53 else 47, 2))), abs_a, neg_a);
let rhs = HalfPairMod(HalfPairOf(raw_b, swizzle_b), abs_b, neg_b);
let pair : half2 = if fma then {
    let addend = HalfPairMod(HalfPairOf(raw_c, swizzle_c), 0, neg_c);
    let p = Half2FmaNC(lhs, rhs, addend);
    if precision == 2 then HalfFmzFma(p, lhs, rhs, addend) else p
} else if multiply then {
    let p = Half2MulNC(lhs, rhs);
    if precision == 2 then HalfFmz(p, lhs, rhs) else p
} else Half2AddNC(lhs, rhs);
R_write(Dst(), HalfPairResult(pair, R_read(Dst()), if imm32 then 0 else UInt(Field(49, 2)), saturate))

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