XMAD

Integer, logic, video and predicate instructions

fixed bit field field the encoding fixes should be

XMAD (reg)

6362616059585756555453525150494847464544434241403938373635343332
0101101100
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 1011 00-- ----

Runs execute_XMAD with Form() 0.

XMAD (rc)

6362616059585756555453525150494847464544434241403938373635343332
010100010
313029282726252423222120191817161514131211109876543210
Rbpred.notpredRaRd

bits 63:48: 0101 0001 0--- ----

Runs execute_XMAD with Form() 1.

XMAD (cr)

6362616059585756555453525150494847464544434241403938373635343332
0100111cbuf.bankcbuf.offset
313029282726252423222120191817161514131211109876543210
cbuf.offsetpred.notpredRaRd

bits 63:48: 0100 111- ---- ----

Runs execute_XMAD with Form() 2.

XMAD (imm)

6362616059585756555453525150494847464544434241403938373635343332
0011011imm.sign00imm
313029282726252423222120191817161514131211109876543210
immpred.notpredRaRd

bits 63:48: 0011 011- 00-- ----

Runs execute_XMAD with Form() 3.

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
mrg56execute_XMAD
psl55execute_XMAD
extended54execute_XMAD
left53execute_XMAD
half_b52execute_XMAD
sel52:50execute_XMAD
sel51:50execute_XMAD
right49execute_XMAD
left48execute_XMAD
sum47execute_XMAD
source_b46:39execute_XMAD
extended38execute_XMAD
mrg37execute_XMAD
psl36execute_XMAD
[35:20]35:20execute_XMAD
half_b35execute_XMAD
Rb27:20RegB()
pred.not19the decoder
pred18:16the decoder
Ra15:8RegA()
Rd7:0Dst()

Operation Sail

XMAD: Each form's operands and fields, as Eden reads them: B is Rb (R), Rc at bit 39 (RC), a constant buffer word (CR) or a 16-bit immediate (I), and C is Rc or the constant buffer word. The product of A's and B's halves (signed by bits 48 and 49) is shifted up 16 by PSL; the select picks C, its low or high half, or adds B << 16 to it (CBCC); MRG puts B's low half in the result's high half. X adds the carry and CC writes the flags, as IADD's do (Eden refuses both)

let f = Form();
let narrow = f == 1 | f == 2;
let source_b = if f == 0 then R_read(RegB()) else if f == 1 then R_read(UInt(Field(39, 8)))
               else if f == 2 then CbufWord() else Bits32(ZeroExtend(Field(20, 16), 32));
let source_c = if f == 1 then CbufWord() else R_read(UInt(Field(39, 8)));
let sel = if narrow then UInt(Field(50, 2)) else UInt(Field(50, 3));
let half_b = if f == 0 then UInt(Field(35, 1)) else if narrow then UInt(Field(52, 1)) else 0;
let psl = if f == 2 then Field(55, 1) == 0b1 else if f == 1 then false else Field(36, 1) == 0b1;
let mrg = if f == 2 then Field(56, 1) == 0b1 else if f == 1 then false else Field(37, 1) == 0b1;
let extended = if narrow then UInt(Field(54, 1)) else UInt(Field(38, 1));
let sixteen = Bits32(0x00000010);
let left = XmadHalf(R_read(RegA()), UInt(Field(53, 1)), UInt(Field(48, 1)));
let right = XmadHalf(source_b, half_b, UInt(Field(49, 1)));
let product0 = left * right;
let product = if psl then product0 << sixteen else product0;
let third = if sel == 1 then XmadHalf(source_c, 0, 0) else if sel == 2 then XmadHalf(source_c, 1, 0)
            else if sel == 4 then (source_b << sixteen) + source_c else source_c;
let sum = IntegerAdd(product, third, 0, extended, UInt(Field(47, 1)));
R_write(Dst(), if mrg then (sum & 0x0000ffff) | ((source_b & 0x0000ffff) << sixteen) else sum)

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