LDC

Memory

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
modekind
6362616059585756555453525150494847464544434241403938373635343332
bankoff
313029282726252423222120191817161514131211109876543210
rRdpred.notpred101110000010

bits 15:0: ---- 1011 1000 0010

Runs execute_LDC.

Fields

FieldBitsFrom
reuse125:122the decoder
wait121:116the decoder
rd_bar115:113the decoder
wr_bar112:110the decoder
yield109the decoder
stall108:105the decoder
mode79:78execute_LDC
kind75:73execute_LDC
bank58:54execute_LDC
off53:38execute_LDC
r31:24execute_LDC
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder

Operation Sail

LDC: a constant buffer's word (or byte, halfword, pair: NAK's MemType at 73), at the offset 38-53 plus the register at 24

let kind = UInt(Field(73, 3));
let bank = UInt(Field(54, 5));
let off = UInt(Field(38, 16));
let r = UInt(Field(24, 8));
let mode = UInt(Field(78, 2));
if (mode != 0 & mode != 2) | kind > 5 then throw(Unsupported("LDC of type %u, mode %u", kind, mode));
if r < RZ then {
    let index = R_read(r);
    if mode == 2 then {
        /* NAK's LdcMode::IndexedSegmented (.IS): the register holds the bank past the instruction's in its upper
           half and the byte offset in its lower half, as NAK packs them with PRMT for a bank known only at run
           time. A select over the banks from the instruction's on (an unbound one reads zeros). One game's vertex
           program that draws its frame into the window reads a record of bank 1 for each vertex,
           c[(VertexId << 5) + 0x10000 + 8] */
        let seg = index >> 16;
        let low = index & 0x0000ffff;
        foreach (w from 0 to (if kind == 5 then 1 else 0)) {
            var v : bits(32) = 0x00000000;
            foreach (b from bank to 17) {
                let here = if kind < 4 then CbufSubwordAt(b, off, low, kind) else CbufLoadAt(b, off + 4 * w, low);
                let is = seg == to_bits(32, b - bank);
                v = if is then here else v
            };
            if Dst() + w < RZ then R_write(Dst() + w, v)
        }
    } else {
        if HandleIndexed() then NoteHandleIndex(index, off);
        if kind < 4 then R_write(Dst(), CbufSubwordAt(bank, off, index, kind)) else {
            R_write(Dst(), CbufLoadAt(bank, off, index));
            if kind == 5 & Dst() < RZ then R_write(Dst() + 1, CbufLoadAt(bank, off + 4, index))
        }
    }
} else if kind < 4 then R_write(Dst(), CbufSubword(bank, off, kind)) else {
    R_write(Dst(), CbufLoad(bank, off));
    if kind == 5 & Dst() < RZ then R_write(Dst() + 1, CbufLoad(bank, off + 4))
}

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.