F2I.64

Conversions

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
ssizexdsize[72]
6362616059585756555453525150494847464544434241403938373635343332
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform100010001

bits 15:0: ---- 0011 0001 0001
bits 15:0: ---- 1001 0001 0001
bits 15:0: ---- 1011 0001 0001
bits 15:0: ---- 1101 0001 0001

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

Fields

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

Operation Sail

F2I's fields (NAK), to a 64-bit integer: the register pair dst, dst + 1. One game's compute programs have F2I.U64.F32.TRUNC, the only form here: the hardware saturates, and a NaN gives 0

let dsize = UInt(Field(75, 2));
let ssize = UInt(Field(84, 2));
if dsize != 3 | ssize != 2 | Field(72, 1) != 0b0 then
    throw(Unsupported("F2I.64 of sizes %u, %u, signed %u", ssize, dsize, Field(72, 1)));
let x = FRound(UInt(Field(78, 2)), SrcF(B));
let nan = FIsNaN(x);
let high = FCompare(6, x, FConst(0x5f800000));
/* the largest float under 2^64 keeps the conversion in range where the result is not taken */
let clamped = FMinN(FMaxN(x, FConst(0x00000000)), FConst(0x5f7fffff));
let u = FToU64(clamped);
let v = if nan then 0x0000000000000000 else if high then 0xffffffffffffffff else u;
R_write(Dst(), v[31 .. 0]);
if Dst() < RZ then R_write(Dst() + 1, v[63 .. 32])

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.