IMAD32I

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

IMAD32I

6362616059585756555453525150494847464544434241403938373635343332
100000
313029282726252423222120191817161514131211109876543210
pred.notpredRaRd

bits 63:48: 1000 00-- ---- ----

Runs execute_IMUL with Form() 8.

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
mode56:55execute_IMUL
mode52:51execute_IMUL
rhs051:20execute_IMUL
[49]49execute_IMUL
rhs046:39execute_IMUL
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

IMUL, IMUL32I, IMAD and IMAD32I: a * b, its high word with .HI (each operand signed or not), + c for IMAD; IMAD's mode negates b (2) or c (1), or adds one (3); .X adds the carry

let f = Form();
let imm32 = f == 3 | f == 8;
let mad = f >= 4;
let lhs = R_read(RegA());
let rhs0 = if imm32 then Bits32(Field(20, 32)) else if f == 5 then R_read(UInt(Field(39, 8)))
           else if f == 6 then CbufWord() else Right(if f == 0 | f == 4 then 0 else if f == 1 then 1 else 2);
var rhs : bits(32) = rhs0;
var addend : bits(32) = 0x00000000;
if mad then {
    addend = if f == 8 then R_read(Dst()) else if f == 5 then CbufWord() else R_read(UInt(Field(39, 8)));
    let mode = if imm32 then UInt(Field(55, 2)) else UInt(Field(51, 2));
    if mode == 2 then { rhs = 0x00000000 - rhs };
    if mode == 1 then { addend = 0x00000000 - addend };
    if mode == 3 then { addend = addend + 0x00000001 };
    if not_bool(imm32) & Field(49, 1) == 0b1 then { addend = addend + (if FlagRead(2) then 0x00000001 else 0x00000000) }
};
let high = Field(if imm32 then 53 else if mad then 54 else 39, 1) == 0b1;
let signed_lhs = UInt(Field(if imm32 then 54 else if mad then 48 else 40, 1));
let signed_rhs = UInt(Field(if imm32 then (if mad then 57 else 55) else if mad then 53 else 41, 1));
let product = if high then MulHigh(lhs, rhs, signed_lhs, signed_rhs) else lhs * rhs;
R_write(Dst(), if mad then product + addend else product)

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