isa/: sm_121 (GB10) encoding tables
sm121-forms.txt is generated by gen/run.sh: the Omega program gen/isa.om is compiled together with my Omega encoder gen/bw_enc_sm121.om (CUDApp b774723f, sha256 fe16b024c3242d12c7c8ef759d84c34a22c7d21cba676cd987f4f3a1ff56ba86) by the pinned omc (sha256 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194). Two runs give the same file, sha256 587d81e2bc8b3dc6fdb48d477a76b717300732ccdb984f05f5b3df658e58e2d7.
How the tables are derived
For every IR op 0..63 and every selector (which operands are present, uniform flag, guard predicate), the generator encodes one base instruction, then flips one input bit at a time: each bit of the destination and three source register numbers, the uniform register, the 32-bit immediate and the barrier register. It compares the 96 instruction bits of words 0..2. Word 3 is the scheduling control word and is kept whole.
- Bits that never move are the form's fixed bits: opcode, modifiers, and RZ (255) in absent register slots.
- Bits that move belong to an operand field.
- Identical forms are listed once. Op 255 is the NOP the encoder pads programs with.
Format
All numbers are decimal. Words are 32-bit, little-endian in memory; bit n of the 128-bit instruction is bit n mod 32 of word n / 32.
F id op sel fix0 fix1 fix2 msk0 msk1 msk2 ctl
D id field m0 m1 m2 start width
Fis one instruction form.opis the CUDApp BlackwellIR opcode number (the op list issrc/omega_blackwell_codegen.candom/encoder/bw_enc_sm121.omin CUDApp).fix0..2are the fixed bits,msk0..2mark the operand-field bits, andctlis the default control word.selbits: 0 destination, 1 source 1, 2 source 2, 3 source 3, 4 uniform register present; 5 uniform; 6 guard@P0; 7 guard negated.Dis one operand field of formid.field: 0 destination, 1 source 1, 2 source 2, 3 source 3, 4 uniform register, 5 immediate, 6 barrier register.m0..m2are its bit mask.startis the instruction bit that input bit 0 lands on.widthis how many input bits map one-to-one onto consecutive bits from there.width0 means the field is not a plain bit copy: for example a branch offset stored asimm - 1, a 24-bit signed offset, or a sign extension.
An instruction belongs to a form when its bits outside the form's mask equal the form's fixed bits.
Check
check/check.sh checks the table in two stages.
1. The D records are checked against the F records. For each form:
- its operand fields never overlap;
- the union of its field masks is exactly the form's mask;
- every field with
width> 0 covers exactly the bits fromstarttostart + width - 1.
The table has 859 D records: 845 have width > 0 and 14 have width 0.
2. The 70 kernels that ran on the GB10 (E2/E3) are rebuilt from this file alone. For each instruction, the check finds the first form that explains it, then writes three things: the form's fixed bits, the instruction's operand-field bits and its control word. All 70 rebuilt kernels match the sha256 list recorded on the chip run (kernels-om.sha256).
There are four negative controls, and each must fail:
- Flipping one fixed bit in the table makes 67 kernels differ.
- Flipping one opcode bit in a kernel makes that instruction match no form.
- Reducing one field's
widthby one fails stage 1. - Clearing one bit of one field's mask fails stage 1.
The output is in check/CHECK.txt.
What the check proves:
- Every bit of all 13,520 chip-run instructions is either a fixed bit of a listed form or inside one of that form's operand fields.
- The D records partition each form's operand bits exactly.
- Each linear field's
startandwidthmatch its mask.
What it does not prove: how the 14 width 0 fields transform their input, for example a branch offset or a sign extension. That transform lives in the encoder source (gen/bw_enc_sm121.om). Regenerating the table (gen/run.sh && git diff --exit-code isa/) shows that the whole file, D records included, is what the encoder produces.
Known limit
The encoder honours guard predicates only on BRA, EXIT, BAR and one store. So sel bits 6 and 7 change the encoding only for ops 22, 45, 46, 54 and 55. The tables reflect the encoder as it is; they do not add predicates it does not emit.