S2R

System registers, votes, shuffles and barriers

fixed bit field field the encoding fixes should be

S2R

6362616059585756555453525150494847464544434241403938373635343332
1111000011001
313029282726252423222120191817161514131211109876543210
srpred.notpredRd

bits 63:48: 1111 0000 1100 1---

Runs execute_S2R with Form() 0.

Fields

FieldBitsFrom
sr27:20execute_S2R
pred.not19the decoder
pred18:16the decoder
Rd7:0Dst()

Operation Sail

S2R: the system register at 20

let sr = UInt(Field(20, 8));
let stage = Stage();
let value : bits(32) =
    /* the thread ids, SR_TID.X to .Z (0x21-0x23), and the block's, SR_CTAID.X to .Z (0x25-0x27) */
    if stage == ST_CS & ((sr >= 33 & sr <= 35) | (sr >= 37 & sr <= 39)) then {
        let local = sr <= 35;
        VecAt(ComputeIds(local), if local then sr - 33 else sr - 37)
    } else if sr == 0 | (sr >= 56 & sr <= 60) then {
        /* SR_LANEID, and the EQ, LT, LE, GT and GE lane masks of a 32-lane warp */
        let lane = LaneId() & 0x0000001f;
        let eq = 0x00000001 << lane;
        let lt = eq - 0x00000001;
        let le = lt | eq;
        match sr { 0 => lane, 56 => eq, 57 => lt, 58 => le, 59 => not_vec(le), _ => not_vec(lt) }
    } else if stage == ST_CS & sr == 32 then {
        /* SR_TID packed: x in bits 0-15, y in 16-25 and z in 26-31, the widths of the largest block (Eden gives y
           8 bits) */
        let tid = ComputeIds(true);
        let x = VecAt(tid, 0);
        let xy = BitsInsert(x, VecAt(tid, 1), 0x00000010, 0x0000000a);
        BitsInsert(xy, VecAt(tid, 2), 0x0000001a, 0x00000006)
    } else if stage == ST_FS & sr == 19 then (if LaneDead() then 0xffffffff else 0x00000000) /* SR_THREAD_KILL */
    else if sr == 17 then InvocationId() /* SR_INVOCATION_ID */
    else if sr >= 80 & sr <= 83 then ClockAt(ReadClock(if sr < 82 then 3 else 1), MOD(sr, 2))
    else if sr == 29 & Between() then {
        /* SR_INVOCATION_INFO: the vertices of the input primitive in bits 16-23, with the primitive's index in the
           batch (bits 0-7) 0, which makes the index the program builds for ISBERD the vertex's. Citron,
           acfb1dcc1ad9adf25b960c4f8f25c5bf78849406: geometry's input topology is known when translating. Its
           invocation info is a constant; tessellation remains dynamic */
        if stage == ST_GS then to_bits(32, InVertices() * 65536) else PatchVertices() << 16
    }
    /* Direct CBE writes are disabled: their enable and address registers (0x15..0x17) are zero */
    else if sr == 18 then 0x3f800000
    else if sr == 29 & stage != ST_FS then 0x00ff0000
    else 0x00000000;
R_write(Dst(), value)

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