IndirectTarget

sm53_flow.sail

Relative CAL through cbuf counts bytes from the next instruction. Absolute JCAL/JMP/JMX count from the shader pool. FlowBase is the GPU address represented by the translator's word0, including compute's fake SPH. A target whose word is a scheduling word (its index 2 mod 4 past the header's ten) goes to the instruction after it

function IndirectTarget(cal : bool, jmx : bool) -> bits(32) = {
    let value0 = if Field(5, 1) == 0b1 then {
        let offset = ZeroExtend(Field(20, 16), 32);
        CbufReadDynamic(UInt(Field(36, 5)), if jmx then offset + R_read(RegA()) else offset)
    } else Field(20, 32);
    let value1 = if jmx then value0 + R_read(RegA()) else value0;
    let value = if cal then value1 + to_bits(32, (InsnIndex() + 1) * 8) else value1 - to_bits(32, FlowBase());
    let target = value >> 3;
    let schedule = (target & 0x00000003) == 0x00000002;
    target + (if schedule then 0x00000001 else 0x00000000)
}

Used by


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