IMAD.HI

Integer

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
CarryIn(87)CarryIn(87)[83:81][74]is_signed
6362616059585756555453525150494847464544434241403938373635343332
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform000100111

bits 15:0: ---- 0010 0010 0111
bits 15:0: ---- 0100 0010 0111
bits 15:0: ---- 0110 0010 0111
bits 15:0: ---- 1000 0010 0111
bits 15:0: ---- 1010 0010 0111
bits 15:0: ---- 1100 0010 0111
bits 15:0: ---- 1110 0010 0111

Forms

Form (bits 11:9)bc
1 (001)Rb at 32Rc at 64
2 (010)Rb at 64immediate at 32
3 (011)Rb at 64constant buffer: offset at 38, bank at 54
4 (100)immediate at 32Rc at 64
5 (101)constant buffer: offset at 38, bank at 54Rc at 64
6 (110)URb at 32Rc at 64
7 (111)Rb at 64URc at 32

IMAD.HI (0x027): CuAssembler sm_86 (0x827 its immediate form)

Runs execute_IMAD_HI.

Fields

FieldBitsFrom
reuse125:122the decoder
wait121:116the decoder
rd_bar115:113the decoder
wr_bar112:110the decoder
yield109the decoder
stall108:105the decoder
CarryIn(87)90CarryIn(87)
CarryIn(87)89:87CarryIn(87)
[83:81]83:81execute_IMAD_HI
[74]74execute_IMAD_HI
is_signed73execute_IMAD_HI
Ra31:24the decoder
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder
form11:9the decoder

Operation Sail

IMAD.HI: the high word of a * b + c (bit 73 signed): the addend goes into the 64-bit product, below the word that is kept, and with .X the carry predicate at 87-90 with it; the carry out of the 64 bits goes to the predicate at 81-83. One game's 64-bit division is written that way (IMAD.HI R8, R7, R11, R8 adds the middle column's low word and hands its carry to P1): with the addend added to the high word instead, 4239360 / 20480 came out 728513, and with this 207 (tools/div_model.py)

let is_signed = Field(73, 1) == 0b1;
Int64();
let a32 = SrcInt(A);
let b32 = SrcInt(B);
let product = if is_signed then SignExtend(a32, 64) * SignExtend(b32, 64) else ZeroExtend(a32, 64) * ZeroExtend(b32, 64);
let c32 = SrcInt(C);
let addend = if is_signed then SignExtend(c32, 64) else ZeroExtend(c32, 64);
var sum : bits(64) = product + addend;
var carry : bool = UInt(sum) < UInt(product);
if Field(74, 1) == 0b1 then {
    let more = sum + CarryIn(87);
    carry = (if carry then true else UInt(more) < UInt(sum));
    sum = more
};
PredWrite(UInt(Field(81, 3)), carry, Uniform()); /* signed too: its 64 bits' carry, as IMAD.WIDE's */
D_write(sum[63 .. 32])

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.