IADD3

Integer

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
CarryIn(87)CarryIn(87)qpCarryIn(77)CarryIn(77)x
6362616059585756555453525150494847464544434241403938373635343332
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform000010000

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

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

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)
q86:84execute_IADD3
p83:81execute_IADD3
CarryIn(77)80CarryIn(77)
CarryIn(77)79:77CarryIn(77)
x74execute_IADD3
Ra31:24the decoder
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder
form11:9the decoder

Operation Sail

IADD3 and UIADD3: a + b + c, with the carries out in the predicates p (81) and q (84) and, for .X (74), two carries in (87 and 77)

let p = UInt(Field(81, 3));
let q = UInt(Field(84, 3));
let x = Field(74, 1) == 0b1;
if p >= PT & q >= PT & not_bool(x) then {
    /* the sum of the terms that aren't zero, a register's or an immediate's whatever the state */
    var sum : bits(32) = 0x00000000;
    var any : bool = false;
    if not_bool(IsZero(A)) then {
        sum = SrcInt(A);
        any = true
    };
    if not_bool(IsZero(B)) then {
        if any then { sum = sum + SrcInt(B) } else { sum = SrcInt(B) };
        any = true
    };
    if not_bool(IsZero(C)) then { if any then { sum = sum + SrcInt(C) } else { sum = SrcInt(C) } };
    D_write(sum)
} else {
    /* the sum in 64 bits: its carries, and .X's two carries in */
    var sum : bits(64) = Term64(A, x) + Term64(B, x);
    sum = sum + Term64(C, x);
    if x then {
        sum = sum + CarryIn(87);
        sum = sum + CarryIn(77)
    };
    let high = sum[63 .. 32];
    D_write(sum[31 .. 0]);
    PredWrite(p, 0 < UInt(high), Uniform());
    PredWrite(q, 1 < UInt(high), Uniform())
}

Fusion IADD3_WIDE Sail

function IADD3_WIDE_ok() -> bool = {
    let p = UInt(FieldAt(0, 81, 3));
    FieldAt(0, 74, 1) == 0b0 & p < PT & UInt(FieldAt(0, 84, 3)) == PT & IsZeroAt(0, C) & not_bool(SrcNegAt(0, C))
    & FieldAt(1, 74, 1) == 0b1 & UInt(FieldAt(1, 87, 3)) == p & FieldAt(1, 90, 1) == 0b0
    & FieldAt(1, 77, 4) == 0xf & UInt(FieldAt(1, 81, 3)) == PT & UInt(FieldAt(1, 84, 3)) == PT
    & IsZeroAt(1, C) & not_bool(SrcNegAt(1, C))
    & not_bool(SrcNegAt(0, A)) & not_bool(SrcNegAt(1, A)) & SrcNegAt(0, B) == SrcNegAt(1, B)
    & not_bool(ReadsDstAt(1, A, 0)) & not_bool(ReadsDstAt(1, B, 0))
}
function IADD3_WIDE() -> unit = {
    let a0 = SrcBitsAt(0, A);
    let b0 = SrcBitsAt(0, B);
    let a1 = SrcBitsAt(1, A);
    let b1 = SrcBitsAt(1, B);
    let sub = SrcNegAt(0, B);
    let lo = if sub then a0 - b0 else a0 + b0;
    /* the low word's carry: no borrow of a subtraction, a sum that wrapped */
    let carry = if sub then UInt(a0) >= UInt(b0) else UInt(lo) < UInt(a0);
    let hi = a1 + (if sub then not_vec(b1) else b1) + (if carry then 0x00000001 else 0x00000000);
    D_writeAt(0, lo);
    PredWrite(UInt(FieldAt(0, 81, 3)), carry, 0);
    D_writeAt(1, hi)
}

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.