F2I

Conversions

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
ssizexdsizeis_signed
6362616059585756555453525150494847464544434241403938373635343332
x
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform100000101

bits 15:0: ---- 0011 0000 0101
bits 15:0: ---- 1001 0000 0101
bits 15:0: ---- 1011 0000 0101
bits 15:0: ---- 1101 0000 0101

Forms

Form (bits 11:9)bc
1 (001)Rb at 32Rc at 64
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

Runs execute_F2I.

Fields

FieldBitsFrom
reuse125:122the decoder
wait121:116the decoder
rd_bar115:113the decoder
wr_bar112:110the decoder
yield109the decoder
stall108:105the decoder
ssize85:84execute_F2I
x79:78execute_F2I
dsize76:75execute_F2I
is_signed72execute_F2I
x60HalfOf
Ra31:24the decoder
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder
form11:9the decoder

Operation Sail

F2I: NAK's log2 of the destination's bytes at 75 and of the source's at 84, signed with 72, the rounding at 78. A half's source is the one bit 60 names, with b's modifiers, as MUFU.F16's. The hardware saturates, and a NaN gives 0; an 8- or 16-bit result saturates to its range, then fills the register sign or zero extended

let dsize = UInt(Field(75, 2));
let ssize = UInt(Field(84, 2));
if dsize == 3 | (ssize != 1 & ssize != 2) then throw(Unsupported("F2I of sizes %u, %u", ssize, dsize));
let from = if ssize == 1 then HalfOf(B) else SrcF(B);
let x = FRound(UInt(Field(78, 2)), from);
let is_signed = Field(72, 1) == 0b1;
let nan = FIsNaN(x);
let v : bits(32) = if dsize < 2 then {
    let lo = if dsize == 0 then (if is_signed then 0xc3000000 else 0x00000000)
             else (if is_signed then 0xc7000000 else 0x00000000);
    let hi = if dsize == 0 then (if is_signed then 0x42fe0000 else 0x437f0000)
             else (if is_signed then 0x46fffe00 else 0x477fff00);
    let clamped = FMinN(FMaxN(x, FConst(lo)), FConst(hi));
    if is_signed then Bits32(FToS32(clamped)) else FToU32(clamped)
} else if is_signed then {
    let high = FCompare(6, x, FConst(0x4f000000));
    let clamped = FMaxN(x, FConst(0xcf000000));
    let s = Bits32(FToS32(clamped));
    if high then 0x7fffffff else s
} else {
    let high = FCompare(6, x, FConst(0x4f800000));
    let clamped = FMaxN(x, FConst(0x00000000));
    let u = FToU32(clamped);
    if high then 0xffffffff else u
};
D_write(if nan then 0x00000000 else 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.