IMAD

Integer

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
PredAt(87)PredAt(87)x
6362616059585756555453525150494847464544434241403938373635343332
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform000100100

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

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

Runs execute_IMAD.

Fields

FieldBitsFrom
reuse125:122the decoder
wait121:116the decoder
rd_bar115:113the decoder
wr_bar112:110the decoder
yield109the decoder
stall108:105the decoder
PredAt(87)90PredAt(87)
PredAt(87)89:87PredAt(87)
x74execute_IMAD
Ra31:24the decoder
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder
form11:9the decoder

Operation Sail

IMAD and UIMAD: a * b + c. .X (bit 74) adds the carry predicate at 87-90, as IADD3.X does, and as there a negated addend is then its complement, ~c: one game's 64-bit division negates a high word with IMAD.X RZ, RZ, ~c, P

let x = Field(74, 1) == 0b1;
/* a factor of zero (IMAD.MOV's RZ, RZ) leaves the addend; an addend of zero (IMAD.SHL's RZ) the product */
let zero = IsZero(A) | IsZero(B);
let product = if zero then 0x00000000 else SrcInt(A) * SrcInt(B);
var v : bits(32) = product;
if x | not_bool(IsZero(C)) then {
    let addend = if x & SrcNeg(C) then not_vec(SrcBits(C)) else SrcInt(C);
    if zero then { v = addend } else { v = v + addend }
};
if x then { v = v + (if PredAt(87) then 0x00000001 else 0x00000000) };
D_write(v)

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.