interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

GitHub aien-dev/omega-mv#1044 (code only)

open derived a5a2bf82d3c18fb6 #1044

Imported from GitHub aien-dev/omega-mv#1044 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base e31919e250f7316a1b8cd04fe582d4e7e0bfc00d · Head e70ccc1fd721c263965585a14b4dcd9ce4a6fbca

Fetch it

A git bundle of the pull request's head, 384220 bytes.

curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/a5a2bf82d3c18fb6.bundle -o a5a2bf82d3c18fb6.bundle
git fetch a5a2bf82d3c18fb6.bundle refs/pull/1044/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-mv
1044
e70ccc1fd721c263965585a14b4dcd9ce4a6fbca
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":1044,"url":"https://github.com/aien-dev/omega-mv/pull/1044","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:19Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index a64341035..caa19f8d7 100644
--- a/.crumb
+++ b/.crumb
@@ -47,8 +47,8 @@
           "purpose": "Directory calibration. Purpose not yet described by a human."
         },
         {
-          "digest": "77451010e776ede2eebf5fe290a99194087cb6481dc91d7f77f209c64290bf72",
-          "last_commit": "142927bd",
+          "digest": "ab79fdb4699ce5ef0ed86ce7b6970b9c7eb930d2ff9452ec8401875cf2f9e052",
+          "last_commit": "0f8672b0",
           "name": "docs",
           "purpose": "Directory docs. Purpose not yet described by a human."
         },
@@ -59,8 +59,8 @@
           "purpose": "Directory doctrine. Purpose not yet described by a human."
         },
         {
-          "digest": "05e0ace7d9815f4dbabd702e0e19ad91ba28547ae5921185c5674c5a849688ad",
-          "last_commit": "39bd3e74",
+          "digest": "09b60f5a70db4f233d36ed1d379e5508d7c04a3ec73b8c014aacb12205b66b31",
+          "last_commit": "0fba6f3f",
           "name": "mk",
           "purpose": "Directory mk. Purpose not yet described by a human."
         },
@@ -83,39 +83,39 @@
           "purpose": "Directory research. Purpose not yet described by a human."
         },
         {
-          "digest": "d5b7b83e378358c3c2a3b4d9d2ce548eecbe6363e12f66bdef8e63d5e18ae6f0",
-          "last_commit": "2cd0947d",
+          "digest": "1d7a2adda2531165ab7dee8a7c344797b0ffbecf3a72fc1b77f2a340e46b86b9",
+          "last_commit": "0fba6f3f",
           "name": "spec",
           "purpose": "Directory spec. Purpose not yet described by a human."
         },
         {
-          "digest": "2fae6036e44241fc1dcf0b4861f5eeba18bbc8c5ddf90ce8167040235d2a2f54",
-          "last_commit": "e59a0060",
+          "digest": "389a6e17ea437fc7ff5ece40717562ddffa5459fb23ec3cdce511538138d6514",
+          "last_commit": "e5d43fd3",
           "name": "src",
           "purpose": "Directory src. Purpose not yet described by a human."
         },
         {
-          "digest": "766fef061465d7e8d964fed85a17337d81269feb87c6129f856b5b3ca0a74886",
-          "last_commit": "69739337",
+          "digest": "6665168341d3ae16545af9580629f21a2f1516916c1831d18b18f59cb6a8c7ed",
+          "last_commit": "e5d43fd3",
           "name": "tests",
           "purpose": "Directory tests. Purpose not yet described by a human."
         },
         {
-          "digest": "57880d84f591e959a8995c41aa5e9bac5ef6c01e7f424810c949d2059a539840",
-          "last_commit": "3613805b",
+          "digest": "4fc782173822d8f425f33022d3e1994f04965f4e5467644944958345e7e05e5c",
+          "last_commit": "1cdee5c2",
           "name": "tools",
           "purpose": "Directory tools. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:3464d16e8ad85fc733a04fba862af5b9cb033ed4d7d4384b116a3c99c1df6b5e",
-      "compiled_at": "2026-11-06T13:51:14Z",
+      "children_root": "sha256:b10cda83c211bc87ddec09b44ff6cb7a821c61c5d399d7aaed6252308c77bc6b",
+      "compiled_at": "2026-11-06T13:52:41Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:401fc703b2505ed6459d85ec7d9fcf5045f419fc24303ff34dca9d726c97f63e",
-      "evidence_files": 15677,
-      "evidence_root": "sha256:4180466f2220a84c82e8437c32eae01ba0e63d2c8ad87168aa29a1f161776274",
-      "files": 24200,
-      "generated_at_commit": "142927bd45f630a6e2b9c7b8ae7db5eecf4e00a2",
-      "source_tree": "sha256:c39219e5fa67137d879fb480f62d4195263ae7b0e456de48489c726f9fc048a0"
+      "digest": "sha256:8a20c408703438889ea2b0b4df43b57f8d4f9c716b4a38a5a7c6e6c5f7e0ed4f",
+      "evidence_files": 15695,
+      "evidence_root": "sha256:5bb2eb733f2dc6ea9ff1b8d7ac811a01e9cd8627739be6b4dda35a4d1ed7a424",
+      "files": 24307,
+      "generated_at_commit": "0f8672b01de282cf90a800638b7b4fb430fa3832",
+      "source_tree": "sha256:dc1b2fa778ae7bb0d4df0631d6f6836190afbd27fe8655d380bc26d950d8f4af"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/README.md b/README.md
index 24701073e..1a966daeb 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ Research-grade, with a staged Alpha qualification programme in progress. An Alph
 - **Decode attention (OWN-30B):** one cache holds up to 131072 positions (128k context, `OMEGA_GPU_DATTN_MAX_POS`). On the GB10 chip, contexts 65536, 100000 and 131072 match the double reference exactly (`evidence/dattn-maxpos-128k-20261018/`); at those lengths the kernel streams K/V at about 57 GB/s, so long contexts are slower than the weights alone allow.
 - **Qwen3.8-27B kernels (GB10, 2026-10-18):** each one is checked on the chip against a double-precision reference with deliberately broken variants that must fail, and none is joined into a serving engine yet. FP8 matrix-vector and the tensor-core prefill GEMM now take k up to 32768, which covers the 27B down projection at k = 17408 (`evidence/fp8-k32768-20261018/`, omega#541). The Gated DeltaNet decode step (the recurrent layer used by 48 of the 64 layers) runs as one launch per layer and matches the reference to about 2e-7; it takes 125.7 us per layer, which moves its 6.29 MB of state at 50.1 GB/s against 273 GB/s nominal (`evidence/gdn-decode-20261018/`, omega#542). The DeltaNet prefill reads a whole prompt in three launches per layer and hands its state to the decode step, which carries on exactly; at 2048 tokens it takes 3.80 us per token per layer, and the recurrent scan in it does about 2.4 trillion operations a second, against a chip peak for that kind of math that has not been measured yet (`evidence/gdn-prefill-20261018/`, omega#543). The full-attention decode step for the other 16 layers (24 query heads over 4 key-value heads, 256 numbers per head, rotation on the first 64 only, done by reordering the numbers once at load) runs as one launch per layer, matches the reference at each tested context (1, 7, 256, 301, 1024, 4096, 8192, 32768 and 131072 tokens) with all five broken variants caught, and at 32768 tokens of context takes 2.10 ms per layer, streaming its 134 MB of cached keys and values at 63.8 GB/s against 273 GB/s nominal (`evidence/QWEN38-DATTN256-8bb4494e-20261018/`, omega#544). The prefill attention for those 16 layers reads a 2048-token chunk of a prompt in two launches per layer and leaves cache rows bit-equal to the ones the decode step would have written; it matches the reference at every tested point up to 129024 + 2048 tokens with all four broken variants caught, and a 2048-token chunk takes 10.0 ms per layer at the start of a prompt and 591 ms at the end of a 128k one, streaming cached keys and values at 230.6 GB/s against 273 GB/s nominal (`evidence/pattn256-chip-20261018T1517Z/`, omega#545). Getting it to run found a bug every kernel shared: the encoder wrote the integer add, one compare and the exit instruction with a fixed timing word, so the waits the code generator scheduled on them never reached the chip. The encoder now keeps them, `make test-bw-encode-control` checks every instruction type, and 18 of 19 kernel families pass their chip tests with the fix (the ternary family fails only its speed gates, which the old encoder fails the same way on the same load; `evidence/encoder-fix-sweep-20261018T1512Z/`).
 - **Expert slots (Expert Ribbon, omega#533):** `src/omega_gpu_fp8_slots.h` keeps a fixed pool of FP8 expert slots that can be refilled while a model runs. A slot is hidden while it is rewritten, gets a new version only after the copy is complete, and cannot be rewritten while any launch or recorded command list still reads it. Shown on the GB10 at the slot commits a8ae3a1f and d8185686 on their 2026-10-18 bases (`tools/run_gpu_fp8_slots_chip.sh`, receipts in `evidence/RIBBON-SLOTS-*`; not re-run on the current base): a slot gives bit-identical results to the same expert held resident, and the negative control (pins ignored) is caught. The SSD side and the model wiring live in aien-sovereign-core.
+- **Omegese GPU kernels (C1, current-main restoration draft [#1044](https://github.com/aien-dev/omega-mv/pull/1044), not on `main`):** `docs/omegese/GPU.md` describes the Omegese kernel language, canonical IR8 and checker2 path for vector add, tiled GEMM and decode attention. `seed/oscgpu/` contains the seeded Omega decoder/checker/lowering ports; `make test-om-ports` compares them with the explicit C migration oracles and exercises named refusals and mutants. The C frontend/production entry points remain migration dependencies. CUDApp owns the successor encoder, cubin packaging and GPU execution. Historical #885/#886 chip and test-server golden-token receipts remain context only: this restored revision's chip and live-35B replacement tiers are **NOT_RUN**. The owner-receipt gate still needs Drake's YubiKey re-sign; it is not weakened or silently resigned.
 - **Hardware:** results on the DGX Spark GB10 are tied to the exact commit in each receipt. Host and emulator passes are never reported as hardware qualification.
 
 The live status is owned by [aien-architecture-mv](https://github.com/aien-dev/aien-architecture-mv): [CURRENT_EXECUTION_PLAN.md](https://github.com/aien-dev/aien-architecture-mv/blob/main/CURRENT_EXECUTION_PLAN.md) and [doctrine/ROADMAP.md](https://github.com/aien-dev/aien-architecture-mv/blob/main/doctrine/ROADMAP.md). This file does not restate numbers that drift. Historical milestone receipts (for example Milestone 4, `OMEGA_SEMANTICS`, 12 of 12 gates) stay in `evidence/` unchanged as history.
diff --git a/docs/.crumb b/docs/.crumb
index cc64db137..dd7c71cb3 100644
--- a/docs/.crumb
+++ b/docs/.crumb
@@ -124,14 +124,14 @@
         }
       ],
       "children_root": "sha256:d25011adea349d458cc24cb696a242a665e67fc241f3942fbb88af6897e08b6b",
-      "compiled_at": "2026-11-06T13:23:19Z",
+      "compiled_at": "2026-11-06T13:24:19Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:77451010e776ede2eebf5fe290a99194087cb6481dc91d7f77f209c64290bf72",
+      "digest": "sha256:ab79fdb4699ce5ef0ed86ce7b6970b9c7eb930d2ff9452ec8401875cf2f9e052",
       "evidence_files": 34,
       "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc",
-      "files": 149,
-      "generated_at_commit": "e59a0060dd8dd247387ff1bf2da6e4c96ce8c468",
-      "source_tree": "sha256:8c1a0699f5d061eea275fef262d7730ee0c3375c530c29ca9f4da57b4f4c707a"
+      "files": 150,
+      "generated_at_commit": "e5d43fd34fa4696b08ec2082066f96a0c8de96d8",
+      "source_tree": "sha256:f8a08b8609e438c6bfd2e02d0f65f4d12f660ab95b79eb9406a924302d9e981f"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/docs/omegese/GPU.md b/docs/omegese/GPU.md
new file mode 100644
index 000000000..0861668b2
--- /dev/null
+++ b/docs/omegese/GPU.md
@@ -0,0 +1,446 @@
+# Omegese on the GPU: kernels
+
+Status: design v2 (2026-10-21, L386), after review 1 (section 14). Bar row C1 in `docs/OMEGA.md`.
+Tool: `tools/omegese/omegese.c`; IR: `src/compiler/osc_ir.h` (encoding version 8); checker:
+`src/checker2/`; backend: `src/omega_osc_gpu.c` over the sm_121 kernel builder
+(`src/omega_blackwell_codegen.h`), launcher: `src/omega_osc_launch.c`. No second encoder.
+Tests: `make test-osc-gpu` (host simulator), `make test-osc-gpu-chip` (the GB10).
+
+Current-main restoration (2026-11-06): this draft integrates the historical
+`c1/chip-fix` implementation onto main `9a9263208650e0c5830807cde6e4691b6a49042e`.
+Old receipts below are historical context, not qualification of this revision.
+Run `make test-om-ports` for the seeded Omega decoder, checker and lowering
+against their explicit C migration oracles. The compiler artifact pin for these
+tests is SHA-256 `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194`,
+not the older compiler used by the original receipts. Trust/owner-signature gates
+are unchanged; a new checker is not silently trusted.
+
+The current encoder preserves training opcodes 60..63 and appends the kernel
+unsigned conversions at 64/65. Generic instruction guard encoding is shared
+with CUDApp's successor. Host MUFU references independently model the current
+simulator's input/output flush-to-zero behavior without relaxing bit equality.
+A single constant index outside a fixed shared-array length is refused as
+`C2-GPU-BOUNDS`; dynamic buffer indices retain trap 3 guards. This is not a
+complete static bounds proof. Host calls into kernels are refused as
+`CALL-KERNEL` before copying into the six-slot host call argument array.
+
+Minimal edge examples are `tests/osc_gpu/shared-bounds-edge.omegese` (index 31
+in a shared array of length 32) and
+`tests/osc_gpu/omegese/bad/shared_oob.omegese` (index 32 in that same length).
+WolframLanguageEvaluator: `{0 <= 31 < 32, 0 <= 32 < 32}` -> `{True, False}`.
+The `shared-bounds` checker mutant removes only this check; the bounds gate
+must detect that the refused example becomes accepted.
+
+## 1. What this adds
+
+Omegese could only write host functions (AArch64). This adds one more function form, the
+kernel. A kernel runs once per GPU thread. The same rules hold as for host functions: one word is
+one Qwen3 token, types are inferred, control is structured, every loop is bounded, and the same
+trust chain checks it (Omegese, then the op list, then canonical IR, then checker2, then a signed
+receipt). The backend is new; nothing above the IR changes meaning.
+
+A kernel that checker2 accepts gives the same output bits on every run. That is the design goal
+of sections 6 to 9: no data races, no hang at `sync` or `down`, and a trap code that does not depend
+on thread timing.
+
+## 2. The kernel line
+
+```
+kernel <name> <threads> (<param> <ptype>)*     a kernel; `end` closes it; it returns nothing
+```
+
+`<threads>` is a number: the threads in each block, 32 to 1024, a multiple of 32. It is fixed
+when the kernel is written, so the checker knows the exact range of `thread`. The launcher uses it
+and cannot change it.
+
+Parameter types:
+
+| written | meaning | in the IR |
+|---|---|---|
+| `view float` / `view uint` | a global buffer the kernel reads | pointer (GVIEW, elem) + hidden u32 length |
+| `edit float` / `edit uint` | a global buffer the kernel reads and writes | pointer (GEDIT, elem) + hidden u32 length |
+| `float` / `uint` / `bool` | one value, the same in every thread | scalar |
+
+A buffer has no length in the source. The launcher passes it, and reads it from its own table of
+allocations, never from the caller (section 11). `len a` reads it (type uint). Every `get`/`put` on a
+buffer checks the index against that length (trap 3).
+
+`omegese next` and `omegese complete` (the writing aids) cover host functions only in v1: a kernel is
+written whole and given to `omegese emit`. The kernel words (`kernel`, the words of section 3,
+`shared`, `sync`) are words only inside a kernel; a host function may still use them as names.
+Every fixed word, these included, is one Qwen3 token (`evidence/omegese-gpu/front/tokenizer-gate.txt`).
+
+`own` is refused in a kernel line: a kernel never owns global memory. A kernel has at most 32 IR
+parameter registers; a buffer uses two (pointer and length), a scalar one.
+
+## 3. Values a kernel can read
+
+| word | takes | type | meaning |
+|---|---|---|---|
+| `thread` | 0 | uint | this thread's index in its block, 0 to threads-1 |
+| `threads` | 0 | uint | the thread count from the kernel line (a number) |
+| `block` | 0 | uint | this block's index along x, 0 to blocks-1 |
+| `blocks` | 0 | uint | blocks along x |
+| `batch` | 0 | uint | this block's index along y, 0 to batches-1 |
+| `batches` | 0 | uint | blocks along y |
+| `len` a | 1 | uint | length of buffer or shared array a |
+| `down` v n | 2 | type of v | v from the thread n lanes higher in the same warp of 32; n is a number 1 to 31; a lane with no such neighbour gets its own v; v is uint or float |
+| `min` / `max` a b | 2 | float or uint | smaller / larger (float rules in section 4) |
+| `mad` a b c | 3 | float | a times b plus c, rounded once |
+| `exp` x | 1 | float | e^x, approximate (section 5) |
+| `inv` x | 1 | float | 1/x, approximate |
+| `root` x | 1 | float | the square root of x, approximate |
+
+`inv root x` is read as one operation, 1/sqrt(x) (section 5).
+
+The grid is one-dimensional inside a block (`thread`) and two-dimensional across blocks (`block`,
+`batch`). The usual global index is `add mul block threads thread`.
+
+## 4. Types and arithmetic in a kernel
+
+`bool`, `uint` (u32) and `float` (IEEE binary32). The 64-bit types and the signed types are refused
+inside a kernel in v1 (checker rule C2-GPU-TYPE). Loop counters, including the hidden ones of `while`
+and `for`, are uint.
+
+- `add sub mul` on uint trap 1 when the true result does not fit in 32 bits. On the host these wrap.
+  In a kernel they do not, so index arithmetic is exact. The race rules in section 8 depend on this.
+- `add sub mul` on float round to nearest even. Denormal inputs and results are kept (no flush to
+  zero). The backend never fuses them; only `mad` is fused (one rounding, FFMA on the chip, `fmaf`
+  in a host reference).
+- `div` and `rem` on float are refused. `div`/`rem` on uint need a number other than 0 as the
+  divisor; the backend multiplies by a magic constant and the result is exact.
+- `shl`/`shr` on uint: amount 32 or more traps 7 (host rule).
+- Comparisons on float are ordered: any comparison with NaN is false, except `ne`, which is true.
+- `neg x` on float flips the sign bit and keeps a NaN payload. On uint, `neg` wraps (host rule).
+- `min`/`max` on float: if one input is NaN the result is the other; if both are NaN the result is
+  the canonical NaN 0x7FFFFFFF; `min` of -0 and +0 is -0 and `max` is +0. This is the chip's FMNMX;
+  the chip sweep in `evidence/omegese-gpu/fmnmx/` confirms it before any kernel relies on it.
+- Every float op that makes a new NaN gives 0x7FFFFFFF. A host reference canonicalises NaN results
+  the same way before it compares.
+- Conversions: `float x` from uint rounds to nearest even. `uint x` from float truncates toward
+  zero; NaN and values whose truncation is outside 0 to 2^32-1 trap 5. `bool` to or from a number is
+  refused (host rule).
+- Float numbers in the source: a bare integer in a float place is that integer, and must be exact
+  in binary32 (else refused). A number with a point (`1.5`, `-1.442695`) is the decimal rounded once,
+  to nearest even, straight to binary32. The leading `-` is part of the number. A point may appear only
+inside a kernel (host functions have no float).
+
+## 5. Approximate functions
+
+`exp`, `inv`, `inv root` and `root` use the chip's fast function unit (MUFU). They are deterministic
+(the same input gives the same bits on every run) but are not correctly rounded. MUFU treats a
+denormal input as zero (so `inv` of a denormal is +inf), and gives a zero of the same sign where the
+true result is denormal (so `inv 0x7F7FFFFF` is +0, measured on the GB10 on 2026-10-22; this sentence was
+added on 2026-10-27, after that run). The definitions:
+
+- `exp x` = EX2(RN(x * 0x3FB8AA3B)): 2 to the power of (x times log2 e, rounded to binary32).
+- `inv x` = RCP(x).
+- `inv root x` = RSQ(x), one operation.
+- `root x` = RCP(RSQ(x)). This gives 0 at 0 and +inf at +inf.
+
+A host reference for a kernel that uses them states its tolerance before the run, or runs a bit
+model of the MUFU unit measured on the chip (`evidence/omegese-gpu/mufu/`).
+
+## 6. Shared memory and sync
+
+```
+s = shared float 256         a block-shared array of 256 floats (uint also allowed)
+sync                         wait until every thread of the block reaches this line
+```
+
+- `shared` is allowed only as the whole value of `<name> =` in the first block of the kernel
+  (before any `if`, loop or call). The length is a number, 1 to 12288; the total over all shared
+  arrays is at most 48 KiB.
+- Every shared array starts zero. The backend zeroes it at kernel start and syncs once, so a read
+  before any write sees 0 on every run.
+- `get`/`put` on a shared array are bounds checked against the static length (trap 3).
+- A shared array name may be read only in its kernel. It cannot be passed, freed, copied or moved.
+
+`sync` and `down` need all threads to reach them together (rule C2-GPU-SYNC-DIVERGENT):
+
+- A value is **varying** when it can differ between threads of a block: `thread`, every `get` (global
+  or shared), every `down`, and any value computed from a varying value. A value assigned inside a
+  divergent block is varying too.
+- A block is **divergent** when some threads of the block may run it and others not: every block
+  between a branch on a varying condition and that branch's join, where the join is the nearest block
+  every path from the branch reaches. A `ret` (also the one inside a `trap N` line, section 7) goes
+  to one virtual exit, so the code after a varying `ret` is divergent until the kernel ends.
+- The IR assigns a register more than once, so varying values and divergent blocks are computed
+  together and repeated until nothing changes.
+- `sync` and `down` are allowed only in blocks that are not divergent.
+- Varying regions nest at most 16 deep (rule C2-GPU-NEST). This is the depth the chip tests cover
+  (`gen_rc_depth` in `src/omega_gpu_elementwise_api.c`), so a kernel checker2 accepts always fits the
+  backend's reconvergence barriers.
+
+## 7. Traps on the GPU
+
+A kernel traps with the host codes: 1 uint overflow, 3 bounds, 4 loop bound, 5 conversion, 7 shift.
+
+The launcher passes a hidden status buffer of 16 u32 words, zeroed before launch. A trapping thread
+stores 1 into word N. After the launch the launcher reads the words. The result is the lowest N
+whose word is 1, and the output buffers are declared undefined.
+
+There are two kinds of trap:
+
+- **A trap inside an operation** (overflow, bounds, conversion, shift). The thread records the code,
+  takes 0 as the result of the operation, and keeps running. From then on it stores nothing: every
+  later `put` of that thread, global or shared, is skipped. It still reaches every `sync` and `down`
+  the other threads reach, because control at those points never depends on its data.
+- **A loop that passes its bound (trap 4).** The thread records the code and leaves the loop. From
+  then on it stores nothing, as above.
+- **A `trap N` line.** The thread records the code and returns: `trap N` is a trap followed by `ret`.
+  checker2 treats it like `ret`: when the branch to it is varying, the code after it is divergent,
+  so no `sync` or `down` can follow it.
+
+In the IR a kernel TRAP is an ordinary instruction: the thread records the code, stops storing and
+runs on to the end of its block. Only RET ends a thread. So for definite assignment the path through
+a TRAP continues (a host TRAP ends the path), and a register left unset on that path is refused.
+
+Why the code is the same on every run: a thread's own steps are fixed by its inputs, and the race
+rules (section 8) make every input fixed. The only case where the race rules can fail is when an
+index overflowed. That records code 1, which is the lowest code, so the result is 1 on every run.
+
+## 8. Race rules
+
+A kernel is refused if two threads can touch the same element of a buffer or shared array, at a time
+not ordered by `sync`, and one of them writes it. checker2 proves this with index expressions.
+
+**Index expressions.** An index is read as a tree through registers that have exactly one
+assignment. The leaves are:
+
+- numbers;
+- uniform inputs that never change: scalar parameters, buffer lengths, `blocks`, `batches`;
+- `thread`, `block` and `batch` (the grid digits);
+- `rem thread K` and `div thread K` with K a number (the low and high thread digits for K);
+- loop counters (the loop digits): a uint counter set from a number before the loop and increased
+  by 1 as the last step of the loop's one back edge. A tree with a loop digit may be used only
+  inside that loop. Omegese gives the hidden counters of a kernel's loops the type uint, so they
+  are loop digits.
+
+The inner nodes are `add`, `mul`, `div` and `rem`. Anything else makes the tree opaque, and an
+opaque tree proves nothing.
+
+**One-to-one indexes.** A tree is one-to-one over its digits when different digit values always
+give different indexes:
+
+- a single digit is one-to-one;
+- `mul x k` with x one-to-one and k a number other than 0 is one-to-one;
+- `add mul x M y` is one-to-one when x and y are one-to-one, they share no digit, and y is always
+  less than M. "Less" is proven by the largest value of y (from numbers and digit ranges: `thread`
+  is below the kernel's thread count, `rem thread K` below K, `div thread K` below the thread count
+  over K, a loop digit below a number count) or by an enclosing `if lt y M` whose two sides are
+  the same trees;
+- adding a tree with no digit keeps it one-to-one.
+
+`rem thread K` and `div thread K` with the same K together stand for `thread`.
+
+**Fixed digits.** Inside `if eq D c`, where D is a grid digit or thread digit and c a number, D has
+the fixed value c. A fixed digit counts as covered, but only for a pair of accesses that both have
+the same fixed value.
+
+**Global buffers (C2-GPU-GLOBAL-RACE).** For every `edit` buffer that the kernel writes, every `get`
+and every `put` on it must use the same index tree E. E must be one-to-one and must cover `thread`,
+plus `block` if the kernel reads `block`, plus `batch` if it reads `batch`. The launcher refuses a
+launch with more than one block along x or y when the kernel does not read `block` or `batch`.
+`view` buffers are never written, so any index is allowed.
+
+**Shared arrays (C2-GPU-SHARED-RACE).** The `sync` lines cut the kernel into phases. Two accesses can
+run at the same time only if a single `sync` (or the kernel start) reaches both of them without
+passing another `sync`. checker2 computes that set of starting points for every access, following
+loop back edges. For every pair of accesses to one shared array that can run at the same time,
+where at least one is a `put` (a `put` is paired with itself), both must use the same index tree E,
+one-to-one and covering `thread`.
+
+At most 63 `sync` lines in a kernel. This bounds the phase sets.
+
+**Aliasing.** The launcher refuses a launch where an `edit` buffer overlaps any other buffer. To
+write a result into an input, declare the input `edit` and use the same index (the 35B gate in
+section 12 does this).
+
+## 9. The IR (encoding version 8)
+
+Version 8 is used only when a unit has a kernel; units without one keep versions 1 to 5 and their
+bytes. Version 6 is reserved by draft PR #525 (structured contracts) and version 7 is the memory
+profile of `spec/one-layer-format.md` section 10; this decoder refuses both as unknown versions.
+Kernel units were written as version 6 with opcodes 30 to 36 until 2026-10-27; evidence committed
+before then records those bytes and their hashes and is kept as history. Additions:
+
+- Each function carries a kind byte: 0 host, 1 kernel. A kernel then carries its thread count
+  (u16, 32 to 1024, a multiple of 32). A kernel returns VOID and has no `requires` or `ensures`.
+  Host code cannot call a kernel; a kernel cannot call any function in v1.
+- Scalar F32. Pointer scalars GVIEW and GEDIT (elem U32 or F32), each followed by its u32 length
+  register, as slices are (OSC_T_BYTES).
+- REF kind BLOCK: a shared array (elem U32 or F32, len 1 to 12288).
+- New instructions, numbered from 40 so they are disjoint from version 7's opcodes 30 to 33
+  (GPU 40, SHARED 41, GLOAD 42, GSTORE 43, SYNC 44, SHFL 45, MAD 46; 30 to 39 are refused):
+  - `GPU` sub THREAD/BLOCK/BLOCKS/BATCH/BATCHES: dst u32. (`threads` lowers to CONST.)
+  - `SHARED`: dst = a zeroed shared array; entry block only.
+  - `GLOAD` a b: dst = buffer a at index b (u32), bounds against a+1.
+  - `GSTORE` a b c: buffer a (GEDIT) at b = c.
+  - `SYNC`.
+  - `SHFL` sub DOWN a b: dst = down(a, b); b is a register with one assignment, a CONST 1 to 31.
+  - `MAD` a b c: dst = a * b + c, F32, rounded once.
+- New BIN subs MIN and MAX; new UN subs EXP, INV, RSQ, SQRT (F32 only).
+- CAST is extended to u32 to and from f32; CMP to f32.
+- LOAD and STORE work on BLOCK refs; ALLOC, RELEASE and slices are refused in kernels.
+
+## 10. checker2 rules for kernels
+
+Restated independently in `src/checker2/` (as for host code):
+
+- C2-GPU-TYPE: only bool, u32, f32, GVIEW/GEDIT, BLOCK refs in a kernel; none of them in a host
+  function.
+- C2-GPU-KERNEL: a kernel returns VOID, has no contract, and has 32 to 1024 threads, a multiple of
+  32.
+- C2-GPU-SYNC-DIVERGENT and C2-GPU-NEST: section 6.
+- C2-GPU-SHARED: SHARED only in the entry block, once per register; total bytes at most 49152.
+- C2-GPU-BUFFER: a buffer register is a parameter and is never assigned.
+- C2-GPU-STORE-VIEW: no GSTORE to a GVIEW buffer.
+- C2-GPU-CALL: no call into or out of a kernel.
+- C2-GPU-DIV: uint div/rem need a CONST divisor that is not 0.
+- C2-GPU-SHFL: the distance is a CONST 1 to 31.
+- C2-GPU-GLOBAL-RACE and C2-GPU-SHARED-RACE: section 8.
+- The host rules all still apply: definite assignment, loop bounds, types per op.
+
+## 11. Backend and launcher
+
+`src/omega_osc_gpu.c` reads a checked unit and builds one BlackwellIRProgram per kernel, then
+calls `omega_bw_regalloc_solve` and `omega_bw_encode_program`. The host code generator
+(`osc_cg`) and the interpreter (`osc_interp`) refuse a unit that has a kernel.
+
+- Arguments live in constant bank 0 from 0x380: for each parameter in order, a buffer is a 64-bit
+  address then a 32-bit length; a scalar is 32 bits. Then the hidden args: status address (64 bit),
+  blocks, batches (32 bit each). 8-byte values are 8-byte aligned.
+- Each IR block becomes a run of builder instructions. Branches become BRA with a relative target,
+  patched after layout. A bool is kept as 0/1 in a register; a CBR is a compare then @P0 BRA.
+- Reconvergence. A branch on a varying value whose nearest join J is a block opens a region: its
+  members are the blocks reachable from the branch without passing J, and its head is the one block
+  every edge into the members enters (the branch block, or the loop head when the branch sits in a
+  loop that J is outside of). Each block is laid out as [joins][arms][body][branches]: one BSYNC per
+  region that joins at this block (innermost first), then one BSSY per region whose head it is
+  (outermost first). An edge lands on the first join of its target that it belongs to, else on the
+  first arm it is outside of, else on the body. A branch whose paths meet only at the virtual exit
+  opens no region (the lanes that return exit, the rest stay together); the kernel is refused if a
+  region head can be reached after such a branch. Regions that overlap without nesting are refused.
+  Uniform branches need none.
+- Barrier registers: two regions get different ones when one contains the other or both lie in a
+  common region; otherwise they share. At most 16 (rule C2-GPU-NEST keeps checked kernels inside).
+- Liveness is computed over the CFG (loops included) and passed to the builder's allocator as
+  intervals over the final layout. A kernel that needs more than the allocator's registers is
+  refused with a message; v1 does not spill.
+- Scheduling follows the rules the elementwise emitter learned on the chip
+  (`src/omega_gpu_elementwise_api.c`). v1 waits on everything pending before each instruction.
+  Correct first; speed is C3's job.
+- A trap inside an operation is a compare, a store of 1 to the status word, and setting the thread's
+  poison flag; every `put` is predicated on the flag being clear.
+
+`omega_kernel_launch` (`src/omega_osc_launch.c`) takes the receipt, the code, the buffers, the scalars
+and the grid. Its checks live in `omega_kernel_launch_words` (`src/omega_osc_launch_args.c`, no device
+calls), so the host tests prove each refusal. It:
+
+- refuses code whose SHA-256 differs from the receipt;
+- refuses a launch whose argument kinds or count differ from the kernel line, or a bool other than 0 or 1;
+- takes each buffer as a range (start, element count) inside one session allocation (`OmegaGpuMem`,
+  whose size the session recorded when it allocated it), and refuses a range past its end;
+- refuses overlaps that involve an `edit` buffer;
+- refuses more than one block along x (or y) when the kernel never reads `block` (or `batch`);
+- zeroes the status words, launches through `omega_gpu_session_launch` with a stated timeout, then
+  reads the status words and reports the trap code or 0.
+
+## 12. Examples
+
+Vector add:
+
+```
+kernel vadd 256 a view float b view float c edit float
+i = add mul block threads thread
+if lt i len c
+put c i add get a i get b i
+end
+end
+```
+
+The 35B gate, in place (a = a * sigmoid(g)):
+
+```
+kernel gate 256 a edit float g view float
+i = add mul block threads thread
+if lt i len a
+put a i mul get a i inv add exp neg get g i 1
+end
+end
+```
+
+The live kernel writes its output over its first input, so the Omegese version declares that input
+`edit` and reads and writes it at the same index. `exp neg x` gives the same bits as the live
+kernel's EX2(x * -log2 e): negation is exact and RN((-x) * L) = -RN(x * L).
+
+## 13. Done-when (C1, from OMEGA.md)
+
+Vector add, a tiled GEMM and one decode-attention kernel, written in Omegese, pass checker2 and run
+on the GB10 with outputs equal to a host reference (bit for bit, or a tolerance stated before the
+run); a broken kernel is refused; one kernel of the live 35B decode path (the gate) is swapped for
+its Omegese version on a test server with identical golden tokens.
+
+Status on 2026-10-27, commit e83c740c7: the first three parts ran on the GB10.
+`evidence/omegese-gpu/chip-20261027/chip-green.log` has 59 launches and 645 checks with 0 failed,
+the four Omegese kernels (`om_vadd`, `om_gate`, `om_gemm`, `om_attn`) included.
+`chip-red-mutant1.log` uses the same binary with mutant 1, which drops the predicate so trapped
+threads still store. It fails 8 checks and exits 1, which shows the chip test can fail.
+The refusals are on the host, in `chip-20261027/host-test-osc-gpu.log` at the same commit:
+checker2 accepts 13 kernels and refuses 15 broken ones, each with its expected reason.
+
+Status on 2026-10-27, commit 67d228d26 (wire version 8, kernel opcodes 40..46): the lowering from
+OSC IR to BlackwellIR is also written in seeded `.om` (`seed/oscgpu/oscir.om`, `gpu*.om`, `c2*.om`),
+built with the pinned `seed/out/omc`. Register allocation and the encoder stay the C builder; the C
+lowering stays the production path and the oracle until the `.om` replaces it. On the host,
+`make test-om-ports` passes: `oscir.om` against `osc_ir_decode`/`osc_ir_validate` (n=6054, diff=0),
+`c2*.om` against checker2 (21627 cases, 0 differ), and the `.om` lowering against the C one
+(n=26556, diff=0; `OMBYTES identical=119 differ=0` over the test kernels' code). `make test-omegese`
+passes (its tokenizer gate is SKIPPED without a tokenizer). On the GB10 at 2026-10-27T16:30:40Z,
+`evidence/omegese-gpu/chip-20261027T1630Z-om/chip-green.log` ran `test_osc_gpu_chip` with
+`OSC_GPU_OM_DIR`, so the kernels it launches took their code from the `.om` lowering, checked equal
+to the C build (`OMBYTES identical=13 differ=0`): 59 launches, 645 checks, 0 failed. The red run
+with mutant 1 fails 8 checks and exits 1.
+
+`make test-checker2-owner-receipt` fails with UNTRUSTED_CHECKER: checker2's identity changed on this
+branch, so its owner receipt needs Drake to re-sign it with his YubiKey (BLOCKED_OPERATOR).
+
+The gate swap ran on 2026-10-27 in an exclusive window that Drake authorized (18091 stopped), on
+draft PR #886 (`c1/gate-lever-reembed`; library from omega 2f6561d4b, the live library plus the
+lever commits). Its receipt is `evidence/omegese-gate-lever/golden-20261027T1634Z/` on that
+branch (commit b8c907e7d). With `AIEN_OMEGA_Q36_OMEGESE_GATE=1`, a test server on 127.0.0.1:18195
+logged the Omegese gate on (code sha256 fabdfc55) and passed 8 of 8 cells: five golden chats, 32
+requests together against the alone reference 5b726818, a second turn and a tool call. The red
+control, with the gate mutated to a * sigmoid(-g) (code 09522207, which checker2 accepts), changed
+the tokens in 6 of 6 cells (RED-OK). The gate's code from the `.om` lowering is the same fabdfc55
+(`chip-20261027T1630Z-om/host-test-om-ports.log`). An earlier attempt at 16:31Z loaded nothing and is NOT_RUN, not FAIL
+(`golden-20261027T1631Z-NOTE.md`). The swap is on #886, not merged into this branch or `main`.
+
+## 14. Review 1 (2026-10-21)
+
+The brief asks for a Fable review before building past vector add. Fable refused twice with its
+weekly limit, so Claude Opus 5.5 reviewed design v1 (commit c0295f31) read-only. Its full text is
+`evidence/omegese-gpu/review/design-review-1.md`. It found 19 problems, 5 of them blockers.
+
+| # | severity | finding | what changed |
+|---|---|---|---|
+| 1 | blocker | nothing stopped races on shared memory | C2-GPU-SHARED-RACE (section 8) |
+| 2 | blocker | nothing stopped races on global memory | C2-GPU-GLOBAL-RACE (section 8) |
+| 3 | blocker | the `same-index` alias fact ignored `batch` and partial overlaps | `same-index` removed; an `edit` buffer may overlap nothing; in place is written as one `edit` buffer |
+| 4 | blocker | bounds checks trusted a caller-supplied length | the launcher takes lengths from its allocation table |
+| 5 | blocker | a thread that traps and exits can hang `sync` or `down` | traps inside an operation keep the thread running with stores off; `trap N` ends the thread and counts as `ret` for divergence (section 7); the drain path and its measurement are dropped |
+| 6 | should-fix | the doc's uniformity text was weaker than the checker | section 6 now states the full rule |
+| 7 | should-fix | whole-block uniformity is too strict for `down` in a warp-0 stage | deferred: v1 reductions run `down` in every warp, then read the warp results from shared memory; the C1 kernels need nothing more |
+| 8 | blocker | `down` was undefined for partial warps and large distances | thread count is a multiple of 32; the distance is a number 1 to 31 (C2-GPU-SHFL) |
+| 9 | should-fix | no shuffle gives every lane the result | deferred: the builder has no butterfly shuffle and the C6 oracle is not yet in place to check a new encoding; v1 broadcasts through shared memory |
+| 10 | should-fix | NaN and denormal behaviour not pinned | section 4: canonical NaN, no flush to zero for add and mul, `ne` is unordered; section 5: MUFU flushes denormal inputs |
+| 11 | should-fix | min/max NaN rules only in a code comment | section 4, to be confirmed by a chip sweep |
+| 12 | should-fix | decimal literals could round twice | one rounding straight to binary32; the leading `-` is part of the number |
+| 13 | should-fix | no fused multiply-add | `mad` added (IR op MAD) |
+| 14 | should-fix | the thread count was known only at launch | the thread count is part of the kernel line |
+| 15 | should-fix | 16 parameter registers is only 8 buffers | raised to 32 registers; `down` on bool is refused and the doc says so |
+| 16 | should-fix | pieces missing for a full CUDA replacement | deferred to the C3 roadmap, none is needed by a C1 kernel: atomics, bf16/fp16/fp8, vector loads, tensor-core matrix multiply, sin and cos, a third grid axis, divisors known only at run time, more than 48 KiB of shared memory. Too many registers is refused, not spilled (section 11) |
+| 17 | should-fix | `root` read as 1/sqrt would be misread | `root` is sqrt; `inv root` is one RSQ |
+| 18 | nit | one-letter word pairs, unverified token counts | words kept (they are the words a model already uses for these things); every new word is checked against the Qwen3 tokenizer and the result saved in `evidence/omegese-gpu/tokens/` |
+| 19 | nit | the backend nesting cap was not in checker2 | C2-GPU-NEST, cap 16 |
diff --git a/evidence/omegese-gpu/01-red-ir-decode.log b/evidence/omegese-gpu/01-red-ir-decode.log
new file mode 100644
index 000000000..f51534975
--- /dev/null
+++ b/evidence/omegese-gpu/01-red-ir-decode.log
@@ -0,0 +1,4 @@
+tests/compiler/test_osc_ir_decode.c:43:56: error: ‘OSC_REF_BLOCK’ undeclared here (not in a function); did you mean ‘OSC_REF_OWN’?
+tests/compiler/test_osc_ir_decode.c:43:16: error: expression in static assertion is not an integer
+tests/compiler/test_osc_ir_decode.c:44:16: error: ‘OSC_T_F32’ undeclared here (not in a function); did you mean ‘OSC_T_I32’?
+red exit 2
diff --git a/evidence/omegese-gpu/chip-20261027/chip-green.log b/evidence/omegese-gpu/chip-20261027/chip-green.log
new file mode 100644
index 000000000..889af73cd
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027/chip-green.log
@@ -0,0 +1,22 @@
+Tue Oct 27 02:55:39 AM UTC 2026
+e83c740c75ec3b534eef97ce3118c13f0fa65338
+3e5c7e9f70d142c99a2bea3cd0045d11ffa5d867a812bdb903d83efb62eedc06  build/osc_gpu/test_osc_gpu_chip
+COMMAND: timeout 300 stdbuf -oL -eL env OSC_GPU_MUTANT=0 build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir
+test_osc_gpu_chip: GB10, mutant 0, MUFU tolerance 2^-20 relative (stated in the source before the run; denormal results may be a zero of the same sign, amended 2026-10-27 after the 2026-10-22 run)
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+test_osc_gpu_chip: 59 chip launches, 6.278 ms on the chip in total
+test_osc_gpu_chip: 645 checks, 0 failed
+EXIT: 0
+Tue Oct 27 02:55:40 AM UTC 2026
diff --git a/evidence/omegese-gpu/chip-20261027/chip-red-mutant1.log b/evidence/omegese-gpu/chip-20261027/chip-red-mutant1.log
new file mode 100644
index 000000000..46d76e5dd
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027/chip-red-mutant1.log
@@ -0,0 +1,30 @@
+Tue Oct 27 02:55:40 AM UTC 2026
+e83c740c75ec3b534eef97ce3118c13f0fa65338
+3e5c7e9f70d142c99a2bea3cd0045d11ffa5d867a812bdb903d83efb62eedc06  build/osc_gpu/test_osc_gpu_chip
+COMMAND: timeout 300 stdbuf -oL -eL env OSC_GPU_MUTANT=1 build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir
+test_osc_gpu_chip: GB10, mutant 1, MUFU tolerance 2^-20 relative (stated in the source before the run; denormal results may be a zero of the same sign, amended 2026-10-27 after the 2026-10-22 run)
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+FAIL: vadd short inputs order 0: 100 words wrong (a trapped thread stored, or a good one did not)
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+FAIL: ops_u op 0 order 0: 36 wrong (first t 3: got 0x00000000 want 0xdeadbeef, a 0xffffffff b 0x00000001)
+FAIL: ops_u op 1 order 0: 75 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 2 order 0: 184 wrong (first t 0: got 0x00000000 want 0xdeadbeef, a 0x3e845270 b 0x0000000f)
+FAIL: ops_u op 10 order 0: 182 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 11 order 0: 182 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 28 order 0: 104 wrong (first t 0: got 0x00000000 want 0xdeadbeef, a 0x3e845270 b 0x0000000f)
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+FAIL: vadd short inputs order 0: 100 words wrong (a trapped thread stored, or a good one did not)
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+test_osc_gpu_chip: 59 chip launches, 6.147 ms on the chip in total
+test_osc_gpu_chip: 645 checks, 8 failed
+EXIT: 1
+Tue Oct 27 02:55:40 AM UTC 2026
diff --git a/evidence/omegese-gpu/chip-20261027/host-test-osc-gpu.log b/evidence/omegese-gpu/chip-20261027/host-test-osc-gpu.log
new file mode 100644
index 000000000..22d979b6f
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027/host-test-osc-gpu.log
@@ -0,0 +1,33 @@
+Tue 27 Oct 2026 02:56:15 AM UTC
+e83c740c75ec3b534eef97ce3118c13f0fa65338
+COMMAND: taskset -c 10-14 make PHYSICS_DIR=../physics-c1 test-osc-gpu
+sh tests/osc_gpu/run.sh build/omegese/omegese build/omega_emit/omega_emit build/checker2/checker2 build/osc_gpu/test_osc_gpu build/osc_gpu/ir build/osc_gpu/osc_gpu_build
+run.sh: 13 kernels emitted and accepted by checker2
+run.sh: 15 broken kernels refused with their expected reasons
+run.sh: 1 embedded kernels still build to the bytes they embed
+  division by a number: 5899975 quotients checked
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  mutant 1 (stores ignore poison): caught by 16 checks
+  mutant 2 (joins dropped): caught by 52 checks
+  mutant 3 (no add overflow trap): caught by 5 checks
+  mutant 4 (intervals not stretched): caught by 10 checks
+  mutant 5 (every region on barrier 0): caught by 3 checks
+  mutant 6 (shared not zeroed): caught by 2 checks
+  mutant 7 (bounds-failed loads run): caught by 4 checks
+  mutant 8 (division magic off by one): caught by 4 checks
+test_osc_gpu: 1308 checks, 0 failed
+EXIT: 0
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-green.log b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-green.log
new file mode 100644
index 000000000..86a892f3f
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-green.log
@@ -0,0 +1,23 @@
+Tue Oct 27 04:30:40 PM UTC 2026
+67d228d265439be346c85aca28bf753f0bc05241
+0dd6470e4f7c8e8017c249b1f695c2c44ad53b6cc86fd474b534e1b1aa29971b  build/osc_gpu/test_osc_gpu_chip
+COMMAND: timeout 300 stdbuf -oL -eL env OSC_GPU_OM_DIR=/home/drakestapleton/work/C1Land/omega/../omchip OSC_GPU_MUTANT=0 build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir
+test_osc_gpu_chip: GB10, mutant 0, MUFU tolerance 2^-20 relative (stated in the source before the run; denormal results may be a zero of the same sign, amended 2026-10-27 after the 2026-10-22 run)
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+test_osc_gpu_chip: 59 chip launches, 6.648 ms on the chip in total
+test_osc_gpu_chip: 645 checks, 0 failed
+OMBYTES identical=13 differ=0
+EXIT: 0
+Tue Oct 27 04:30:40 PM UTC 2026
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-om.sh b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-om.sh
new file mode 100755
index 000000000..83f5f455b
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-om.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# C1Land chip run: test_osc_gpu_chip green (mutant 0) and red (mutant 1), with the kernels' bytes taken from the
+# seeded .om lowering (OSC_GPU_OM_DIR, built by tests/osc_gpu/om_build_all.sh) and asserted equal to the C build.
+# Called inside flock -w 900 /tmp/aien-gb10.lock; writes logs to $1 and BOARD GPU-START/GPU-END lines.
+set -u
+OUT=$1; OMD=$2
+B=/home/drakestapleton/handoffs/BOARD.md
+cd /home/drakestapleton/work/C1Land/omega || exit 2
+mkdir -p "$OUT"
+echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) C1Land: GPU-START test_osc_gpu_chip green+red with OSC_GPU_OM_DIR (.om lowering), c1/chip-fix $(git rev-parse --short HEAD), <=15 min" >> "$B"
+for m in 0 1; do
+    n=$([ $m = 0 ] && echo green || echo red-mutant1)
+    {
+        date -u
+        git rev-parse HEAD
+        sha256sum build/osc_gpu/test_osc_gpu_chip
+        echo "COMMAND: timeout 300 stdbuf -oL -eL env OSC_GPU_OM_DIR=$OMD OSC_GPU_MUTANT=$m build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir"
+        timeout 300 stdbuf -oL -eL env OSC_GPU_OM_DIR="$OMD" OSC_GPU_MUTANT=$m build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir 2>&1
+        echo "EXIT: $?"
+        date -u
+    } > "$OUT/chip-$n.log" 2>&1
+done
+echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) C1Land: GPU-END test_osc_gpu_chip; logs $OUT" >> "$B"
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-red-mutant1.log b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-red-mutant1.log
new file mode 100644
index 000000000..e376e0b23
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/chip-red-mutant1.log
@@ -0,0 +1,31 @@
+Tue Oct 27 04:30:40 PM UTC 2026
+67d228d265439be346c85aca28bf753f0bc05241
+0dd6470e4f7c8e8017c249b1f695c2c44ad53b6cc86fd474b534e1b1aa29971b  build/osc_gpu/test_osc_gpu_chip
+COMMAND: timeout 300 stdbuf -oL -eL env OSC_GPU_OM_DIR=/home/drakestapleton/work/C1Land/omega/../omchip OSC_GPU_MUTANT=1 build/osc_gpu/test_osc_gpu_chip build/osc_gpu/ir
+test_osc_gpu_chip: GB10, mutant 1, MUFU tolerance 2^-20 relative (stated in the source before the run; denormal results may be a zero of the same sign, amended 2026-10-27 after the 2026-10-22 run)
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+FAIL: vadd short inputs order 0: 100 words wrong (a trapped thread stored, or a good one did not)
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+FAIL: ops_u op 0 order 0: 36 wrong (first t 3: got 0x00000000 want 0xdeadbeef, a 0xffffffff b 0x00000001)
+FAIL: ops_u op 1 order 0: 75 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 2 order 0: 184 wrong (first t 0: got 0x00000000 want 0xdeadbeef, a 0x3e845270 b 0x0000000f)
+FAIL: ops_u op 10 order 0: 182 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 11 order 0: 182 wrong (first t 1: got 0x00000000 want 0xdeadbeef, a 0x32cad522 b 0x71f95219)
+FAIL: ops_u op 28 order 0: 104 wrong (first t 0: got 0x00000000 want 0xdeadbeef, a 0x3e845270 b 0x0000000f)
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+FAIL: vadd short inputs order 0: 100 words wrong (a trapped thread stored, or a good one did not)
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+test_osc_gpu_chip: 59 chip launches, 6.281 ms on the chip in total
+test_osc_gpu_chip: 645 checks, 8 failed
+OMBYTES identical=13 differ=0
+EXIT: 1
+Tue Oct 27 04:30:41 PM UTC 2026
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-checker2-owner-receipt.log b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-checker2-owner-receipt.log
new file mode 100644
index 000000000..1e3ddd822
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-checker2-owner-receipt.log
@@ -0,0 +1,8 @@
+sh tests/checker2/owner_receipt.sh build/checker2/checker2 tests/checker2/fixtures/owner-receipt build/checker2/owner-receipt
+owner_receipt: FAIL owner draft is not byte-identical to the committed draft
+owner_receipt: FAIL production verify: receipt=UNTRUSTED_CHECKER
+owner_receipt: FAIL default (production) verify: receipt=UNTRUSTED_CHECKER
+owner_receipt: FAIL control wrong-target: want WRONG_TARGET, got receipt=UNTRUSTED_CHECKER
+owner_receipt: FAIL control wrong-executable: want EXECUTABLE_MISMATCH, got receipt=UNTRUSTED_CHECKER
+owner_receipt: FAIL (5)
+make: *** [mk/checker2.mk:108: test-checker2-owner-receipt] Error 1
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-om-ports.log b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-om-ports.log
new file mode 100644
index 000000000..e1411c517
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-om-ports.log
@@ -0,0 +1,59 @@
+sh tests/osc_gpu/run.sh build/omegese/omegese build/omega_emit/omega_emit build/checker2/checker2 build/osc_gpu/test_osc_gpu build/osc_gpu/ir build/osc_gpu/osc_gpu_build
+sh tests/checker2/differential.sh build/compiler/oscc build/checker2/osc_emit_ir build/checker2/checker2 build/checker2/differential build/omega_emit/omega_emit
+run.sh: 14 kernels emitted and accepted by checker2
+run.sh: 15 broken kernels refused with their expected reasons
+run.sh: 1 embedded kernels still build to the bytes they embed
+differential: kernels accepted=6, kernel negatives refused by their rule=19
+differential: accepted by both=107 front-end refusals=138 (known-bad neg units=138) disagreements=0
+  division by a number: 5899975 quotients checked
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  mutant 1 (stores ignore poison): caught by 16 checks
+  mutant 2 (joins dropped): caught by 52 checks
+  mutant 3 (no add overflow trap): caught by 5 checks
+  mutant 4 (intervals not stretched): caught by 10 checks
+  mutant 5 (every region on barrier 0): caught by 3 checks
+  mutant 6 (shared not zeroed): caught by 2 checks
+  mutant 7 (bounds-failed loads run): caught by 4 checks
+  mutant 8 (division magic off by one): caught by 4 checks
+test_osc_gpu: 1308 checks, 0 failed
+sh tests/osc_gpu/oscir_diff.sh seed/out/omc build/osc_gpu/oscir_diff
+sh tests/checker2/om_diff.sh build/checker2/checker2 build/checker2/om build/checker2/differential/ir build/osc_gpu/ir
+sh tests/osc_gpu/om_diff.sh seed/out/omc build/osc_gpu/om_oracle build/osc_gpu/test_osc_gpu build/osc_gpu/ir build/osc_gpu/om
+om_build: build/checker2/om/c2om sha256 cda15ebdae028b34fa4e49d1151ff3dcea6d1588fd8e6f9ed36adaaa343c5d46
+om_diff: omc 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f
+om_diff: c9f4e2068899b291fad4104bb214961be974798d549ca6d8f8fad20b7b194c3e  seed/oscgpu/oscir.om
+om_diff: 1dd4c97662ba74093a938e63281e467ea69cf7244de26288f9d54348b496dd79  seed/oscgpu/gpuir.om
+om_diff: 425fa68ea37b6b86e61c4a070cdc46dd4effacb8880e645d80c7b297c8799d31  seed/oscgpu/gpulow.om
+om_diff: 84797b27c32f79935107dd8e6bc52aab38c6c533c92f99830cbed27252039633  seed/oscgpu/gpuemit.om
+om_diff: c3586e38e27337eea9526ee6142187edf83c17ddeb620296276a92f96a825fa6  seed/oscgpu/gpumain.om
+om_diff: dbf619ac365fe5e30ca81ad76ecae4b5c6d92b2b74b468e8f69060fe403ded58  gpu
+om_diff: corpus 15 units x names x mutants 0..8: n=270
+om_diff: damaged units and usage: n=9
+corpus kernel: 15
+corpus badkernel: 6
+corpus repo: 1
+corpus gen: 3995
+corpus pfx: 1365
+corpus flip: 672
+OMDIFF PASS n=6054 same=6054 diff=0
+om_diff: log build/checker2/om/omdiff.log
+OMDIFF PASS cases=21627 differ=0
+om_diff: variants: n=26275
+om_diff: embedded gate.omegese gate fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230
+om_diff: test_osc_gpu: OMBYTES identical=119 differ=0
+OMDIFF PASS n=26556 same=26556 diff=0
+rc=0
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-omegese.log b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-omegese.log
new file mode 100644
index 000000000..01c6574d5
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/host-test-omegese.log
@@ -0,0 +1,35 @@
+bash tools/omegese/test_omegese.sh /home/drakestapleton/work/C1Land/omega/build/omegese/omegese /home/drakestapleton/work/C1Land/omega/build/omega_emit/omega_emit /home/drakestapleton/work/C1Land/omega/build/checker2/checker2
+dev: 10/10 omegese -> omega_emit -> checker2 ACCEPT
+nested: 6/6 rewritten dev programs and 5/5 trial-2 model answers ACCEPT; trial-2 dev07 refused for its extra value
+review fixes: stacked conversions convert; brackets around a for count change nothing
+coverage: 8/8 accepted
+next: 69 prefixes give the expected words
+refusals: 46/46 refused with the expected reason, every control accepted
+loop guard: mutant without the counter increment REJECTED (C2-LOOP-UNBOUNDED)
+tokenizer gate: SKIPPED (set OMEGESE_TOKCOUNT and OMEGESE_TOKENIZER)
+next oracle: every word and the end of input legal at all 2636 word boundaries of 75 accepted programs
+completeness: 150 single-word mutants (17 accepted by emit): emit accepts iff every word was legal (2958 word boundaries)
+soundness fuzz: 40/40 random walks (852 legal items picked) never met an empty set and closed into accepted programs
+checker2 residual: 0 of 80 completed walks that emit accepts are rejected later (omega_emit or checker2)
+truncation fuzz: 2799 byte prefixes through emit, next and next --machine, exit 0 or 1; at the 2698 prefixes of accepted programs, next allows the byte that follows and complete finishes into a program emit accepts
+test-omegese: PASS
+OMEGESE_SANITIZED=1 OMEGESE_CANARIES="/home/drakestapleton/work/C1Land/omega/build/omegese/omegese_canary1 /home/drakestapleton/work/C1Land/omega/build/omegese/omegese_canary2" \
+OMEGESE_WALKS=10 OMEGESE_MUTANTS=1 \
+bash tools/omegese/test_omegese.sh /home/drakestapleton/work/C1Land/omega/build/omegese/omegese_asan /home/drakestapleton/work/C1Land/omega/build/omega_emit/omega_emit /home/drakestapleton/work/C1Land/omega/build/checker2/checker2
+sanitizers: 2/2 canaries caught (read after free, signed overflow)
+dev: 10/10 omegese -> omega_emit -> checker2 ACCEPT
+nested: 6/6 rewritten dev programs and 5/5 trial-2 model answers ACCEPT; trial-2 dev07 refused for its extra value
+review fixes: stacked conversions convert; brackets around a for count change nothing
+coverage: 8/8 accepted
+next: 69 prefixes give the expected words
+refusals: 46/46 refused with the expected reason, every control accepted
+loop guard: mutant without the counter increment REJECTED (C2-LOOP-UNBOUNDED)
+tokenizer gate: SKIPPED (set OMEGESE_TOKCOUNT and OMEGESE_TOKENIZER)
+next oracle: every word and the end of input legal at all 2636 word boundaries of 75 accepted programs
+completeness: 75 single-word mutants (12 accepted by emit): emit accepts iff every word was legal (1496 word boundaries)
+soundness fuzz: 10/10 random walks (188 legal items picked) never met an empty set and closed into accepted programs
+checker2 residual: 0 of 80 completed walks that emit accepts are rejected later (omega_emit or checker2)
+truncation fuzz: 2799 byte prefixes through emit, next and next --machine, exit 0 or 1; at the 2698 prefixes of accepted programs, next allows the byte that follows and complete finishes into a program emit accepts
+sanitizers: no ASan or UBSan report in the whole run
+test-omegese: PASS
+rc=0
diff --git a/evidence/omegese-gpu/chip-20261027T1630Z-om/omchip-SHA256SUMS b/evidence/omegese-gpu/chip-20261027T1630Z-om/omchip-SHA256SUMS
new file mode 100644
index 000000000..31d58a4d1
--- /dev/null
+++ b/evidence/omegese-gpu/chip-20261027T1630Z-om/omchip-SHA256SUMS
@@ -0,0 +1,252 @@
+bafb653aecbf8f5658d1234590a3551b65999f70bb25fc332420a21644b84e3c  gate__m0.code
+4e07936d1fdddfad3c96eca7ae308e31251a509c10fd86a19d2a4112af5b1756  gate__m0.man
+7c55bc3718099f466285b1e698fc7ae440f010717769b6e1fcefe76cda51b1b4  gate__m1.code
+a47245b4f5d67635e46789998c02e60c3326e4c5e12f5a38f516c17ba43da77e  gate__m1.man
+6afc3b6dc2c5fb459322f5248bae367da0c68da0e81462841be083e2d3ae6c01  gate__m2.code
+0c2345f28450098c37fe206fc0e3c686cd54f41e769cbcbd7c897fe136dff823  gate__m2.man
+7dac5f20417664863c794525545cc67c47af12ce5e6b3cf19b62da96223aa9aa  gate__m3.code
+6992379f3f9904a6aa9da55d5f8cdc313a40d83fce6261dfeb7bf72621f72389  gate__m3.man
+bafb653aecbf8f5658d1234590a3551b65999f70bb25fc332420a21644b84e3c  gate__m4.code
+4e07936d1fdddfad3c96eca7ae308e31251a509c10fd86a19d2a4112af5b1756  gate__m4.man
+bafb653aecbf8f5658d1234590a3551b65999f70bb25fc332420a21644b84e3c  gate__m5.code
+4e07936d1fdddfad3c96eca7ae308e31251a509c10fd86a19d2a4112af5b1756  gate__m5.man
+bafb653aecbf8f5658d1234590a3551b65999f70bb25fc332420a21644b84e3c  gate__m6.code
+4e07936d1fdddfad3c96eca7ae308e31251a509c10fd86a19d2a4112af5b1756  gate__m6.man
+268d987996af4c1884856092941a2556de0a5a9283395f5a8839305253b78cef  gate__m7.code
+8adb4fdb8c5becc7428ab8e29ceea4336a2ae651d95fd5bf693498fab1b6e477  gate__m7.man
+bafb653aecbf8f5658d1234590a3551b65999f70bb25fc332420a21644b84e3c  gate__m8.code
+4e07936d1fdddfad3c96eca7ae308e31251a509c10fd86a19d2a4112af5b1756  gate__m8.man
+014348e111b3035ac47c418a9f02a58903c29e598d7977de4b5c51cc6088ac51  gemm__m0.code
+a204af97940284043aaa272a2a3cb300301999852663ce78e03520c861ec32c4  gemm__m0.man
+8809362a1883ab690d107f2056b58d924c2bb5f72901e2dca5f7495626f4a912  gemm__m1.code
+c93165dc5f73410cf317ce88dc78c6f7ebf3b38ff00ce4e6b55a627439de88d9  gemm__m1.man
+98c10c7585af21575044fc63385f6eb391b2f8f7c0508c34b2f42fe0022c482d  gemm__m2.code
+92a2e02c170110d8f500e0fe0ea76a696e06ea787d2fbcf6b38db4076f2006fb  gemm__m2.man
+1b2822403847d5be4220406709dabad4f6d840b2a8364832251de92a6492225f  gemm__m3.code
+d71260192dfa4bc8e8abbf7d5f878bde82d3981665270dc47a73acdd9b96324e  gemm__m3.man
+f92e1bb3afae6f07007edfede21d2f8703028ff332f213ba92e4e82e72b95b17  gemm__m4.code
+26454916df2470adfc78766582bf4f7fbba33c6fa0ce993ec1ec35fe4c2c7538  gemm__m4.man
+014348e111b3035ac47c418a9f02a58903c29e598d7977de4b5c51cc6088ac51  gemm__m5.code
+a204af97940284043aaa272a2a3cb300301999852663ce78e03520c861ec32c4  gemm__m5.man
+1e64dc798b073c4d377e9d739aa12a35341f323d0fbbd38f597ebd82eb506aeb  gemm__m6.code
+409eedc17cc8eaac3380f38b0211751fc340cf72df31823b84cea9a333b4a995  gemm__m6.man
+94be52ba2e48c3ca29253204efd5e23697203698eabac0ead23a05e6a0ea5246  gemm__m7.code
+0f8d265928596adf50cf8ca191ab5c3e24e329e5d7739ca93cacdf1774635b4b  gemm__m7.man
+014348e111b3035ac47c418a9f02a58903c29e598d7977de4b5c51cc6088ac51  gemm__m8.code
+a204af97940284043aaa272a2a3cb300301999852663ce78e03520c861ec32c4  gemm__m8.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m0.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m0.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m1.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m1.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m2.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m2.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m3.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m3.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m4.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m4.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m5.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m5.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m6.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m6.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m7.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m7.man
+440e084b2e1210748a714c7a1bd25543f3bc705db7a83052de9a64efa44e877d  nest16__m8.code
+aeb11d34d339ab9e6fb9b27119e2d7cde6818fe8cf51b0a4fc79a2b2d08ae586  nest16__m8.man
+89660cb91a57c2128556be001916759d77ab62915ad184289683a236a41bf4ff  nest16j__m0.code
+d7c707570effc6eaebf71b1259094101d2fbeeb52206e97dc4fc98de16e9ef0d  nest16j__m0.man
+20cd0f48501dd5de797a0bc4ff33fe7270bfbc514197728688003b70d9fe109a  nest16j__m1.code
+1df2c9abc164ad7f956d9fbb2df4a203a71b929eaa6191dca507cd36fdb87a03  nest16j__m1.man
+9ffe92cc3d5d1b83438c77b1c71f8d4cf90f590ebe96ea43fdbf78b38ae87de7  nest16j__m2.code
+8ecc67985e3b9c7d4c6ae1d7fdc036a4fb403c58b6fde0b1bb453d639e56b444  nest16j__m2.man
+6739d221197aeb93166c3fe721f3252806902dd2196387bf6ce9113ca64cabb8  nest16j__m3.code
+22cf08cfcbbd68626814475289d430eaf82e031531f180970bb13fbef9aeefee  nest16j__m3.man
+89660cb91a57c2128556be001916759d77ab62915ad184289683a236a41bf4ff  nest16j__m4.code
+d7c707570effc6eaebf71b1259094101d2fbeeb52206e97dc4fc98de16e9ef0d  nest16j__m4.man
+0fff416d8275fc9d25353afa533a088af682c5b13dc4c8a6841328e51e22a601  nest16j__m5.code
+b44a79ee4c119dec39e7627c3427988e887de8c1fb3239795f1af402609b3d90  nest16j__m5.man
+89660cb91a57c2128556be001916759d77ab62915ad184289683a236a41bf4ff  nest16j__m6.code
+d7c707570effc6eaebf71b1259094101d2fbeeb52206e97dc4fc98de16e9ef0d  nest16j__m6.man
+89660cb91a57c2128556be001916759d77ab62915ad184289683a236a41bf4ff  nest16j__m7.code
+d7c707570effc6eaebf71b1259094101d2fbeeb52206e97dc4fc98de16e9ef0d  nest16j__m7.man
+89660cb91a57c2128556be001916759d77ab62915ad184289683a236a41bf4ff  nest16j__m8.code
+d7c707570effc6eaebf71b1259094101d2fbeeb52206e97dc4fc98de16e9ef0d  nest16j__m8.man
+29d4bdf7c6b3fd52ae21d5032f782c2b48e9c92f5e8c05c2ee3aeed71fc982ad  om_attn__m0.code
+f668757b85ada9968030937aebcf07437d39a7aa8f675432106965ad75cdbad8  om_attn__m0.man
+a705ac390c616ae8fab0186f227b4e7a29efdce9f3ee0360542c236415803dc3  om_attn__m1.code
+3e573fb455c7a77afc31788b64ffa2e9199821e5f9cbd3dc025497c96b4fe59e  om_attn__m1.man
+a58740711f4462e09ee8b85af6259688906a01a9bbaba94a08515a1833ae4730  om_attn__m2.code
+eeefbb91596c4bb32f681a9199ef088842b095b9c9c8f0f9ed8668b6f74a6f9a  om_attn__m2.man
+79bbb16121f57748cecdf8b03135a5ac537086d6b7fd0e28a8859692871cdf9b  om_attn__m3.code
+adf614c256451a181a10dae7de45765d04bd8008b68a9910506959b8cbf28322  om_attn__m3.man
+997d6704360539e283bdfd7219a19af88dccfcaf1e9bb7166a2ca533b9e4afd5  om_attn__m4.code
+dafcefc30c679f13cb09cb3634a42df2e714aa83899ddd7a7dacaadc3e557c6a  om_attn__m4.man
+29d4bdf7c6b3fd52ae21d5032f782c2b48e9c92f5e8c05c2ee3aeed71fc982ad  om_attn__m5.code
+f668757b85ada9968030937aebcf07437d39a7aa8f675432106965ad75cdbad8  om_attn__m5.man
+1cdffa8ba5394ff76c324e68d86a7b4da3efaef0fda855018721d88c4db5ad51  om_attn__m6.code
+742a5d64cc0836aba64a177a0aafa281b07212ee34c107dbbfa54a23b240cc5f  om_attn__m6.man
+b2550757432626b42daae515a67b77b021cb9236a96d55676308297dc8e2edac  om_attn__m7.code
+6d9586adb879b918f8e9267a872cf7cf485def18793e43006817bb17e42d3372  om_attn__m7.man
+29d4bdf7c6b3fd52ae21d5032f782c2b48e9c92f5e8c05c2ee3aeed71fc982ad  om_attn__m8.code
+f668757b85ada9968030937aebcf07437d39a7aa8f675432106965ad75cdbad8  om_attn__m8.man
+fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230  om_gate__m0.code
+a873a61e8b099ebfacb6d89eef0205d6a6c568876ac34b77a56546efda460fdb  om_gate__m0.man
+7f8ce780053d9b17854ba58926ebf07e84ec248c233eb7e4afe8c16ff0e152b9  om_gate__m1.code
+6193fd75d7472d67fc1c478186bb8631c546164b1f95cf3af4638ef3da6056fb  om_gate__m1.man
+12bd5fac76d3748543e45898cf6bdf40aaf3ef683d9de881df78f0ffc3b49689  om_gate__m2.code
+d805dfa4e2241206aeace9422942e33be492044be5cd85ac9ea59da9807d2537  om_gate__m2.man
+898fc21db583fabe6452364d010f43fc4e0fc4c5a1efd9ddf94eaaf1818c1de3  om_gate__m3.code
+084aff26727105857fd72b1eca71faaaa280d2f6133bf528cb3527df3c6c5fdf  om_gate__m3.man
+fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230  om_gate__m4.code
+a873a61e8b099ebfacb6d89eef0205d6a6c568876ac34b77a56546efda460fdb  om_gate__m4.man
+fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230  om_gate__m5.code
+a873a61e8b099ebfacb6d89eef0205d6a6c568876ac34b77a56546efda460fdb  om_gate__m5.man
+fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230  om_gate__m6.code
+a873a61e8b099ebfacb6d89eef0205d6a6c568876ac34b77a56546efda460fdb  om_gate__m6.man
+8bb50eddf22d31ea9ac3197326159c8aecb11c90061be331843d927aeb74fc9e  om_gate__m7.code
+2929e4b1dd16cf70c7000e1cdbc1e6ac8379ea87bdf31695976931299731cd03  om_gate__m7.man
+fabdfc55cf9d67bc608ae066e5c63b69f7d779f379dbf558d392ad668605d230  om_gate__m8.code
+a873a61e8b099ebfacb6d89eef0205d6a6c568876ac34b77a56546efda460fdb  om_gate__m8.man
+4279a294b3978673f987f43f316f5b0e72e19e15c7518084679ed71151520209  om_gemm__m0.code
+77a88d9e187d9f2d3c4294967989850c2063eb69becb1a78da3ed02f8a86a492  om_gemm__m0.man
+10c0efd53cdd4f4e44cbfb65991f3c0af3f9526d44abc9a87633ea0d1a6e3d05  om_gemm__m1.code
+24830b48a80b425fc165a3315c995f6a1ade2c3b9576c75474cfbe1654e768b1  om_gemm__m1.man
+291583c264e181067a2bc7d3cc2b15b4717a60fea4ce76b700f28c9e72056a47  om_gemm__m2.code
+96561e740c7e51583cec3582e875d1eb0eac2ae2fb2a905a17c9a0aaba2a2fc2  om_gemm__m2.man
+6d25b0335be6674b128f24bc040a0c32fe00559fc50f037eb184ea674f89e9c2  om_gemm__m3.code
+4c1841c72c5a44392a14c6c5c6a5f00c15a65a5ae3d0b0574655f4dcbce8485f  om_gemm__m3.man
+65f116836ae2f0494ab3434edb295639809099e13827dea3974ebc8c206d7334  om_gemm__m4.code
+54b5cc72ae530e3cd978af240f31ecbc209ac3632d1c51a3a8a1ea32db2936e0  om_gemm__m4.man
+4279a294b3978673f987f43f316f5b0e72e19e15c7518084679ed71151520209  om_gemm__m5.code
+77a88d9e187d9f2d3c4294967989850c2063eb69becb1a78da3ed02f8a86a492  om_gemm__m5.man
+d49204cc770c83c50918de943dc0713fa568d818f0811d3c4c882b989431ebc1  om_gemm__m6.code
+4be4a8ee21b057fc4db13300609f27123c09bef52cd6c492e6f778d7aea8d2b0  om_gemm__m6.man
+3cc2cc6357d46dba317643ef67637c571b574642bc76a3ec978ee224cff25a1e  om_gemm__m7.code
+e4de2e14c16003dfc1ddf6c30fa4f53fa5b81951adaff5ecf4188ccc9f234912  om_gemm__m7.man
+4279a294b3978673f987f43f316f5b0e72e19e15c7518084679ed71151520209  om_gemm__m8.code
+77a88d9e187d9f2d3c4294967989850c2063eb69becb1a78da3ed02f8a86a492  om_gemm__m8.man
+9fe7d8d8f5034ab57713a7a20572e6bacd64ca1131340e4840acb90b6b2c5d72  om_vadd__m0.code
+f990372312627c244104f1882c755b331c779f0709eb38345e0d5bda76ff2571  om_vadd__m0.man
+74d99bc73d450e8c50ea3aca05507923725a2daf974965c00dd8da4aff0aa0e0  om_vadd__m1.code
+b8c77466992c7053b812dc0708cde134f710579dbf26692dbc4797f4c4c9acfc  om_vadd__m1.man
+05072534d0c477d3d14af4d2cdd7d3cd87ba80a16de1c83892450dc4acab6884  om_vadd__m2.code
+9b57e32f9b96c10e787587b6e22702d03df98136fad2fc59635dbffd3a75e2bb  om_vadd__m2.man
+a3e1c88bb0c5f9e519bc86cf7ba34be7b72b48f186a05304ff26b1d948bd9d40  om_vadd__m3.code
+d45eeee878cdefd7ee904b1d3d3911cdb19b1ba666d604ac6f5b19a89180119f  om_vadd__m3.man
+9fe7d8d8f5034ab57713a7a20572e6bacd64ca1131340e4840acb90b6b2c5d72  om_vadd__m4.code
+f990372312627c244104f1882c755b331c779f0709eb38345e0d5bda76ff2571  om_vadd__m4.man
+9fe7d8d8f5034ab57713a7a20572e6bacd64ca1131340e4840acb90b6b2c5d72  om_vadd__m5.code
+f990372312627c244104f1882c755b331c779f0709eb38345e0d5bda76ff2571  om_vadd__m5.man
+9fe7d8d8f5034ab57713a7a20572e6bacd64ca1131340e4840acb90b6b2c5d72  om_vadd__m6.code
+f990372312627c244104f1882c755b331c779f0709eb38345e0d5bda76ff2571  om_vadd__m6.man
+e9b9c68a329f5208a35ddc341f4830f6b500f89c15a6a775be52778a79f4d8f0  om_vadd__m7.code
+63889044489259e93d0caa8448ccd484b77429febcb56ff2734099d580e7a493  om_vadd__m7.man
+9fe7d8d8f5034ab57713a7a20572e6bacd64ca1131340e4840acb90b6b2c5d72  om_vadd__m8.code
+f990372312627c244104f1882c755b331c779f0709eb38345e0d5bda76ff2571  om_vadd__m8.man
+8b9f35d5dc259888027d97dfe7b39aad2880caec98a2e26e89a6a4e976bd6aa1  ops_f__m0.code
+824583e8c915748124460eb4754ef55ab87185ce684b65cdde553ad4856d0774  ops_f__m0.man
+32b6e741905edea4a6af371a208c7551e85e8f57f76531b3656c76b7c78d24a6  ops_f__m1.code
+e8621a8f7f5719e0b09267a64b940eebfe4774a1bc27df8848a1f045b3ee447e  ops_f__m1.man
+8b9f35d5dc259888027d97dfe7b39aad2880caec98a2e26e89a6a4e976bd6aa1  ops_f__m2.code
+824583e8c915748124460eb4754ef55ab87185ce684b65cdde553ad4856d0774  ops_f__m2.man
+8b9f35d5dc259888027d97dfe7b39aad2880caec98a2e26e89a6a4e976bd6aa1  ops_f__m3.code
+824583e8c915748124460eb4754ef55ab87185ce684b65cdde553ad4856d0774  ops_f__m3.man
+665d012e430a3aa392eee27153ed86a847b0241ee87a11b39a2e3cfa2c37e733  ops_f__m4.code
+98c1d4fff7437521acfa64de0e3431907f1d05b4d88ec0673e8e68333debc6f2  ops_f__m4.man
+8b9f35d5dc259888027d97dfe7b39aad2880caec98a2e26e89a6a4e976bd6aa1  ops_f__m5.code
+824583e8c915748124460eb4754ef55ab87185ce684b65cdde553ad4856d0774  ops_f__m5.man
+daa72cc27700570ba4fbb52c4334e1af78a4ddbaedf8ac43a4e4cbf2a842328a  ops_f__m6.code
+43e118383511cbe44a1d4ae869dfac03cf80fa76e38e57c681cbb8c085dc66bc  ops_f__m6.man
+31685e246908c2533349bc48d20cb2aa2323eec36412d22da92f1b9ae8638b7c  ops_f__m7.code
+a0b8b13fbea1ec6d377a122e6f1a5d37d24fdb975595465ab1f8dd325a7c7f5b  ops_f__m7.man
+8b9f35d5dc259888027d97dfe7b39aad2880caec98a2e26e89a6a4e976bd6aa1  ops_f__m8.code
+824583e8c915748124460eb4754ef55ab87185ce684b65cdde553ad4856d0774  ops_f__m8.man
+ba57adfbec1590117b61558d5a6b3b58a1471856cd2245730515ea985a3d857d  ops_u__m0.code
+ef918f9e0531a54613757a43f71e9a319a9ea3033b2909ab0d9c6bff34c40ede  ops_u__m0.man
+014ef32753c0d7d0f47f762f57a08a9b6ad8bdf9f2f4012840d187fd3737fd49  ops_u__m1.code
+c51f036993a8e26b027d39b98c17bb8f5bc6bacfbd1f8ff399ae0239cda41b4c  ops_u__m1.man
+67ed0afcdbf0c90c25cb502bc4c26a46d508301f88f6df14df19d6663b4a8fbb  ops_u__m2.code
+28740c083c336401918801e79a21958a8ebe4e076d7fe605e05ef83152980cb0  ops_u__m2.man
+42c1283f65f161cc89485ab7f0adfca36b6aa440319d52db7c17210d21b5c0e3  ops_u__m3.code
+a2c8af539aadac375bcdcf4906b7c1aabfab16ad5497dbf5570f21fb8c3b04e0  ops_u__m3.man
+6b1abd4e87e606408cd010b4c082e1487cf9a24a618d69b52de61ca4e2e3d2b7  ops_u__m4.code
+3b2ab59bc8af8375446fc76aacfb6b1126770657f83d4e9f064f05303c74bdba  ops_u__m4.man
+ba57adfbec1590117b61558d5a6b3b58a1471856cd2245730515ea985a3d857d  ops_u__m5.code
+ef918f9e0531a54613757a43f71e9a319a9ea3033b2909ab0d9c6bff34c40ede  ops_u__m5.man
+ba57adfbec1590117b61558d5a6b3b58a1471856cd2245730515ea985a3d857d  ops_u__m6.code
+ef918f9e0531a54613757a43f71e9a319a9ea3033b2909ab0d9c6bff34c40ede  ops_u__m6.man
+6d2c44c3771493c0816697d99a3a9aaef614a3249bff174c784a1533e26ee624  ops_u__m7.code
+ded271f97161d1de5b15979adfe38a895a2887935d2a1b7f79bd138c068b7855  ops_u__m7.man
+15cfe65ec21e746b68a82db77d763ed1232bf86059201322407bbb01e6dc8f83  ops_u__m8.code
+20d42d2b57bf470354d5be891f21ffa73c6a44724c86d2ac82c645af164f07ae  ops_u__m8.man
+ceccdd773d94b0eb74ea9e99a25dd4c98e2c33003d119217b744da20082c6c52  reduce__m0.code
+af9a731860bf3c35600acf0e385db191aa0675541d9f5c1aff57b12377e65710  reduce__m0.man
+c234fb08276c7fd613edb0e798a60005f7e66e67e1dbb11c0364b06675f11c66  reduce__m1.code
+f1666765beb28041b565d46de0e168dbfec9dd110be5a8a41fc3875433f54b80  reduce__m1.man
+d58063ee6075332eb152396c5a41af3c824a9b67a6f6fea3f69323ed7410ea23  reduce__m2.code
+173b1f3c1c20ba289ab5140651dc6d815acc65a0f9abf831a2aa30b5438291bc  reduce__m2.man
+c5d89533d0a7283a6b3ad55b3b1e900f76203f8efcd52aaab450d13b8dce25a8  reduce__m3.code
+9f9a5723bd365cc2baccdf195421a498285e3444191350dde0f81bb862b16da5  reduce__m3.man
+c3e477a231b77baad492596e7bb518b294fce1fb3b3584e2d35210a1cd1da304  reduce__m4.code
+82b5195c51c9822157513654fa27c0b72548fe631077ed90fa3055fb63ae93a0  reduce__m4.man
+ceccdd773d94b0eb74ea9e99a25dd4c98e2c33003d119217b744da20082c6c52  reduce__m5.code
+af9a731860bf3c35600acf0e385db191aa0675541d9f5c1aff57b12377e65710  reduce__m5.man
+d221c360f0c2da58025c15606ba580710dd35bc86c136227f2ee183f6fcb7e8b  reduce__m6.code
+42dce4939f5f1b00fb38735985937376d88c33c50213f87f48a928bd86d9abed  reduce__m6.man
+792626c3e53db9a4686932e93b264f433cffd6885d8478120aa7686c9da3c761  reduce__m7.code
+a69cd08f5b0362cfb9960c7f43acc1566ec2ee43018de7b9c09c0356a5f9ef2c  reduce__m7.man
+ceccdd773d94b0eb74ea9e99a25dd4c98e2c33003d119217b744da20082c6c52  reduce__m8.code
+af9a731860bf3c35600acf0e385db191aa0675541d9f5c1aff57b12377e65710  reduce__m8.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m0.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m0.man
+23463104d8a1d73cacb8bda5fe6be6b98001d4de61b922f9ae0a6b875924e178  rows__m1.code
+eae91bb8b1e94b3651d7b262969b1173d507280d2ca2863e8f4c98ed0cd55ba3  rows__m1.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m2.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m2.man
+b1899265290ace8ca16cba12128faed8e9bc6e9faed490f6e8fc920f846c7b88  rows__m3.code
+c574c39eef4dd93ac1b70401dc4fd204788c86e303fc55228756460f1ad4586e  rows__m3.man
+afb71e0a94aa703314928cc33e852dbb9f242780e635756eb604d9e437e1dbe5  rows__m4.code
+72195d2f75fa8d267188c24b636ad95848e9cc8e325ecb25b35b97d93dd0bf53  rows__m4.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m5.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m5.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m6.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m6.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m7.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m7.man
+5fbf516665889836ac8ae0e4da2ac0dc3460f46a75c1a5c0b15747c56be4cfa9  rows__m8.code
+229f1d3e2d7a4465f3f908deae748ae971ca4cfa45fee40707ccbdb2276d7096  rows__m8.man
+a2c83ac4c56dd1e26ea1f1820be870cc0282df7153fb1c3018bfee24cf4ca6ed  vadd__m0.code
+56abc0e1f3d64ce8875619a41886505eccf26ccb4b2ba9814d66b86be3de0bfe  vadd__m0.man
+fdc2b88b308ee8ac0ed4bb60d586ee11713b4e9fc1c25cf35514ce49098fede2  vadd__m1.code
+bb7ece27f6b9d7bb15049202f1154b654df85744ec89b60011379d8a1317a553  vadd__m1.man
+f98c8a42107c42a061c7bb3e92cbd090d1a8460ad559e68d3921ffafd69df339  vadd__m2.code
+ea21a928569abe9139842a9be303158da0868c6c12472e58300573d27755185a  vadd__m2.man
+e2adde54b5712d548390aff32bf09af113b0cf64de81bb0ff7a51375b8da2dc1  vadd__m3.code
+ba4308a9d327730d6b76492e62565cbae64ee79dbb7e2350d343b2ccc2debbc3  vadd__m3.man
+a2c83ac4c56dd1e26ea1f1820be870cc0282df7153fb1c3018bfee24cf4ca6ed  vadd__m4.code
+56abc0e1f3d64ce8875619a41886505eccf26ccb4b2ba9814d66b86be3de0bfe  vadd__m4.man
+a2c83ac4c56dd1e26ea1f1820be870cc0282df7153fb1c3018bfee24cf4ca6ed  vadd__m5.code
+56abc0e1f3d64ce8875619a41886505eccf26ccb4b2ba9814d66b86be3de0bfe  vadd__m5.man
+a2c83ac4c56dd1e26ea1f1820be870cc0282df7153fb1c3018bfee24cf4ca6ed  vadd__m6.code
+56abc0e1f3d64ce8875619a41886505eccf26ccb4b2ba9814d66b86be3de0bfe  vadd__m6.man
+d37ac2c4e8d1ccff2eaf15edeae9dfc357f21df3110fac3c1a0fd344f303479d  vadd__m7.code
+390f98706281e47ce1d394178e205b1745b049fea86783eccb1a13b5d078f528  vadd__m7.man
+a2c83ac4c56dd1e26ea1f1820be870cc0282df7153fb1c3018bfee24cf4ca6ed  vadd__m8.code
+56abc0e1f3d64ce8875619a41886505eccf26ccb4b2ba9814d66b86be3de0bfe  vadd__m8.man
+29dac0d3190c0408577a47b5204fdb2d3e03eabe1e3210eb6fc01bbd8d418185  vloop__m0.code
+4f6026ba5a33218edc7b2c1c4add0744137ecfd62773b44839a747708cc9ffeb  vloop__m0.man
+ea065a612dcd94fc1a0918a278f117f65798350a4ca071d3735093496fffb5ba  vloop__m1.code
+ab733c448607430b2913c42f3211b94ec9f38a5fdca27020f46c349080df92a8  vloop__m1.man
+d0ffc5835778b6aa7be1db8f7784ffafbf33992881658361e1105b328bc1d07a  vloop__m2.code
+f83e8717dc5e56b626dfc4a28d196dc511e48ffe6d7e8a87dbe977ea6fa7f8f0  vloop__m2.man
+ca593b4d37ff1a7ddbbed03eda828fa017bfdc49f1787605dd9098f47df06452  vloop__m3.code
+e24a83b19777b7e153bc823b79f777614eaa8b5a7081c59cc17b98a4a573af2c  vloop__m3.man
+885d70620ee010496837bdc5e240b376d78f93e79429e9833ffbc81ed493df55  vloop__m4.code
+8727863ee763449bc0a8b0fc9bd284dcabb451078e056b48f22da3dee4578477  vloop__m4.man
+29dac0d3190c0408577a47b5204fdb2d3e03eabe1e3210eb6fc01bbd8d418185  vloop__m5.code
+4f6026ba5a33218edc7b2c1c4add0744137ecfd62773b44839a747708cc9ffeb  vloop__m5.man
+29dac0d3190c0408577a47b5204fdb2d3e03eabe1e3210eb6fc01bbd8d418185  vloop__m6.code
+4f6026ba5a33218edc7b2c1c4add0744137ecfd62773b44839a747708cc9ffeb  vloop__m6.man
+5b417eec05efefa526cef396c64b5ba83d6a2302a7f3fe88be9b17673d096e24  vloop__m7.code
+ff9c3cf9b00ea247b760883a2339fc257d57f8acca8d309e9d7ba085b78113ef  vloop__m7.man
+29dac0d3190c0408577a47b5204fdb2d3e03eabe1e3210eb6fc01bbd8d418185  vloop__m8.code
+4f6026ba5a33218edc7b2c1c4add0744137ecfd62773b44839a747708cc9ffeb  vloop__m8.man
diff --git a/evidence/omegese-gpu/front/embedded-green.log b/evidence/omegese-gpu/front/embedded-green.log
new file mode 100644
index 000000000..979b6db16
--- /dev/null
+++ b/evidence/omegese-gpu/front/embedded-green.log
@@ -0,0 +1,6 @@
+$ sh tests/osc_gpu/run.sh <dev omegese omega_emit checker2 test_osc_gpu> /tmp/l386b/rw <dev osc_gpu_build>   (2026-10-22T00:28:01Z, dev build of this branch)
+run.sh: 13 kernels emitted and accepted by checker2
+run.sh: 12 broken kernels refused with their expected reasons
+run.sh: 1 embedded kernels still build to the bytes they embed
+test_osc_gpu: 1308 checks, 0 failed
+exit 0
diff --git a/evidence/omegese-gpu/front/embedded-red.log b/evidence/omegese-gpu/front/embedded-red.log
new file mode 100644
index 000000000..2b2a50eb4
--- /dev/null
+++ b/evidence/omegese-gpu/front/embedded-red.log
@@ -0,0 +1,5 @@
+red control: EMBEDDED sha changed by one hex digit (dc6f17bd -> dc6f17be), same command
+run.sh: 13 kernels emitted and accepted by checker2
+run.sh: 12 broken kernels refused with their expected reasons
+FAIL: gate.omegese builds to code sha256 dc6f17bd96eb065703035fee02133df0c250183930b1db34b7fadf81be45ffb6, but omega branch omegese/gate-lever src/omega_q36_om_gate.h (the 35B decode gate, AIEN_OMEGA_Q36_OMEGESE_GATE=1) embeds dc6f17be96eb065703035fee02133df0c250183930b1db34b7fadf81be45ffb6
+exit 1
diff --git a/evidence/omegese-gpu/front/red-host-refuses-kernel.log b/evidence/omegese-gpu/front/red-host-refuses-kernel.log
new file mode 100644
index 000000000..4f823d654
--- /dev/null
+++ b/evidence/omegese-gpu/front/red-host-refuses-kernel.log
@@ -0,0 +1,2 @@
+red: tests/osc_gpu/test_osc_gpu.c linked with the previous src/compiler/osc_cg.c and osc_interp.c (no kernel refusal), 2026-10-22T00:09Z
+exit 134 (134 = abort: the old interpreter or code generator crashed on a kernel unit instead of refusing it)
diff --git a/evidence/omegese-gpu/front/test-omegese.log b/evidence/omegese-gpu/front/test-omegese.log
new file mode 100644
index 000000000..9c3f901ab
--- /dev/null
+++ b/evidence/omegese-gpu/front/test-omegese.log
@@ -0,0 +1,16 @@
+$ bash tools/omegese/test_omegese.sh omegese omega_emit checker2   (omegese from this commit's tools/omegese/omegese.c)
+dev: 10/10 omegese -> omega_emit -> checker2 ACCEPT
+nested: 6/6 rewritten dev programs and 5/5 trial-2 model answers ACCEPT; trial-2 dev07 refused for its extra value
+review fixes: stacked conversions convert; brackets around a for count change nothing
+coverage: 8/8 accepted
+next: 69 prefixes give the expected words
+refusals: 46/46 refused with the expected reason, every control accepted
+loop guard: mutant without the counter increment REJECTED (C2-LOOP-UNBOUNDED)
+tokenizer gate: SKIPPED (set OMEGESE_TOKCOUNT and OMEGESE_TOKENIZER)
+next oracle: every word and the end of input legal at all 2636 word boundaries of 75 accepted programs
+completeness: 150 single-word mutants (17 accepted by emit): emit accepts iff every word was legal (2958 word boundaries)
+soundness fuzz: 40/40 random walks (852 legal items picked) never met an empty set and closed into accepted programs
+checker2 residual: 0 of 80 completed walks that emit accepts are rejected later (omega_emit or checker2)
+truncation fuzz: 2799 byte prefixes through emit, next and next --machine, exit 0 or 1; at the 2698 prefixes of accepted programs, next allows the byte that follows and complete finishes into a program emit accepts
+test-omegese: PASS
+exit 0
diff --git a/evidence/omegese-gpu/front/test-osc-gpu-host.log b/evidence/omegese-gpu/front/test-osc-gpu-host.log
new file mode 100644
index 000000000..371ee71c7
--- /dev/null
+++ b/evidence/omegese-gpu/front/test-osc-gpu-host.log
@@ -0,0 +1,29 @@
+$ sh tests/osc_gpu/run.sh omegese omega_emit checker2 test_osc_gpu ir   (2026-10-22T00:09Z, tree 98b21bca + this commit's working tree; gcc 13, -O2 -ffp-contract=off)
+run.sh: 13 kernels emitted and accepted by checker2
+run.sh: 12 broken kernels refused with their expected reasons
+  division by a number: 5899975 quotients checked
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  gemm    248 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  reduce  192 instructions,  24 registers, 256 threads, 8224 shared bytes, 2 regions on 1 barriers, 12 argument words
+  nest16  112 instructions,  16 registers, 32 threads, 0 shared bytes, 0 regions on 0 barriers, 8 argument words
+  ops_u   624 instructions,  32 registers, 256 threads, 0 shared bytes, 16 regions on 1 barriers, 24 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  nest16j 288 instructions,  16 registers, 32 threads, 0 shared bytes, 16 regions on 16 barriers, 8 argument words
+  vloop    80 instructions,  24 registers, 64 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_gate     72 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 12 argument words
+  om_gemm    256 instructions,  40 registers, 256 threads, 2048 shared bytes, 1 regions on 1 barriers, 16 argument words
+  om_attn    248 instructions,  48 registers, 128 threads, 16 shared bytes, 1 regions on 1 barriers, 22 argument words
+  ops_f   208 instructions,  32 registers, 256 threads, 256 shared bytes, 0 regions on 0 barriers, 20 argument words
+  vadd     64 instructions,  24 registers, 256 threads, 0 shared bytes, 1 regions on 1 barriers, 16 argument words
+  mutant 1 (stores ignore poison): caught by 16 checks
+  mutant 2 (joins dropped): caught by 52 checks
+  mutant 3 (no add overflow trap): caught by 5 checks
+  mutant 4 (intervals not stretched): caught by 10 checks
+  mutant 5 (every region on barrier 0): caught by 3 checks
+  mutant 6 (shared not zeroed): caught by 2 checks
+  mutant 7 (bounds-failed loads run): caught by 4 checks
+  mutant 8 (division magic off by one): caught by 4 checks
+test_osc_gpu: 1308 checks, 0 failed
+exit 0
diff --git a/evidence/omegese-gpu/front/tokenizer-gate.txt b/evidence/omegese-gpu/front/tokenizer-gate.txt
new file mode 100644
index 000000000..e70ab71a3
--- /dev/null
+++ b/evidence/omegese-gpu/front/tokenizer-gate.txt
@@ -0,0 +1,6 @@
+# tokenizer gate for the kernel words (L386, C1), 2026-10-22T00:08Z
+# omegese built from tools/omegese/omegese.c at 98b21bca
+$ tokcount /home/drakestapleton/models/qwen3-30b-a3b-instruct-2507-fp8/tokenizer.json words $(omegese words) bound | awk '$1 != 1'   (column 1: tokens of " word")
+words checked: 67, with more than one token: 0
+$ tokcount /home/drakestapleton/models/qwen3.6-35b-a3b-fp8-95a723d0/tokenizer.json words $(omegese words) bound | awk '$1 != 1'   (column 1: tokens of " word")
+words checked: 67, with more than one token: 0
diff --git a/evidence/omegese-gpu/review/design-review-1.md b/evidence/omegese-gpu/review/design-review-1.md
new file mode 100644
index 000000000..e1555bfaa
--- /dev/null
+++ b/evidence/omegese-gpu/review/design-review-1.md
@@ -0,0 +1,63 @@
+# Design review 1 of docs/omegese/GPU.md (c0295f31)
+
+Reviewer: Claude Opus 5.5 (read-only subagent). Fable was asked first and refused twice with its
+weekly limit ("You've hit your weekly limit, resets Oct 25"); the brief allows the best model
+available. Run 2026-10-21 about 22:30Z. The reviewer read the repo over ssh and changed nothing.
+
+I found 19 problems with the GPU kernel design. Five are blockers: the checker as designed would accept kernels that race, hang or read out of bounds. I read GPU.md at commit c0295f31, plus the IR header, the IR validator and `gen_gate`. That function is not on `omegese/gpu`; I read it from branch `alpha/decode-speed-to-main`. I changed no files and ran nothing.
+
+1. **Blocker, §6 and §9: nothing stops races on shared memory.** The rules only control where `sync` may appear. checker2 would accept `put s 0 thread`, where every thread writes the same slot. It would also accept `put s thread v` followed by `get s add thread 1` with no `sync` between. Both give output that depends on timing. Change: add a rule C2-GPU-SHARED-RACE. Split the code into phases at each `sync`, and follow back edges too, so the gap between the last read of a tile and the next loop's write is covered. Within a phase, a shared array is either read-only, or every write uses an index that gives each thread its own slot and each thread reads only its own slots. Accept a fixed set of index forms: `thread`, `add thread mul k threads` with uniform `k`, and the warp index when guarded by a lane-0 test. Tree reductions then need two arrays used in turn, or `down`.
+
+2. **Blocker, §2, §8 and §9: nothing stops races on global memory.** `put c 0 thread` passes. So does one thread reading `c[j]` that another thread or block writes in the same launch. Change: add C2-GPU-GLOBAL-RACE. Every write index must be a recognised form that is different for every (thread, block, batch). A kernel may read an `edit` buffer only at the indices that same thread writes. `sync` orders reads and writes only within a block.
+
+3. **Blocker, §8: the `same-index` proof ignores the second grid dimension.** `add mul block threads thread` repeats for every `batch`. When `batches > 1`, two blocks write the same element. The rest of the rule also has gaps:
+   - "no other thread reads it" cannot be checked as written. Require every load and store on both aliased buffers to use that one index.
+   - Allow only exact aliases (same base address, same length, same element type) and refuse partial overlaps.
+   - The launcher must refuse `same-index` launches unless `batches == 1`, or the form must include `batch`.
+
+4. **Blocker, §2 and §11: the bounds checks trust a length the caller supplies.** `len` comes from the caller's argument list. Change: the launcher takes each length from its own allocation table, or checks `len*4 <= allocation size`. Otherwise trap 3 protects nothing.
+
+5. **Blocker, §6 and §7: a thread that traps and then hits `down` (or `sync`) can hang.** The planned rule ignores trap paths, so `x = get a i` (which may trap 3) followed by `down` is accepted. On the hardware, a shuffle whose lane mask includes an exited lane is undefined, and that is not covered by the planned measurement. Change: a trapping thread does not exit. It records its code, sets a per-thread poisoned flag, and keeps running with every store disabled; a load returns 0; a loop-bound trap leaves the loop. Uniform values never depend on loaded data, so a poisoned thread still reaches every `sync` and `down` the others reach. Drop the "drain path" idea and the barrier measurement. Define the host reference as all threads in step, reporting the lowest code seen.
+
+6. **Should-fix, §6: the uniformity text in the doc is weaker than the planned checker rule.** It says code is uniform again after a varying `if`, but never says values assigned inside that `if` are varying. Copy the planned rule into the doc. Spell out that:
+   - "varying" and "divergent" are computed together and repeated until nothing changes (the IR reassigns registers, so it is not SSA).
+   - "trap paths" means blocks from which every path ends in a trap.
+   - A `ret` goes to a virtual exit node.
+
+   With those, the rule is sound.
+
+7. **Should-fix, §6: requiring whole-block uniformity for `down` is too strict.** It refuses the standard second stage of a block reduction, `if lt thread 32 { ... down ... }`. Change: add a warp-level uniformity: a value depending on `thread` only through `div thread 32`, with block size a multiple of 32, is warp-uniform, and `down` is allowed in warp-uniform regions. Also allow a shared load at a uniform index in a read-only phase to count as uniform (sound once finding 1 is in). Tiled GEMM and decode attention already fit the planned rule: guarded loads, `sync` at the join, uniform tile loops.
+
+8. **Blocker, §3: the `down` semantics are wrong for partial warps and large distances.** When `threads % 32 != 0`, the lanes past the end of the last warp do not exist. A full-mask shuffle there is undefined; it does not return the thread's own value. The hardware also uses only the low 5 bits of the distance (my recollection of the PTX spec, not checked on the chip), so `down v 33` acts as `down v 1`. Change: the launcher requires `threads % 32 == 0`, and the distance must be a number from 1 to 31.
+
+9. **Should-fix, §3: there is no shuffle that gives every lane the result.** After a `down` reduction only lane 0 holds the total. Softmax in decode attention needs the max and the sum in every lane, which today costs a shared write plus a `sync`. Change: add an all-lanes shuffle (XOR/butterfly, `swap v n`) or a broadcast-from-lane shuffle (`from v k`).
+
+10. **Should-fix, §4: NaN and denormal behaviour is not pinned down, so bit-exact host references can fail.**
+    - GPU arithmetic returns the canonical NaN 0x7FFFFFFF. The AArch64 host keeps NaN payloads unless default-NaN mode is set. The host reference must canonicalise.
+    - `neg` keeps the payload; say so.
+    - FADD and FMUL must be emitted without flush-to-zero.
+    - The MUFU fast functions flush denormals to zero, so `inv` of a denormal is +inf. Put that in §5.
+    - `ne` must compile to the unordered not-equal compare (FSETP.NEU).
+
+11. **Should-fix, §3 vs `osc_ir.h`: min/max on NaN is described only in the IR comment** ("a NaN operand gives the other operand"). Put it in §3, and add that two NaNs give 0x7FFFFFFF and that `min -0 +0` is -0 (measure the FMNMX instruction).
+
+12. **Should-fix, §4: decimal literals can be rounded twice.** Decimal to double to float can round twice. Require one correctly rounded step (ties to even), or add a hex-bits literal. State whether a leading `-` belongs to the number.
+
+13. **Should-fix, §4: there is no fused multiply-add (`mad`).** Most CUDA kernels need fused multiply-add for accuracy and speed, and the live RMS-norm kernel (`gen_res`) uses FFMA, so it cannot be reproduced bit for bit. Add `mad` in v1. It is a single rounding on both sides (FFMA on the GPU, FMADD on the host).
+
+14. **Should-fix, §2 and §3: the block size is only known at launch.** A tiled GEMM's thread rows and columns need constant `div`/`rem`. The race proofs in findings 1 and 2 need the thread range. The 32-multiple in finding 8 needs it too. Change: `kernel gemm threads 256 ...`. checker2 then knows the exact range, and the launcher enforces it.
+
+15. **Should-fix, §2 and `osc_ir.h`: the 16-parameter limit is really about 8 buffers.** OSC_MAX_KPARAMS (16) counts registers, and each buffer uses two (pointer plus length). Decode attention needs q, K, V, out, a block table, sequence lengths and scalars. Raise it to 32 registers, or count source parameters. Also state that the IR refuses `down` on bool, while the doc says `down` takes "type of v".
+
+16. **Should-fix, overall goal: missing pieces for a "full CUDA replacement".**
+    - **Needed in v1:** atomics, unsigned only (add/max/min, which are order-independent), with float atomics refused so results stay deterministic.
+    - **Roadmap (C3), but should be named:** bf16, fp16 and fp8 element types with conversion loads; vector loads (the live kernels use 128-bit global loads); tensor-core matrix multiply; sin/cos for RoPE (rotary position embedding); a third grid dimension; uniform runtime divisors.
+    - State what happens when a kernel needs more than 255 registers (refuse or spill) and when the 48 KiB shared cap is exceeded (sm_121 allows about 99 KiB).
+
+17. **Should-fix, §5: `root` means 1/sqrt.** A model will read it as sqrt and get silently wrong results. Change: make `root` = sqrt, and define the two-word form `inv root x` as one RSQ operation.
+
+18. **Nit, §3: one-letter word pairs.** `thread`/`threads`, `block`/`blocks` and `batch`/`batches` differ by one letter, and a model's slip type-checks fine. `batch` will also be read as the ML batch. Consider `row`/`rows` for the y index. Check every new word against the Qwen3 tokenizer and save the evidence; the one-token claims are not verified anywhere in the evidence folder.
+
+19. **Nit, §10: the backend refuses nesting deeper than the chip-tested reconvergence depth.** checker2 does not enforce that limit, so a kernel it accepts can still fail to compile. Mirror the cap in checker2.
+
+The gate example itself matches the live kernel. `exp neg g` gives the same bits as the live constant `C_NLOG2E` (0xBFB8AA3B), and `add 1`, `inv` and `mul a` follow the live instruction order. The only differences are the bounds against `len o` instead of a count argument (equal if the launcher sets them so) and the extra load bounds checks, which do not change the output.
diff --git a/mk/.crumb b/mk/.crumb
index 5e0bd757b..d2e5e9eec 100644
--- a/mk/.crumb
+++ b/mk/.crumb
@@ -7,14 +7,14 @@
     "generated": {
       "children": [],
       "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "compiled_at": "2026-11-05T22:54:12Z",
+      "compiled_at": "2026-11-06T13:12:06Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:05e0ace7d9815f4dbabd702e0e19ad91ba28547ae5921185c5674c5a849688ad",
+      "digest": "sha256:09b60f5a70db4f233d36ed1d379e5508d7c04a3ec73b8c014aacb12205b66b31",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 98,
-      "generated_at_commit": "39bd3e74f267f84c5317a2d5bce7916b621c158e",
-      "source_tree": "sha256:0594d27871d6b7e2febe6110451bd9b791640fa3a1b5309584030931a86272c5"
+      "files": 99,
+      "generated_at_commit": "bb552199e8970bbdcb42c79acc8a36f9c1189e23",
+      "source_tree": "sha256:f03e2d2d4917b899fb2dc652077e8a7f156d4d80f19edd5b819699fcb7cd1bc7"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/mk/checker2.mk b/mk/checker2.mk
index 3ddb336d1..5f9119c9b 100644
--- a/mk/checker2.mk
+++ b/mk/checker2.mk
@@ -53,8 +53,8 @@ $(C2_DIR)/osc_emit_ir: tests/checker2/producer/osc_emit_ir.c $(C2_PRODUCER_LIB)
 	@mkdir -p $(C2_DIR)
 	$(CC) $(C2_CFLAGS:-Isrc/checker2=-Isrc/compiler) -o $@ tests/checker2/producer/osc_emit_ir.c $(C2_PRODUCER_LIB)
 
-test-checker2-differential: $(OUT_DIR)/compiler/oscc $(C2_DIR)/osc_emit_ir $(C2_DIR)/checker2
-	sh tests/checker2/differential.sh $(OUT_DIR)/compiler/oscc $(C2_DIR)/osc_emit_ir $(C2_DIR)/checker2 $(C2_DIR)/differential
+test-checker2-differential: $(OUT_DIR)/compiler/oscc $(C2_DIR)/osc_emit_ir $(C2_DIR)/checker2 $(OUT_DIR)/omega_emit/omega_emit
+	sh tests/checker2/differential.sh $(OUT_DIR)/compiler/oscc $(C2_DIR)/osc_emit_ir $(C2_DIR)/checker2 $(C2_DIR)/differential $(OUT_DIR)/omega_emit/omega_emit
 
 $(C2_DIR)/test_c2_receipt: tests/checker2/test_c2_receipt.c $(C2_RECEIPT) $(C2_HDRS)
 	@mkdir -p $(C2_DIR)
diff --git a/mk/omega-osc-gpu.mk b/mk/omega-osc-gpu.mk
new file mode 100644
index 000000000..7aee0de76
--- /dev/null
+++ b/mk/omega-osc-gpu.mk
@@ -0,0 +1,68 @@
+# Omegese GPU back end (L386, C1 of docs/OMEGA.md): src/omega_osc_gpu.c builds sm_121 code for an
+# Omegese kernel through the existing BlackwellIR builder. Picked up by `-include mk/*.mk`; not part
+# of `all` or `test`.
+#   make test-osc-gpu    host only: every accepted kernel of tests/checker2/kernels and tests/osc_gpu/kernels
+#                        and the Omegese-written ones of tests/osc_gpu/omegese (through omegese emit first)
+#                        through omega_emit, checker2 and the back end, then on the SIMT warp simulator
+#                        against host references (bit-exact), plus the back end's mutants (each must fail)
+#   make test-osc-gpu-chip   the same kernel tests on the GB10 through omega_kernel_launch (src/omega_osc_launch.c):
+#                        bit-exact except exp/inv/root (MUFU), which pass within 2^-20 relative (GPU.md s5).
+#                        Run it inside a chip window (spark-window run); OSC_GPU_MUTANT=n is the red run.
+#   make test-osc-gpu-om host only: the seeded .om lowering (seed/oscgpu, built with the pinned seed/out/omc) against
+#                        the C one, byte for byte (tests/osc_gpu/om_diff.sh); test_osc_gpu <ir-dir> <om-dir>, <om-dir> from
+#                        tests/osc_gpu/om_build_all.sh, uses the .om's bytes (the chip run: OSC_GPU_OM_DIR=<om-dir> make test-osc-gpu-chip)
+#   make test-om-ports   host only: all three seeded .om ports against their C oracles (migration pending: the C
+#                        stays the production path and the oracle until the .om replaces it): test-oscir-om
+#                        (seed/oscgpu/oscir.om vs osc_ir_decode/osc_ir_validate, tests/osc_gpu/oscir_diff.sh),
+#                        test-checker2-om (seed/oscgpu/c2*.om vs checker2 check, tests/checker2/om_diff.sh) and
+#                        test-osc-gpu-om
+ifndef OMEGA_OSC_GPU_MK
+OMEGA_OSC_GPU_MK := 1
+.PHONY: test-osc-gpu test-osc-gpu-chip
+OSG_DIR = $(OUT_DIR)/osc_gpu
+OSG_CFLAGS = -std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -ffp-contract=off -Isrc -Isrc/compiler -Itests
+OSG_OSC_LIB = $(filter-out src/compiler/oscc_main.c,$(wildcard src/compiler/*.c)) src/omega_om_units.c
+OSG_SRCS = src/omega_osc_gpu.c src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_osc_launch_args.c
+OSG_HDRS = src/omega_osc_gpu.h src/omega_osc_launch.h src/omega_gpu_session.h src/omega_blackwell_codegen.h src/omega_bw_em.h tests/bw_warp_sim.h $(wildcard src/compiler/*.h)
+
+$(OSG_DIR)/test_osc_gpu: tests/osc_gpu/test_osc_gpu.c $(OSG_SRCS) $(OSG_OSC_LIB) $(OSG_HDRS)
+	@mkdir -p $(OSG_DIR)
+	$(CC) $(OSG_CFLAGS) -o $@ tests/osc_gpu/test_osc_gpu.c $(OSG_SRCS) $(OSG_OSC_LIB) -lm
+
+OSG_CHIP_SRCS = src/omega_osc_launch.c src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c \
+	src/omega_blackwell_qmd.c $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c
+$(OSG_DIR)/test_osc_gpu_chip: tests/osc_gpu/test_osc_gpu.c $(OSG_SRCS) $(OSG_CHIP_SRCS) $(OSG_OSC_LIB) $(OSG_HDRS)
+	@mkdir -p $(OSG_DIR)
+	$(CC) $(OSG_CFLAGS) -DOSC_CHIP -Wno-unused-function -pthread $(GPU_ENGINE_PHYS_INC) -o $@ tests/osc_gpu/test_osc_gpu.c \
+		$(OSG_SRCS) $(OSG_CHIP_SRCS) $(OSG_OSC_LIB) -lm
+
+test-osc-gpu: $(OSG_DIR)/test_osc_gpu $(OUT_DIR)/omegese/omegese $(OUT_DIR)/omega_emit/omega_emit $(OUT_DIR)/checker2/checker2 $(OSG_DIR)/osc_gpu_build
+	sh tests/osc_gpu/run.sh $(OUT_DIR)/omegese/omegese $(OUT_DIR)/omega_emit/omega_emit $(OUT_DIR)/checker2/checker2 $(OSG_DIR)/test_osc_gpu $(OSG_DIR)/ir $(OSG_DIR)/osc_gpu_build
+
+# osc_gpu_build: one checked kernel to code + a C header that embeds it (tools/osc_gpu/osc_gpu_build.c)
+$(OSG_DIR)/osc_gpu_build: tools/osc_gpu/osc_gpu_build.c $(OSG_SRCS) $(OSG_OSC_LIB) $(OSG_HDRS)
+	@mkdir -p $(OSG_DIR)
+	$(CC) $(OSG_CFLAGS) -o $@ tools/osc_gpu/osc_gpu_build.c $(OSG_SRCS) $(OSG_OSC_LIB) -lm
+
+# the seeded .om lowering (seed/oscgpu): om_oracle is the test-only oracle and glue (tests/osc_gpu/om_oracle.c);
+# test-osc-gpu-om builds the .om with the pinned seed/out/omc and compares it with the C back end (tests/osc_gpu/om_diff.sh)
+$(OSG_DIR)/om_oracle: tests/osc_gpu/om_oracle.c $(OSG_SRCS) $(OSG_OSC_LIB) $(OSG_HDRS)
+	@mkdir -p $(OSG_DIR)
+	$(CC) $(OSG_CFLAGS) -o $@ tests/osc_gpu/om_oracle.c $(OSG_SRCS) $(OSG_OSC_LIB) -lm
+.PHONY: test-osc-gpu-om
+test-osc-gpu-om: test-osc-gpu $(OSG_DIR)/om_oracle
+	sh tests/osc_gpu/om_diff.sh seed/out/omc $(OSG_DIR)/om_oracle $(OSG_DIR)/test_osc_gpu $(OSG_DIR)/ir $(OSG_DIR)/om
+
+.PHONY: test-oscir-om test-checker2-om test-om-ports
+test-oscir-om: test-osc-gpu
+	sh tests/osc_gpu/oscir_diff.sh seed/out/omc $(OSG_DIR)/oscir_diff
+test-checker2-om: test-checker2-differential test-osc-gpu
+	sh tests/checker2/om_diff.sh $(OUT_DIR)/checker2/checker2 $(OUT_DIR)/checker2/om $(OUT_DIR)/checker2/differential/ir $(OSG_DIR)/ir
+.PHONY: test-checker2-om-bounds
+test-checker2-om-bounds: $(OUT_DIR)/omegese/omegese $(OUT_DIR)/omega_emit/omega_emit $(OUT_DIR)/checker2/checker2
+	sh tests/checker2/om_bounds.sh $(OUT_DIR)/omegese/omegese $(OUT_DIR)/omega_emit/omega_emit $(OUT_DIR)/checker2/checker2 $(OUT_DIR)/checker2/shared-bounds
+test-om-ports: test-oscir-om test-checker2-om test-osc-gpu-om test-checker2-om-bounds
+
+test-osc-gpu-chip: $(OSG_DIR)/test_osc_gpu_chip test-osc-gpu
+	$(OSG_DIR)/test_osc_gpu_chip $(OSG_DIR)/ir $(OSC_GPU_OM_DIR)
+endif
diff --git a/om/encoder/bw_enc_sm121.om b/om/encoder/bw_enc_sm121.om
index 5cbbd9c41..03471c906 100644
--- a/om/encoder/bw_enc_sm121.om
+++ b/om/encoder/bw_enc_sm121.om
@@ -349,9 +349,6 @@ ret 0
 end
 if eq op 45
 a = ulong 31053
-if ne get o 9 0
-a = 2381
-end
 put4 w a 0 58720256 ctl o 1042944
 ret 0
 end
@@ -487,10 +484,20 @@ a = or or 31139 shl rz o 1 15 16 shl rb o 2 24
 put4 w a or rb o 3 2147483648 or s rb o 5 ctl o 3284480
 ret 0
 end
+note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"7245","7305","00201000","0020f000","004fe200","004e2200"}
+note -> {29253,29445,2101248,2158592,5235200,5120512}.
+if eq op 64
+put4 w wd o 29253 rb o 2 2101248 ctl o 5235200
+ret 0
+end
+if eq op 65
+put4 w wd o 29445 rb o 2 2158592 ctl o 5120512
+ret 0
+end
 ret 1
 end
 
-fn enc1 o view ulong 16 w edit ulong 4 to ulong
+fn encraw o view ulong 16 w edit ulong 4 to ulong
 op = get o 0
 if lt op 15
 ret enc_a o w
@@ -507,6 +514,28 @@ end
 ret enc_e o w
 end
 
+note Guard ordinary instructions only when their encoded field is the documented always predicate.
+note BRA, BSSY, BSYNC and STG.STRONG.SYS encode their guard in their own cases.
+note WolframLanguageEvaluator: FromDigits["ffff0fff",16] -> 4294905855.
+fn enc1 o view ulong 16 w edit ulong 4 to ulong
+if ne encraw o w 0
+ret 1
+end
+op = get o 0
+if eq get o 9 0
+ret 0
+end
+if or or eq op 46 eq op 54 or eq op 55 eq op 22
+ret 0
+end
+a = get w 0
+if ne and shr a 12 15 7
+ret 1
+end
+put w 0 or and a 4294905855 shl pred o 12
+ret 0
+end
+
 note the 16 bytes of instruction i, each word little-endian
 fn store code edit uchar 16384 i ulong w view ulong 4 to void
 for k ulong 4
diff --git a/seed/oscgpu/c2cfg.om b/seed/oscgpu/c2cfg.om
new file mode 100644
index 000000000..3cb7578c1
--- /dev/null
+++ b/seed/oscgpu/c2cfg.om
@@ -0,0 +1,661 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2cfg.om: the CFG and dataflow rules of src/checker2/c2_check.c, ported line for line:
+note build_cfg, link_cfg, dominates, count_defs, check_handles, check_defined, single_const,
+note loop_guarded, check_loops. Bitsets are 8 words of cbs at a base offset (the C's Bits).
+note Block ends use the C's uint32 arithmetic (first + count wraps modulo 2^32).
+
+text cmlay "block %d is not the next contiguous range"
+text cmnoterm "block %d does not end in a terminator"
+text cminterm "terminator inside block %d"
+text cmcover "blocks cover %u of %u instructions"
+text crlay "C2-CFG-LAYOUT"
+text crterm "C2-CFG-TERMINATOR"
+text crhand "C2-HANDLE-DISCIPLINE"
+text cmhdef "handle v%d defined more than once or a parameter"
+text cmhuse "handle v%d used outside its handle position"
+text cmhao "v%d is not a handle opened by AOPEN"
+text cmhpo "v%d is not a handle opened by POPEN"
+text crpool "C2-TYPE-POOL"
+text cmpool "pool value type"
+text crundef "C2-UNDEFINED-USE"
+text cmundef "v%d may be read before it is written"
+text crirr "C2-CFG-IRREDUCIBLE"
+text cmirr "cycle entered other than through its header (block %d)"
+text crunb "C2-LOOP-UNBOUNDED"
+text cmunb "loop at block %d has no counter guard"
+
+const cmask32 long 4294967295
+
+fn c2_bset base long i long to void
+w = add base shr i 6
+b = shl ulong 1 and i 63
+put cbs w or get cbs w b
+end
+
+fn c2_btest base long i long to bool
+x = shr get cbs add base shr i 6 and i 63
+ret ne and x ulong 1 ulong 0
+end
+
+fn c2_ball base long to void
+for k long 8
+put cbs add base k sub ulong 0 ulong 1
+end
+end
+
+fn c2_bzero base long to void
+for k long 8
+put cbs add base k ulong 0
+end
+end
+
+fn c2_band d long s long to void
+for k long 8
+put cbs add d k and get cbs add d k get cbs add s k
+end
+end
+
+fn c2_bcpy d long s long to void
+for k long 8
+put cbs add d k get cbs add s k
+end
+end
+
+fn c2_beq x long y long to bool
+for k long 8
+if ne get cbs add x k get cbs add y k
+ret false
+end
+end
+ret true
+end
+
+note Block b's end (first + count, uint32) and its last instruction (first + count - 1, uint32).
+fn c2_bend b long to long
+ret and add c2_bfirst b c2_bcount b cmask32
+end
+
+fn c2_blast b long to long
+ret and sub add c2_bfirst b c2_bcount b 1 cmask32
+end
+
+fn c2_dom a long b long to bool
+ret c2_btest add cbdom mul b 8 a
+end
+
+fn c2_bcfg to long
+fi = get cfi 0
+ni = c2_ni
+pos = long 0
+for b long c2_nb
+fs = c2_bfirst b
+bc = c2_bcount b
+e = c2_bend b
+if or or lt bc 1 ne fs pos gt e ni
+c2_a1 b
+ret c2_fail crlay fi -1 cmlay
+end
+if lt c2_bterm b fs e 0
+ret -1
+end
+pos = and add pos bc cmask32
+end
+if ne pos ni
+c2_a2 pos ni
+ret c2_fail crlay fi -1 cmcover
+end
+ret 0
+end
+
+fn c2_bterm b long fs long e long to long
+i = fs
+while lt i e bound 4097
+put cblk i b
+last = eq add i 1 e
+if ne c2_term c2_op i last
+c2_a1 b
+if last
+ret c2_fail crterm get cfi 0 i cmnoterm
+end
+ret c2_fail crterm get cfi 0 i cminterm
+end
+i = add i 1
+end
+ret 0
+end
+
+fn c2_lcfg to void
+nb = c2_nb
+for b long nb
+s = c2_is c2_blast b
+op = get cop s
+n = long 0
+if eq op cqbr
+put csuc mul b 2 get ct s
+n = 1
+end
+if eq op cqcbr
+put csuc mul b 2 get ct s
+n = 1
+if ne get cf s get ct s
+put csuc add mul b 2 1 get cf s
+n = 2
+end
+end
+put cnsu b n
+end
+for b long nb
+put creach b 0
+end
+put creach 0 1
+put cstk 0 0
+sp = long 1
+while gt sp 0 bound 999999
+sp = sub sp 1
+b = get cstk sp
+for k long get cnsu b
+q = get csuc add mul b 2 k
+if eq get creach q 0
+put creach q 1
+put cstk sp q
+sp = add sp 1
+end
+end
+end
+c2_ldom nb
+end
+
+fn c2_ldom nb long to void
+for b long nb
+c2_ball add cbdom mul b 8
+end
+c2_bzero cbdom
+c2_bset cbdom 0
+ch = true
+while ch bound 999999
+ch = false
+for b long nb
+if and gt b 0 ne get creach b 0
+c2_ball cbt0
+c2_predand b nb cbdom
+c2_bset cbt0 b
+if not c2_beq cbt0 add cbdom mul b 8
+c2_bcpy add cbdom mul b 8 cbt0
+ch = true
+end
+end
+end
+end
+end
+
+note cbt0 &= region[p] for every reachable p with an edge p -> b.
+fn c2_predand b long nb long region long to void
+for p long nb
+if ne get creach p 0
+for k long get cnsu p
+if eq get csuc add mul p 2 k b
+c2_band cbt0 add region mul p 8
+end
+end
+end
+end
+end
+
+fn c2_cdefs to void
+np = c2_np
+for r long c2_nv
+put cnd r 0
+if lt r np
+put cnd r 1
+end
+put cdi r -1
+end
+for i long c2_ni
+d = c2_defs i
+if ge d 0
+n = add get cnd d 1
+put cnd d n
+put cdi d -1
+if eq n 1
+put cdi d i
+end
+end
+end
+end
+
+fn c2_hands to long
+ni = c2_ni
+for i long ni
+s = c2_is i
+op = get cop s
+if or eq op cqaopen eq op cqpopen
+h = get cdst s
+if or lt h c2_np ne get cnd h 1
+c2_a1 h
+ret c2_fail crhand get cfi 0 i cmhdef
+end
+if lt c2_huse h op ni 0
+ret -1
+end
+end
+end
+ret c2_horig ni
+end
+
+fn c2_huse h long hop long ni long to long
+for j long ni
+nu = c2_uses j
+for k long nu
+if eq get cus k h
+if not c2_hok j h hop
+c2_a1 h
+ret c2_fail crhand get cfi 0 j cmhuse
+end
+end
+end
+end
+ret 0
+end
+
+fn c2_hok j long h long hop long to bool
+s = c2_is j
+op = get cop s
+a = get ca s
+b = get cb s
+if eq hop cqaopen
+if eq op cqaalloc
+ret and eq b h ne a h
+end
+ret and eq op cqadest eq a h
+end
+if eq op cqpclose
+ret eq a h
+end
+if eq op cqhalloc
+ret and eq b h ne a h
+end
+if not or or eq op cqhgen eq op cqhfree or eq op cqhload eq op cqhstore
+ret false
+end
+if or ne a h eq b h
+ret false
+end
+if eq get cc s h
+ret false
+end
+ret ne get carg mul s 6 h
+end
+
+fn c2_horig ni long to long
+for j long ni
+if lt c2_horig1 j 0
+ret -1
+end
+end
+ret 0
+end
+
+fn c2_horig1 j long to long
+s = c2_is j
+op = get cop s
+h = long -1
+if or eq op cqaalloc eq op cqhalloc
+h = get cb s
+end
+if or or eq op cqadest eq op cqpclose or eq op cqhgen eq op cqhfree
+h = get ca s
+end
+if or eq op cqhload eq op cqhstore
+h = get ca s
+end
+if lt h 0
+ret 0
+end
+di = get cdi h
+want = cqpopen
+if or eq op cqaalloc eq op cqadest
+want = cqaopen
+end
+bad = lt di 0
+if not bad
+bad = ne c2_op di want
+end
+if bad
+c2_a1 h
+if eq want cqaopen
+ret c2_fail crhand get cfi 0 j cmhao
+end
+ret c2_fail crhand get cfi 0 j cmhpo
+end
+es = get csub c2_is di
+r = long -1
+if eq op cqhalloc
+r = get ca s
+end
+if eq op cqhload
+r = get cdst s
+end
+if eq op cqhstore
+r = get carg mul s 6
+end
+if ge r 0
+if ne get cts c2_vs r es
+ret c2_fail crpool get cfi 0 j cmpool
+end
+end
+ret 0
+end
+
+note check_defined. Sets: in cbdin + 8b, out cbdout + 8b, params cbt1, cur cbt0.
+fn c2_cdef to long
+nb = c2_nb
+c2_bzero cbt1
+for r long c2_np
+c2_bset cbt1 r
+end
+for b long nb
+c2_ball add cbdout mul b 8
+end
+ch = true
+while ch bound 999999
+ch = false
+for b long nb
+if ne get creach b 0
+if eq b 0
+c2_bcpy cbt0 cbt1
+c2_predand 0 nb cbdout
+else
+c2_ball cbt0
+c2_predand b nb cbdout
+end
+c2_bcpy add cbdin mul b 8 cbt0
+c2_dflow b
+if not c2_beq cbt0 add cbdout mul b 8
+c2_bcpy add cbdout mul b 8 cbt0
+ch = true
+end
+end
+end
+end
+for b long nb
+if ne get creach b 0
+c2_bcpy cbt0 add cbdin mul b 8
+if lt c2_duse b 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_dflow b long to void
+kern = ne get cgk get cfi 0 0
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+if and eq c2_op i cqtrap not kern
+c2_ball cbt0
+ret
+end
+d = c2_defs i
+if ge d 0
+c2_bset cbt0 d
+end
+i = add i 1
+end
+end
+
+fn c2_duse b long to long
+kern = ne get cgk get cfi 0 0
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+if and eq c2_op i cqtrap not kern
+ret 0
+end
+nu = c2_uses i
+for k long nu
+u = get cus k
+if not c2_btest cbt0 u
+c2_a1 u
+ret c2_fail crundef get cfi 0 i cmundef
+end
+end
+d = c2_defs i
+if ge d 0
+c2_bset cbt0 d
+end
+i = add i 1
+end
+ret 0
+end
+
+note single_const: the CONST value of r when r is defined exactly once, by CONST; else the flag is 0.
+fn c2_sconst r long to bool
+if lt r 0
+ret false
+end
+if ne get cnd r 1
+ret false
+end
+di = get cdi r
+if lt di 0
+ret false
+end
+ret eq c2_op di cqconst
+end
+
+fn c2_sval r long to ulong
+ret get cimm c2_is get cdi r
+end
+
+note loop_guarded over cinl (in loop), cwl[0..nl) latches.
+fn c2_lguard nl long to bool
+for g long c2_nb
+if ne get cinl g 0
+if c2_lguard1 g nl
+ret true
+end
+end
+end
+ret false
+end
+
+note |K| <= 1000000 with the C's signed/unsigned reading of K (an unsigned K above 2000000 is cut
+note to 2000000 there, which only matters for the comparison and so is not modelled).
+fn c2_kfits kb long to bool
+kv = c2_sval kb
+if c2_sgn get cts c2_vs kb
+note the C reads K as int64: a value at or above 2^63 is negative, magnitude 2^64 - K
+if ge kv shl ulong 1 63
+ret le sub ulong 0 kv ulong 1000000
+end
+end
+ret le kv ulong 1000000
+end
+
+fn c2_domall a long nl long to bool
+for k long nl
+if not c2_dom a get cwl k
+ret false
+end
+end
+ret true
+end
+
+fn c2_lguard1 g long nl long to bool
+if not c2_domall g nl
+ret false
+end
+t = c2_is c2_blast g
+if ne get cop t cqcbr
+ret false
+end
+ci = get cdi get ca t
+if lt ci 0
+ret false
+end
+if or ne get cblk ci g ne c2_op ci cqcmp
+ret false
+end
+cm = c2_is ci
+sb = get csub cm
+ex = false
+if eq sb 6
+ex = eq get cinl get ct t 0
+else
+if eq sb 3
+ex = eq get cinl get cf t 0
+else
+ret false
+end
+end
+if not ex
+ret false
+end
+kb = get cb cm
+if not c2_sconst kb
+ret false
+end
+if not c2_kfits kb
+ret false
+end
+cr = get ca cm
+if not c2_int get cts c2_vs cr
+ret false
+end
+ret c2_lincs cr nl
+end
+
+fn c2_lincs cr long nl long to bool
+incs = long 0
+for i long c2_ni
+if ne get cinl get cblk i 0
+if eq c2_defs i cr
+if not c2_linc i cr nl
+ret false
+end
+incs = add incs 1
+end
+end
+end
+ret ge incs 1
+end
+
+fn c2_linc i long cr long nl long to bool
+s = c2_is i
+if or ne get cop s cqbin ne get csub s 1
+ret false
+end
+if ne get ca s cr
+ret false
+end
+ob = get cb s
+if not c2_sconst ob
+ret false
+end
+if ne c2_sval ob ulong 1
+ret false
+end
+ret c2_domall get cblk i nl
+end
+
+fn c2_loops to long
+nb = c2_nb
+for b long nb
+put ccol b 0
+end
+put cstk 0 0
+put cidx 0 0
+sp = long 1
+put ccol 0 1
+while gt sp 0 bound 999999
+b = get cstk sub sp 1
+ix = get cidx sub sp 1
+if lt ix get cnsu b
+put cidx sub sp 1 add ix 1
+s = get csuc add mul b 2 ix
+if and eq get ccol s 1 not c2_dom s b
+c2_a1 s
+ret c2_fail crirr get cfi 0 -1 cmirr
+end
+if eq get ccol s 0
+put ccol s 1
+put cstk sp s
+put cidx sp 0
+sp = add sp 1
+end
+else
+put ccol b 2
+sp = sub sp 1
+end
+end
+for h long nb
+if ne get creach h 0
+if lt c2_loop1 h nb 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_loop1 h long nb long to long
+nl = long 0
+for p long nb
+if and ne get creach p 0 c2_hassuc p h
+if c2_dom h p
+put cwl nl p
+nl = add nl 1
+end
+end
+end
+if eq nl 0
+ret 0
+end
+for p long nb
+put cinl p 0
+end
+put cinl h 1
+n = long 0
+for k long nl
+q = get cwl k
+if eq get cinl q 0
+put cinl q 1
+put cstk n q
+n = add n 1
+end
+end
+c2_lgrow n nb
+if not c2_lguard nl
+c2_a1 h
+ret c2_fail crunb get cfi 0 c2_bfirst h cmunb
+end
+ret 0
+end
+
+fn c2_lgrow n0 long nb long to void
+n = n0
+while gt n 0 bound 999999
+n = sub n 1
+b = get cstk n
+for p long nb
+if and ne get creach p 0 eq get cinl p 0
+if c2_hassuc p b
+put cinl p 1
+put cstk n p
+n = add n 1
+end
+end
+end
+end
+end
+
+fn c2_hassuc p long b long to bool
+for k long get cnsu p
+if eq get csuc add mul p 2 k b
+ret true
+end
+end
+ret false
+end
diff --git a/seed/oscgpu/c2chk.om b/seed/oscgpu/c2chk.om
new file mode 100644
index 000000000..2ef952cbf
--- /dev/null
+++ b/seed/oscgpu/c2chk.om
@@ -0,0 +1,395 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2chk.om: type predicates, check_structs, check_type, uses/defines and check_insn of
+note src/checker2/c2_check.c. Types are named by slot (c2glob.om: f*481+v, f*481+480 the return).
+
+fn c2_val s long to bool
+ret and ge s 1 le s 9
+end
+fn c2_int s long to bool
+ret and ge s 2 le s 9
+end
+fn c2_sgn s long to bool
+ret and ge s 6 le s 9
+end
+fn c2_num s long to bool
+ret or c2_val s eq s 13
+end
+fn c2_kv s long to bool
+ret or eq s 4 eq s 13
+end
+fn c2_width s long to long
+if eq s 1
+ret 1
+end
+if or eq s 2 eq s 6
+ret 8
+end
+if or eq s 3 eq s 7
+ret 16
+end
+if or or eq s 4 eq s 8 eq s 13
+ret 32
+end
+if or eq s 5 eq s 9
+ret 64
+end
+ret 0
+end
+
+fn c2_scal x long to bool
+ret c2_num get cts x
+end
+fn c2_gbuf x long to bool
+ret or eq get cts x 14 eq get cts x 15
+end
+fn c2_isblk x long to bool
+ret and eq get cts x 10 eq get ctk x 4
+end
+fn c2_isref x long to bool
+ret eq get cts x 10
+end
+fn c2_isarr x long to bool
+ret and eq get cts x 10 eq get cti x 0
+end
+fn c2_isstr x long to bool
+ret and eq get cts x 10 ne get cti x 0
+end
+fn c2_slice x long to bool
+ret or eq get cts x 11 eq get cts x 12
+end
+fn c2_u64 x long to bool
+ret eq get cts x 5
+end
+
+fn c2_same x long y long to bool
+if ne get cts x get cts y
+ret false
+end
+if c2_gbuf x
+ret eq get cte x get cte y
+end
+if ne get cts x 10
+ret true
+end
+if ne get ctk x get ctk y
+ret false
+end
+ret c2_shape x y
+end
+
+fn c2_shape x long y long to bool
+if not and eq get cts x 10 eq get cts y 10
+ret false
+end
+if ne get cte x get cte y
+ret false
+end
+if ne get ctl x get ctl y
+ret false
+end
+ret eq get cti x get cti y
+end
+
+fn c2_bind tk long fr long to bool
+if or eq tk 4 eq fr 4
+ret false
+end
+if eq fr 1
+ret true
+end
+if eq fr 3
+ret or eq tk 3 eq tk 2
+end
+if eq fr 2
+ret eq tk 2
+end
+ret false
+end
+
+fn c2_canonv s long imm ulong to bool
+w = c2_width s
+if eq s 1
+ret le imm 1
+end
+if eq w 64
+ret true
+end
+if not c2_sgn s
+ret lt imm shl ulong 1 w
+end
+h = shl ulong 1 sub w 1
+ret or lt imm h ge imm sub ulong 0 h
+end
+
+text crsname "C2-STRUCT-NAME"
+text crsftyp "C2-STRUCT-FIELD-TYPE"
+text crsflen "C2-STRUCT-FIELD-LEN"
+text crslay "C2-STRUCT-LAYOUT"
+text cmstwice "struct %s defined twice"
+text cmftwice "field %s.%s twice"
+text cmfqual "%s.%s"
+text cmflen "%s.%s length %u"
+text cmfoff "%s.%s offset %u, prefix sum %u"
+text cmscell "%s cells %u, fields need %u"
+
+note Name equality: struct names (refs 0..15), field names (100 + slot), function names (1000 + fi).
+fn c2_nameq p long q long to bool
+if lt p 100
+if ne get csnl p get csnl q
+ret false
+end
+for i long get csnl p
+x = get csn add mul p 64 i
+y = get csn add mul q 64 i
+if ne x y
+ret false
+end
+end
+ret true
+end
+if lt p 1000
+ret c2_fnameq sub p 100 sub q 100
+end
+ret c2_gnameq sub p 1000 sub q 1000
+end
+
+fn c2_fnameq a long b long to bool
+if ne get cfnl a get cfnl b
+ret false
+end
+for i long get cfnl a
+x = get cfn add mul a 64 i
+y = get cfn add mul b 64 i
+if ne x y
+ret false
+end
+end
+ret true
+end
+
+fn c2_gnameq a long b long to bool
+if ne get cgnl a get cgnl b
+ret false
+end
+for i long get cgnl a
+x = get cgn add mul a 64 i
+y = get cgn add mul b 64 i
+if ne x y
+ret false
+end
+end
+ret true
+end
+
+fn c2_cfield k long f long off long to long
+q = add mul k 16 f
+for g long f
+if c2_nameq add 100 add mul k 16 g add 100 q
+c2_s2 k add 100 q
+ret c2_fail crsname -1 -1 cmftwice
+end
+end
+c2_s2 k add 100 q
+if not c2_val get cfs q
+ret c2_fail crsftyp -1 -1 cmfqual
+end
+if gt get cfal q 64
+c2_a1 get cfal q
+ret c2_fail crsflen -1 -1 cmflen
+end
+if ne get cfof q off
+c2_a2 get cfof q off
+ret c2_fail crslay -1 -1 cmfoff
+end
+ret 0
+end
+
+fn c2_cstructs to long
+for k long get cnst 0
+for j long k
+if c2_nameq j k
+c2_s1 k
+ret c2_fail crsname -1 -1 cmstwice
+end
+end
+off = long 0
+for f long get csnf k
+if ne c2_cfield k f off 0
+ret -1
+end
+al = get cfal add mul k 16 f
+if ne al 0
+off = add off al
+else
+off = add off 1
+end
+end
+if or or ne get csnc k off lt off 1 gt off 64
+c2_s1 k
+c2_a2 get csnc k off
+ret c2_fail crslay -1 -1 cmscell
+end
+end
+ret 0
+end
+
+fn c2_ctype x long to bool
+s = get cts x
+if or ge s 16 eq s 0
+ret false
+end
+if c2_gbuf x
+ret c2_kv get cte x
+end
+if ne s 10
+ret true
+end
+k = get ctk x
+l = get ctl x
+if eq k 4
+ret and and c2_kv get cte x eq get cti x 0 and ge l 1 le l 12288
+end
+if or lt k 1 gt k 3
+ret false
+end
+if eq get cte x 0
+d = get cti x
+if or lt d 1 gt d get cnst 0
+ret false
+end
+ret eq l get csnc sub d 1
+end
+ret and and c2_val get cte x eq get cti x 0 and ge l 1 le l 64
+end
+
+note Current-function accessors.
+fn c2_vs r long to long
+ret add mul get cfi 0 481 r
+end
+fn c2_is i long to long
+ret add mul get cfi 0 4096 i
+end
+fn c2_nv to long
+ret get cgnv get cfi 0
+end
+fn c2_np to long
+ret get cgnp get cfi 0
+end
+fn c2_nb to long
+ret get cgnb get cfi 0
+end
+fn c2_ni to long
+ret get cgni get cfi 0
+end
+fn c2_op i long to long
+ret get cop c2_is i
+end
+fn c2_bfirst b long to long
+ret get cbf add mul get cfi 0 512 b
+end
+fn c2_bcount b long to long
+ret get cbc add mul get cfi 0 512 b
+end
+fn c2_term op long to bool
+ret or or eq op cqbr eq op cqcbr eq op cqret
+end
+
+fn c2_u1 x long to long
+put cus 0 x
+ret 1
+end
+fn c2_u2 x long y long to long
+put cus 0 x
+put cus 1 y
+ret 2
+end
+fn c2_u3 x long y long z long to long
+put cus 0 x
+put cus 1 y
+put cus 2 z
+ret 3
+end
+
+note uses(): the registers instruction i reads, into cus; returns the count. Class cuse (c2_init):
+note 0 none, 1 a, 2 a when a >= 0 (RET), 3 a b, 4 a b c, 5 a b c args0 (HSTORE), 6 a [b] (FLOAD),
+note 7 a [b] c (FSTORE), 8 the call arguments, 9 a a+1 b (GLOAD), 10 a a+1 b c (GSTORE).
+fn c2_uses i long to long
+s = c2_is i
+u = get cuse get cop s
+a = get ca s
+b = get cb s
+if eq u 1
+ret c2_u1 a
+end
+if eq u 2
+if ge a 0
+ret c2_u1 a
+end
+ret 0
+end
+if eq u 3
+ret c2_u2 a b
+end
+if eq u 4
+ret c2_u3 a b get cc s
+end
+ret c2_uses2 s u a b
+end
+
+fn c2_uses2 s long u long a long b long to long
+if eq u 5
+z1 = c2_u3 a b get cc s
+put cus 3 get carg mul s 6
+ret 4
+end
+if eq u 6
+if ge b 0
+ret c2_u2 a b
+end
+ret c2_u1 a
+end
+if eq u 7
+if ge b 0
+ret c2_u3 a b get cc s
+end
+ret c2_u2 a get cc s
+end
+if eq u 8
+n = get cnag s
+for k long n
+put cus k get carg add mul s 6 k
+end
+ret n
+end
+a1 = c2_i16 add a 1
+if eq u 9
+ret c2_u3 a a1 b
+end
+if eq u 10
+z2 = c2_u3 a a1 b
+put cus 3 get cc s
+ret 4
+end
+ret 0
+end
+
+fn c2_i16 v long to long
+if gt v 32767
+ret sub v 65536
+end
+ret v
+end
+
+fn c2_defop op long to bool
+ret ne get cdop op 0
+end
+
+note defines(): the register instruction i writes, or -1.
+fn c2_defs i long to long
+s = c2_is i
+op = get cop s
+if or c2_defop op eq op cqcall
+ret get cdst s
+end
+ret -1
+end
diff --git a/seed/oscgpu/c2dec.om b/seed/oscgpu/c2dec.om
new file mode 100644
index 000000000..8ef0acfa0
--- /dev/null
+++ b/seed/oscgpu/c2dec.om
@@ -0,0 +1,729 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2dec.om: c2_decode of src/checker2/c2_ir.c. Readers are little-endian and do nothing once cbad is
+note set (the C stops at the first failed read of an operand list; the verdict is the same either way
+note because a failed read always ends in C2-DECODE-TRUNCATED at that point).
+
+text crtrunc "C2-DECODE-TRUNCATED"
+text crmagic "C2-DECODE-MAGIC"
+text crver "C2-DECODE-VERSION"
+text crlstr "C2-LIMIT-STRUCTS"
+text crname "C2-DECODE-NAME"
+text crsfld "C2-STRUCT-FIELDS"
+text crlfn "C2-LIMIT-FUNCS"
+text crkind "C2-DECODE-KIND"
+text crlvr "C2-LIMIT-VREGS"
+text crlbl "C2-LIMIT-BLOCKS"
+text crlin "C2-LIMIT-INSNS"
+text crtext "C2-DECODE-TEXT"
+text crtrail "C2-DECODE-TRAILING"
+text crnonc "C2-DECODE-VERSION-NONCANONICAL"
+text crarity "C2-CALL-ARITY"
+text cropc "C2-DECODE-OPCODE"
+text cmmagic "bad magic"
+text cmver "unknown version %u"
+text cmscnt "struct count"
+text cmnstr "%u structs"
+text cmsnm "struct name"
+text cmsnm2 "struct %d name"
+text cmshdr "struct header"
+text cmsfld "struct %d has %u fields"
+text cmfnm "field name"
+text cmfnm2 "struct %d field %d name"
+text cmfield "field"
+text cmfcnt "function count"
+text cmnfn "%u functions"
+text cmgnm "function name"
+text cmgkind "function kind"
+text cmgkd2 "function kind %u"
+text cmthr "thread count"
+text cmnpar "nparams"
+text cmret "return type"
+text cmnvr "nvregs"
+text cmnvr2 "%u vregs"
+text cmvrt "vreg type"
+text cmnbl "nblocks"
+text cmnbl2 "%u blocks"
+text cmblock "block"
+text cmnin "ninsns"
+text cmnin2 "%u instructions"
+text cmreq "requires text"
+text cmens "ensures text"
+text cmtrail "%zu bytes after the last function"
+text cmnonc "version byte %u, content needs %d"
+text cmopc "opcode"
+text cmopnd "instruction operands"
+text cmcarg "call with %u arguments"
+text cmuopc "unknown opcode %u"
+
+fn c2_q8 to long
+if ne get cbad 0 0
+ret 0
+end
+p = get cpos 0
+if gt add p 1 get cn 0
+put cbad 0 1
+ret 0
+end
+put cpos 0 add p 1
+ret long get cbuf p
+end
+
+fn c2_q16 to long
+lo = c2_q8
+hi = c2_q8
+ret or lo shl hi 8
+end
+
+fn c2_q32 to long
+if ne get cbad 0 0
+ret 0
+end
+if gt add get cpos 0 4 get cn 0
+put cbad 0 1
+ret 0
+end
+a = c2_q16
+b = c2_q16
+ret or a shl b 16
+end
+
+fn c2_q64 to ulong
+if ne get cbad 0 0
+ret 0
+end
+p = get cpos 0
+if gt add p 8 get cn 0
+put cbad 0 1
+ret 0
+end
+x = ulong 0
+k = long 7
+while ge k 0 bound 9
+x = or shl x 8 ulong get cbuf add p k
+k = sub k 1
+end
+put cpos 0 add p 8
+ret x
+end
+
+note u16 as int16: 0xFFFF is -1.
+fn c2_qvr to long
+if ne get cbad 0 0
+ret 0
+end
+if gt add get cpos 0 2 get cn 0
+put cbad 0 1
+ret 0
+end
+x = c2_q16
+if ge x 32768
+ret sub x 65536
+end
+ret x
+end
+
+note rdname: 0 ok (bytes in cnm, length cnml), -1 length byte missing, -2 too long, short or not an
+note identifier ([A-Za-z_][A-Za-z0-9_]*).
+fn c2_rname to long
+put cbad 0 0
+n = c2_q8
+if ne get cbad 0 0
+ret -1
+end
+if gt n 63
+ret -2
+end
+p = get cpos 0
+if gt add p n get cn 0
+ret -2
+end
+put cnml 0 n
+ok = long 1
+if eq n 0
+ok = 0
+end
+for i long n
+x = get cbuf add p i
+put cnm i x
+al = or or and ge x 65 le x 90 and ge x 97 le x 122 eq x 95
+dg = and ge x 48 le x 57
+if not or al and gt i 0 dg
+ok = 0
+end
+end
+put cpos 0 add p n
+if eq ok 0
+ret -2
+end
+ret 0
+end
+
+note rdtext: length (>= 0), -1 length missing, -2 over 255, short, or an inner NUL.
+fn c2_rtext to long
+put cbad 0 0
+n = c2_q16
+if ne get cbad 0 0
+ret -1
+end
+p = get cpos 0
+if or gt n 255 gt add p n get cn 0
+ret -2
+end
+put cpos 0 add p n
+for i long n
+if eq get cbuf add p i 0
+ret -2
+end
+end
+ret n
+end
+
+note rdtype into type slot s: 0 ok, -1 truncated.
+fn c2_rtype s long to long
+put cbad 0 0
+put cts s 0
+put ctk s 0
+put cte s 0
+put ctl s 0
+put cti s 0
+x = c2_q8
+if ne get cbad 0 0
+ret -1
+end
+put cts s x
+if or eq x 14 eq x 15
+put cte s c2_q8
+if ne get cbad 0 0
+ret -1
+end
+ret 0
+end
+if eq x 10
+put ctk s c2_q8
+put cte s c2_q8
+put ctl s c2_q16
+if ne get cbad 0 0
+ret -1
+end
+if eq get cte s 0
+put cti s c2_q8
+if ne get cbad 0 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_trunc fi long msg view uchar * to long
+ret c2_fail crtrunc fi -1 msg
+end
+
+note Opcode classes. clay: wire layout of the operands; cuse: registers read (see c2_uses); cdop: 1
+note when the opcode defines its destination (CALL is handled apart: a void call has none).
+fn c2_cls op long ly long us long dp long to void
+put clay op ly
+put cuse op us
+put cdop op dp
+end
+
+fn c2_init to void
+c2_cls cqconst 1 0 1
+c2_cls cqmov 2 1 1
+c2_cls cqbin 3 3 1
+c2_cls cqun 4 1 1
+c2_cls cqcmp 3 3 1
+c2_cls cqcast 2 1 1
+c2_cls cqalloc 2 1 1
+c2_cls cqrel 5 1 0
+c2_cls cqload 7 3 1
+c2_cls cqstore 9 4 0
+c2_cls cqcall 14 8 0
+c2_cls cqtrap 15 0 0
+c2_cls cqbr 16 0 0
+c2_cls cqcbr 17 1 0
+c2_cls cqret 5 2 0
+c2_cls cqfload 12 6 1
+c2_cls cqfstore 13 7 0
+c2_cls cqaopen 6 0 1
+c2_cls cqaalloc 7 3 1
+c2_cls cqadest 5 1 0
+c2_cls cqpopen 8 0 1
+c2_cls cqpclose 5 1 0
+c2_cls cqhalloc 7 3 1
+c2_cls cqhgen 7 3 1
+c2_cls cqhfree 9 4 0
+c2_cls cqhload 10 4 1
+c2_cls cqhstore 11 5 0
+c2_cls cqsload 7 3 1
+c2_cls cqsstore 9 4 0
+c2_cls cqgpu 18 0 1
+c2_cls cqshared 19 0 1
+c2_cls cqgload 7 9 1
+c2_cls cqgstore 9 10 0
+c2_cls cqsync 20 0 0
+c2_cls cqshfl 3 3 1
+c2_cls cqmad 10 4 1
+end
+
+note Operand list of instruction slot s whose opcode is op: 0 read, 1 unknown opcode, 2 call arity.
+fn c2_dops s long op long to long
+ly = get clay op
+if eq ly 0
+ret 1
+end
+if eq ly 1
+put cdst s c2_qvr
+put cimm s c2_q64
+ret 0
+end
+if eq ly 2
+put cdst s c2_qvr
+put ca s c2_qvr
+ret 0
+end
+if eq ly 3
+put csub s c2_q8
+put cdst s c2_qvr
+put ca s c2_qvr
+put cb s c2_qvr
+ret 0
+end
+if eq ly 4
+put csub s c2_q8
+put cdst s c2_qvr
+put ca s c2_qvr
+ret 0
+end
+if eq ly 5
+put ca s c2_qvr
+ret 0
+end
+if eq ly 6
+put cdst s c2_qvr
+put cimm s ulong c2_q8
+ret 0
+end
+if eq ly 7
+put cdst s c2_qvr
+put ca s c2_qvr
+put cb s c2_qvr
+ret 0
+end
+if eq ly 8
+put cdst s c2_qvr
+put csub s c2_q8
+put cnag s c2_q8
+put cimm s c2_q64
+ret 0
+end
+if eq ly 9
+put ca s c2_qvr
+put cb s c2_qvr
+put cc s c2_qvr
+ret 0
+end
+ret c2_dops2 s ly
+end
+
+fn c2_dops2 s long ly long to long
+if eq ly 10
+put cdst s c2_qvr
+put ca s c2_qvr
+put cb s c2_qvr
+put cc s c2_qvr
+ret 0
+end
+if eq ly 11
+put ca s c2_qvr
+put cb s c2_qvr
+put cc s c2_qvr
+put carg mul s 6 c2_qvr
+put cnag s 1
+ret 0
+end
+if eq ly 12
+put cdst s c2_qvr
+put ca s c2_qvr
+put cb s c2_qvr
+put cimm s ulong c2_q8
+ret 0
+end
+if eq ly 13
+put ca s c2_qvr
+put cb s c2_qvr
+put cc s c2_qvr
+put cimm s ulong c2_q8
+ret 0
+end
+if eq ly 14
+put cdst s c2_qvr
+put ccal s c2_q16
+put cnag s c2_q8
+if c2_bad
+ret 0
+end
+n = get cnag s
+if gt n 6
+ret 2
+end
+for k long n
+put carg add mul s 6 k c2_qvr
+end
+ret 0
+end
+if eq ly 15
+put cimm s ulong c2_q8
+ret 0
+end
+if eq ly 16
+put ct s c2_q16
+ret 0
+end
+if eq ly 17
+put ca s c2_qvr
+put ct s c2_q16
+put cf s c2_q16
+ret 0
+end
+if eq ly 18
+put csub s c2_q8
+put cdst s c2_qvr
+ret 0
+end
+if eq ly 19
+put cdst s c2_qvr
+end
+ret 0
+end
+
+fn c2_bad to bool
+ret ne get cbad 0 0
+end
+
+fn c2_dinsn fi long ii long to long
+s = add mul fi 4096 ii
+put cdst s -1
+put ca s -1
+put cb s -1
+put cc s -1
+for k long 6
+put carg add mul s 6 k -1
+end
+put csub s 0
+put cnag s 0
+put ct s 0
+put cf s 0
+put ccal s 0
+put cimm s 0
+put cbad 0 0
+op = c2_q8
+if ne get cbad 0 0
+ret c2_trunc fi cmopc
+end
+put cop s op
+r = c2_dops s op
+if eq r 1
+c2_a1 op
+ret c2_fail cropc fi ii cmuopc
+end
+if eq r 2
+c2_a1 get cnag s
+ret c2_fail crarity fi ii cmcarg
+end
+if ne get cbad 0 0
+ret c2_trunc fi cmopnd
+end
+ret 0
+end
+
+fn c2_cpname dst long to void
+note dst: 0..15 struct name, 100+slot field name, 1000+fi function name
+n = get cnml 0
+if lt dst 100
+put csnl dst n
+for i long n
+put csn add mul dst 64 i get cnm i
+end
+ret
+end
+if lt dst 1000
+q = sub dst 100
+put cfnl q n
+for i long n
+put cfn add mul q 64 i get cnm i
+end
+ret
+end
+g = sub dst 1000
+put cgnl g n
+for i long n
+put cgn add mul g 64 i get cnm i
+end
+end
+
+fn c2_dfield k long f long to long
+e = c2_rname
+if eq e -1
+ret c2_trunc -1 cmfnm
+end
+if ne e 0
+c2_a2 k f
+ret c2_fail crname -1 -1 cmfnm2
+end
+q = add mul k 16 f
+c2_cpname add 100 q
+put cbad 0 0
+put cfs q c2_q8
+put cfal q c2_q16
+put cfof q c2_q16
+if ne get cbad 0 0
+ret c2_trunc -1 cmfield
+end
+ret 0
+end
+
+fn c2_dstructs to long
+put cbad 0 0
+n = c2_q8
+if ne get cbad 0 0
+ret c2_trunc -1 cmscnt
+end
+put cnst 0 n
+if gt n 16
+c2_a1 n
+ret c2_fail crlstr -1 -1 cmnstr
+end
+for k long n
+e = c2_rname
+if eq e -1
+ret c2_trunc -1 cmsnm
+end
+if ne e 0
+c2_a1 k
+ret c2_fail crname -1 -1 cmsnm2
+end
+c2_cpname k
+put cbad 0 0
+put csnf k c2_q8
+put csnc k c2_q16
+if ne get cbad 0 0
+ret c2_trunc -1 cmshdr
+end
+nf = get csnf k
+if or lt nf 1 gt nf 16
+c2_a2 k nf
+ret c2_fail crsfld -1 -1 cmsfld
+end
+for f long nf
+if ne c2_dfield k f 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+note Function header up to and including the vreg types.
+fn c2_dfhead fi long to long
+e = c2_rname
+if eq e -1
+ret c2_trunc fi cmgnm
+end
+if ne e 0
+ret c2_fail crname fi -1 cmgnm
+end
+c2_cpname add 1000 fi
+put cgk fi 0
+put cgth fi 0
+if eq get cver 0 cvkern
+put cbad 0 0
+kd = c2_q8
+if ne get cbad 0 0
+ret c2_trunc fi cmgkind
+end
+put cgk fi kd
+if gt kd 1
+c2_a1 kd
+ret c2_fail crkind fi -1 cmgkd2
+end
+if eq kd 1
+put cgth fi c2_q16
+if ne get cbad 0 0
+ret c2_trunc fi cmthr
+end
+end
+end
+put cbad 0 0
+put cgnp fi c2_q8
+if ne get cbad 0 0
+ret c2_trunc fi cmnpar
+end
+base = mul fi 481
+if ne c2_rtype add base 480 0
+ret c2_trunc fi cmret
+end
+put cbad 0 0
+nv = c2_q16
+if ne get cbad 0 0
+ret c2_trunc fi cmnvr
+end
+put cgnv fi nv
+if gt nv 480
+c2_a1 nv
+ret c2_fail crlvr fi -1 cmnvr2
+end
+for k long nv
+if ne c2_rtype add base k 0
+ret c2_trunc fi cmvrt
+end
+end
+ret 0
+end
+
+fn c2_dfunc fi long to long
+if ne c2_dfhead fi 0
+ret -1
+end
+put cbad 0 0
+nb = c2_q16
+if ne get cbad 0 0
+ret c2_trunc fi cmnbl
+end
+put cgnb fi nb
+if or lt nb 1 gt nb 512
+c2_a1 nb
+ret c2_fail crlbl fi -1 cmnbl2
+end
+for b long nb
+s = add mul fi 512 b
+put cbf s c2_q32
+put cbc s c2_q32
+if ne get cbad 0 0
+ret c2_trunc fi cmblock
+end
+end
+ni = c2_q32
+if ne get cbad 0 0
+ret c2_trunc fi cmnin
+end
+put cgni fi ni
+if or lt ni 1 gt ni 4096
+c2_a1 ni
+ret c2_fail crlin fi -1 cmnin2
+end
+for i long ni
+if ne c2_dinsn fi i 0
+ret -1
+end
+end
+e = c2_rtext
+if eq e -1
+ret c2_trunc fi cmreq
+end
+if lt e 0
+ret c2_fail crtext fi -1 cmreq
+end
+put cgrq fi e
+e = c2_rtext
+if eq e -1
+ret c2_trunc fi cmens
+end
+if lt e 0
+ret c2_fail crtext fi -1 cmens
+end
+put cgen fi e
+ret 0
+end
+
+fn c2_canon to long
+nf = get cnfn 0
+for g long nf
+if ne get cgk g 0
+ret cvkern
+end
+end
+for g long nf
+for k long get cgnv g
+x = get cts add mul g 481 k
+if or eq x 11 eq x 12
+ret 5
+end
+end
+end
+h3 = long 0
+for g long nf
+for i long get cgni g
+op = get cop add mul g 4096 i
+if and ge op cqpopen le op cqhstore
+ret 4
+end
+if and ge op cqaopen le op cqadest
+h3 = 1
+end
+end
+end
+if ne h3 0
+ret 3
+end
+if gt get cnst 0 0
+ret 2
+end
+ret 1
+end
+
+text cmagic "OSC1IR"
+
+fn c2_decode to long
+n = get cn 0
+if lt n 8
+ret c2_fail crmagic -1 -1 cmmagic
+end
+for i ulong 6
+if ne get cbuf i get cmagic i
+ret c2_fail crmagic -1 -1 cmmagic
+end
+end
+if ne get cbuf 6 0
+ret c2_fail crmagic -1 -1 cmmagic
+end
+v = long get cbuf 7
+put cver 0 v
+if not or and ge v 1 le v 5 eq v cvkern
+c2_a1 v
+ret c2_fail crver -1 -1 cmver
+end
+put cpos 0 8
+put cnst 0 0
+if ge v 2
+if ne c2_dstructs 0
+ret -1
+end
+end
+put cbad 0 0
+nf = c2_q16
+if ne get cbad 0 0
+ret c2_trunc -1 cmfcnt
+end
+put cnfn 0 nf
+if or lt nf 1 gt nf 32
+c2_a1 nf
+ret c2_fail crlfn -1 -1 cmnfn
+end
+for fi long nf
+if ne c2_dfunc fi 0
+ret -1
+end
+end
+p = get cpos 0
+if ne p n
+c2_a1 sub n p
+ret c2_fail crtrail -1 -1 cmtrail
+end
+cv2 = c2_canon
+if ne cv2 v
+c2_a2 v cv2
+ret c2_fail crnonc -1 -1 cmnonc
+end
+ret 0
+end
diff --git a/seed/oscgpu/c2glob.om b/seed/oscgpu/c2glob.om
new file mode 100644
index 000000000..82b42ef66
--- /dev/null
+++ b/seed/oscgpu/c2glob.om
@@ -0,0 +1,204 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2glob.om: checker2 in seeded Omega, part 1 of the unit (constants and tables).
+note Port of src/checker2/c2_ir.c (c2_decode) and src/checker2/c2_check.c (c2_check_unit) plus the
+note `check` command of src/checker2/checker2_main.c. The C stays as the differential oracle
+note (tests/checker2/om_diff.sh). checker2 is independent of the compiler's decoder by design, so this
+note unit shares no code with seed/oscgpu/oscir.om. Build order: tests/checker2/om_build.sh.
+note Names: globals and constants start with c, functions with c2_.
+om2
+
+note Opcodes (c2_ir.h C2Op). The kernel opcodes are separate constants: the wire numbering moved.
+const cqconst long 1
+const cqmov long 2
+const cqbin long 3
+const cqun long 4
+const cqcmp long 5
+const cqcast long 6
+const cqalloc long 7
+const cqrel long 8
+const cqload long 9
+const cqstore long 10
+const cqcall long 11
+const cqtrap long 12
+const cqbr long 13
+const cqcbr long 14
+const cqret long 15
+const cqfload long 16
+const cqfstore long 17
+const cqaopen long 18
+const cqaalloc long 19
+const cqadest long 20
+const cqpopen long 21
+const cqpclose long 22
+const cqhalloc long 23
+const cqhgen long 24
+const cqhfree long 25
+const cqhload long 26
+const cqhstore long 27
+const cqsload long 28
+const cqsstore long 29
+const cqgpu long 40
+const cqshared long 41
+const cqgload long 42
+const cqgstore long 43
+const cqsync long 44
+const cqshfl long 45
+const cqmad long 46
+note Version byte of a unit with a kernel (kind byte and thread count present iff this version).
+const cvkern long 8
+
+note Input: the first 16 MiB of the file (a canonical unit is under 3 MiB, so the decoder fails or
+note finishes before it could index past the stored prefix; an index past it traps 3, fail closed).
+global cbuf uchar 16777216
+global cn long 1
+global cpos long 1
+global cdig uchar 32
+global cbad long 1
+global crv ulong 1
+global cnm uchar 256
+global cnml long 1
+global cus long 8
+note Per-opcode classes (c2_init): operand layout on the wire, registers read, defines a register.
+global clay long 256
+global cuse long 256
+global cdop long 256
+
+note Unit header.
+global cver long 1
+global cnst long 1
+global cnfn long 1
+
+note Structs (16) and fields (slot k*16+f); names 64 bytes per entry.
+global csn uchar 1024
+global csnl long 16
+global csnf long 16
+global csnc long 16
+global cfn uchar 16384
+global cfnl long 256
+global cfs long 256
+global cfal long 256
+global cfof long 256
+
+note Functions (32).
+global cgn uchar 2048
+global cgnl long 32
+global cgk long 32
+global cgth long 32
+global cgnp long 32
+global cgnv long 32
+global cgnb long 32
+global cgni long 32
+global cgrq long 32
+global cgen long 32
+
+note Types: slot f*481+v for vreg v, slot f*481+480 for the return type.
+global cts long 15392
+global ctk long 15392
+global cte long 15392
+global ctl long 15392
+global cti long 15392
+
+note Instructions: slot f*4096+i; args at slot*6+k.
+global cop long 131072
+global csub long 131072
+global cnag long 131072
+global cdst long 131072
+global ca long 131072
+global cb long 131072
+global cc long 131072
+global ct long 131072
+global cf long 131072
+global ccal long 131072
+global cimm ulong 131072
+global carg long 786432
+
+note Blocks: slot f*512+b.
+global cbf long 16384
+global cbc long 16384
+
+note Verdict.
+global cfail long 1
+global cvf long 1
+global cvi long 1
+global crul uchar 64
+global crln long 1
+global cdet uchar 160
+global cdtn long 1
+note Format arguments: numbers in order, one u64 for %llu, names in order (see c2_oname).
+global cv long 4
+global cvu ulong 1
+global cvs long 2
+note Output staging buffer and its cap.
+global cob uchar 8192
+global cobn long 1
+global cocap long 1
+
+note Current function.
+global cfi long 1
+global cquiet long 1
+global cblk long 4096
+global csuc long 1024
+global cnsu long 512
+global creach long 512
+global cnd long 480
+global cdi long 480
+
+note Bitsets of 512 bits (8 words). Regions of cbs: dom 0, defined-in 4096, defined-out 8192,
+note pdom 12288, varying regions 16384, loops 20480, scratch sets from 24576 (8 words each).
+global cbs ulong 32768
+const cbdom long 0
+const cbdin long 4096
+const cbdout long 8192
+const cbpdom long 12288
+const cbreg long 16384
+const cbloop long 20480
+const cbt0 long 24576
+const cbt1 long 24584
+const cbt2 long 24592
+
+note check_loops / kernel_uniform scratch.
+global cinl long 512
+global ccol long 512
+global cstk long 4096
+global cidx long 512
+global cdivb long 512
+global cdone long 512
+global cvary long 480
+global cwl long 4096
+
+note Ownership: arena object, borrow origin, in-states (b*480+r), live blocks, current states.
+global coao long 480
+global coor long 480
+global coin long 245760
+global colv long 512
+global cst long 480
+
+note Races: expression nodes, memo, preds, phases, sync lines, accesses and their facts.
+global cnk long 4096
+global cna long 4096
+global cnb long 4096
+global cnh long 4096
+global cnv ulong 4096
+global cnn long 1
+global cthr long 1
+global cmemo long 480
+global cnpr long 512
+global cpin ulong 512
+global cpout ulong 512
+global csyn long 64
+global cnsy long 1
+global cxi long 4096
+global cxr long 4096
+global cxb long 4096
+global cxm ulong 4096
+global cxs long 4096
+global cxe long 4096
+note facts per access x: lt pairs at x*64+2k, fixes at x*32+k (id, value).
+global cxnl long 4096
+global cxnf long 4096
+global cxlt long 262144
+global cxfi long 131072
+global cxfv ulong 131072
+note digit lists (two of 1024)
+global cdgl long 2048
+global cdgn long 2
diff --git a/seed/oscgpu/c2gpu.om b/seed/oscgpu/c2gpu.om
new file mode 100644
index 000000000..5c03bfa41
--- /dev/null
+++ b/seed/oscgpu/c2gpu.om
@@ -0,0 +1,347 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2gpu.om: kernel_forbidden, kernel_ops and kernel_uniform of src/checker2/c2_check.c.
+
+text crgop "C2-GPU-OP"
+text cmghost "kernel instruction %u in a host function"
+text cmgnot "op %u is not allowed in a kernel"
+text crgsh "C2-GPU-SHARED"
+text cmshent "shared array outside the entry block"
+text cmshonce "shared array v%d defined more than once"
+text cmshby "shared arrays over %u bytes"
+text crgdiv "C2-GPU-DIV"
+text cmgdiv "kernel div/rem needs a nonzero constant divisor"
+text crgshfl "C2-GPU-SHFL"
+text cmgshfl "shuffle distance is not one constant 1..31"
+text crgsyl "C2-GPU-SYNC-LIMIT"
+text cmgsyl "more than %d sync lines"
+text crgnest "C2-GPU-NEST"
+text cmgnest "block %d sits %d varying regions deep (at most %d)"
+text crgsdv "C2-GPU-SYNC-DIVERGENT"
+text cmgsdv "sync or down in block %d, which not every thread reaches"
+text crgbnd "C2-GPU-BOUNDS"
+text cmgbnd "constant shared index outside declared length"
+
+fn c2_kforb op long to bool
+if or eq op cqalloc eq op cqrel
+ret true
+end
+if or eq op cqaopen eq op cqaalloc
+ret true
+end
+if or eq op cqadest eq op cqpopen
+ret true
+end
+if or eq op cqpclose eq op cqhalloc
+ret true
+end
+if or eq op cqhgen eq op cqhfree
+ret true
+end
+if or eq op cqhload eq op cqhstore
+ret true
+end
+if or eq op cqsload eq op cqsstore
+ret true
+end
+if or eq op cqfload eq op cqfstore
+ret true
+end
+ret eq op cqcall
+end
+
+note BIN MIN/MAX and UN EXP and above are kernel-only sub-ops.
+fn c2_gsub s long to bool
+op = get cop s
+sb = get csub s
+if eq op cqbin
+ret or eq sb 11 eq sb 12
+end
+if eq op cqun
+ret ge sb 4
+end
+ret false
+end
+
+fn c2_kops to long
+kern = ne get cgk get cfi 0 0
+put cxs 0 0
+put cnsy 0 0
+for i long c2_ni
+s = c2_is i
+op = get cop s
+if not kern
+if or and ge op cqgpu le op cqmad c2_gsub s
+c2_a1 op
+ret c2_fail crgop get cfi 0 i cmghost
+end
+else
+if lt c2_kop1 i s op 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+note one kernel instruction; the shared byte total lives in cxs[0], the sync count in cnsy[0].
+fn c2_kop1 i long s long op long to long
+fi = get cfi 0
+if c2_kforb op
+c2_a1 op
+ret c2_fail crgop fi i cmgnot
+end
+if eq op cqshared
+d = get cdst s
+if ne get cblk i 0
+ret c2_fail crgsh fi i cmshent
+end
+if ne get cnd d 1
+c2_a1 d
+ret c2_fail crgsh fi i cmshonce
+end
+tot = add get cxs 0 mul 4 get ctl c2_vs d
+put cxs 0 tot
+if gt tot 49152
+c2_a1 49152
+ret c2_fail crgsh fi i cmshby
+end
+ret 0
+end
+if eq op cqbin
+sb = get csub s
+if or eq sb 4 eq sb 5
+b = get cb s
+bad = lt b c2_np
+if not bad
+bad = not c2_sconst b
+end
+if not bad
+bad = eq c2_sval b ulong 0
+end
+if bad
+ret c2_fail crgdiv fi i cmgdiv
+end
+end
+ret 0
+end
+ret c2_kop2 i s op
+end
+
+fn c2_kop2 i long s long op long to long
+fi = get cfi 0
+if or eq op cqload eq op cqstore
+a = c2_vs get ca s
+b = get cb s
+if and eq get ctk a 4 c2_sconst b
+if ge c2_sval b ulong get ctl a
+ret c2_fail crgbnd fi i cmgbnd
+end
+end
+ret 0
+end
+if eq op cqshfl
+b = get cb s
+bad = not c2_sconst b
+if not bad
+k = c2_sval b
+bad = or lt k ulong 1 ge k ulong 32
+end
+if bad
+ret c2_fail crgshfl fi i cmgshfl
+end
+ret 0
+end
+if eq op cqsync
+n = add get cnsy 0 1
+put cnsy 0 n
+if gt n 63
+c2_a1 63
+ret c2_fail crgsyl fi i cmgsyl
+end
+end
+ret 0
+end
+
+note kernel_uniform. pdom at cbpdom + 8b, region at cbreg + 8b, divb cdivb, done cdone, vary cvary.
+fn c2_kuni to long
+nb = c2_nb
+for b long nb
+put cdivb b 0
+put cdone b 0
+c2_bzero add cbreg mul b 8
+c2_ball add cbpdom mul b 8
+if eq get cnsu b 0
+c2_bzero add cbpdom mul b 8
+c2_bset add cbpdom mul b 8 b
+end
+end
+for r long c2_nv
+put cvary r 0
+end
+c2_kpdom nb
+ch = true
+while ch bound 999999
+ch = false
+for b long nb
+if ne get creach b 0
+if c2_kvdefs b
+ch = true
+end
+if c2_kdiv b
+ch = true
+end
+end
+end
+end
+for b long nb
+if ne get creach b 0
+if lt c2_knest b nb 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_kpdom nb long to void
+ch = true
+while ch bound 999999
+ch = false
+b = sub nb 1
+while ge b 0 bound 513
+if c2_kpd1 b
+ch = true
+end
+b = sub b 1
+end
+end
+end
+
+fn c2_kpd1 b long to bool
+if eq get cnsu b 0
+ret false
+end
+c2_ball cbt0
+for k long get cnsu b
+c2_band cbt0 add cbpdom mul get csuc add mul b 2 k 8
+end
+c2_bset cbt0 b
+if c2_beq cbt0 add cbpdom mul b 8
+ret false
+end
+c2_bcpy add cbpdom mul b 8 cbt0
+ret true
+end
+
+note The vary pass over block b's instructions; true when any register became varying.
+fn c2_kvdefs b long to bool
+ch = false
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+d = c2_defs i
+if ge d 0
+if eq get cvary d 0
+if c2_kvary b i
+put cvary d 1
+ch = true
+end
+end
+end
+i = add i 1
+end
+ret ch
+end
+
+fn c2_kvary b long i long to bool
+if ne get cdivb b 0
+ret true
+end
+s = c2_is i
+op = get cop s
+if and eq op cqgpu eq get csub s 1
+ret true
+end
+if or or eq op cqgload eq op cqshfl eq op cqload
+ret true
+end
+nu = c2_uses i
+for k long nu
+if ne get cvary get cus k 0
+ret true
+end
+end
+ret false
+end
+
+note A CBR on a varying register opens block b's region (once); true when it did.
+fn c2_kdiv b long to bool
+t = c2_is c2_blast b
+if ne get cop t cqcbr
+ret false
+end
+if or eq get cvary get ca t 0 ne get cdone b 0
+ret false
+end
+put cdone b 1
+sp = c2_kpush b 0
+rg = add cbreg mul b 8
+while gt sp 0 bound 999999
+sp = sub sp 1
+c = get cstk sp
+if not c2_btest rg c
+if or eq c b not c2_btest add cbpdom mul b 8 c
+c2_bset rg c
+put cdivb c 1
+sp = c2_kpush c sp
+end
+end
+end
+ret true
+end
+
+fn c2_kpush c long sp0 long to long
+sp = sp0
+for k long get cnsu c
+put cstk sp get csuc add mul c 2 k
+sp = add sp 1
+end
+ret sp
+end
+
+fn c2_knest b long nb long to long
+nest = long 0
+for c long nb
+if ne get cdone c 0
+if c2_btest add cbreg mul c 8 b
+nest = add nest 1
+end
+end
+end
+if ne get cdone b 0
+if not c2_btest add cbreg mul b 8 b
+nest = add nest 1
+end
+end
+fi = get cfi 0
+if gt nest 16
+put cv 0 b
+put cv 1 nest
+put cv 2 16
+ret c2_fail crgnest fi c2_bfirst b cmgnest
+end
+if eq get cdivb b 0
+ret 0
+end
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+op = c2_op i
+if or eq op cqsync eq op cqshfl
+c2_a1 b
+ret c2_fail crgsdv fi i cmgsdv
+end
+i = add i 1
+end
+ret 0
+end
diff --git a/seed/oscgpu/c2ins.om b/seed/oscgpu/c2ins.om
new file mode 100644
index 000000000..fed3c8533
--- /dev/null
+++ b/seed/oscgpu/c2ins.om
@@ -0,0 +1,782 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2ins.om: check_insn of src/checker2/c2_check.c, one function per opcode group. Each returns 0
+note or the -1 of c2_fail. Operand types are slots (c2_vs); an operand outside 0..nv-1 never reaches
+note a slot read, because the C reads the same operands only after the same range checks.
+
+text cropr "C2-OPERAND-RANGE"
+text crslw "C2-SLICE-WRITE"
+text crgbuf "C2-GPU-BUFFER"
+text crtcon "C2-TYPE-CONST"
+text crccan "C2-CONST-CANONICAL"
+text crslesc "C2-SLICE-ESCAPE"
+text crtmov "C2-TYPE-MOV"
+text crsubop "C2-DECODE-SUBOP"
+text crtbin "C2-TYPE-BIN"
+text crtun "C2-TYPE-UN"
+text crtcmp "C2-TYPE-CMP"
+text crtcast "C2-TYPE-CAST"
+text crtall "C2-TYPE-ALLOC"
+text crtrel "C2-TYPE-RELEASE"
+text crtidx "C2-TYPE-INDEX"
+text crro "C2-READ-ONLY"
+text crtfld "C2-TYPE-FIELD"
+text crthnd "C2-TYPE-HANDLE"
+text cracap "C2-ARENA-CAPACITY"
+text crtpool "C2-TYPE-POOL"
+text crpcap "C2-POOL-CAPACITY"
+text crtslc "C2-TYPE-SLICE"
+text crtrap "C2-TRAP-CODE"
+text crcfgt "C2-CFG-TARGET"
+text crtcond "C2-TYPE-COND"
+text crtret "C2-TYPE-RET"
+text crcord "C2-CALL-ORDER"
+text crgcall "C2-GPU-CALL"
+text crtcall "C2-TYPE-CALL"
+text cralias "C2-CALL-ALIAS"
+text crtgpu "C2-TYPE-GPU"
+text crgsv "C2-GPU-STORE-VIEW"
+
+text cmopr "operand v%d out of range"
+text cmnodst "missing destination"
+text cmdstr "destination v%d out of range"
+text cmslrd "slice register v%d redefined"
+text cmsllrd "slice length register v%d redefined"
+text cmgbrd "buffer register v%d redefined"
+text cmgblrd "buffer length register v%d redefined"
+text cmcnsc "constant into a non-scalar register"
+text cmcncan "constant %llu not canonical for its type"
+text cmslcp "slice copied"
+text cmmovr "reference kinds or shapes do not bind"
+text cmmovt "MOV between different types"
+text cmbinop "binary op %u"
+text cmminmx "min/max need u32 or f32"
+text cmf32op "f32 binary op %u"
+text cmf32t "f32 operand types"
+text cmshift "shift operand types"
+text cmbitw "bitwise operand types"
+text cmarith "arithmetic operand types"
+text cmunop "unary op %u"
+text cmundif "unary result type differs from operand"
+text cmunty "unary operand type"
+text cmcmpop "comparison %u"
+text cmcmpt "comparison operand types"
+text cmcastf "f32 cast other than u32 <-> f32"
+text cmcasti "cast between non-integers (bool casts are refused)"
+text cmallo "allocation into a non-owner"
+text cmalinit "initial value type"
+text cmahnd "arena handle is not u64"
+text cmrel "release of a non-owner"
+text cmidxa "indexing a non-array"
+text cmidxi "index is not an integer"
+text cmidxe "element type"
+text cmstsh "store through a shared borrow"
+text cmfldns "field access on a non-struct"
+text cmfldn "field %llu of %s"
+text cmfldei "element index of field %s.%s"
+text cmfldt "type of field %s.%s"
+text cmfstsh "field store through a shared borrow"
+text cmhndl "handle is not u64"
+text cmpoolid "pool id is not u64"
+text cmpelt "pool element type %u"
+text cmpcap "pool of %u slots"
+text cmarcap "arena of %llu cells"
+text cmpalo "pool alloc operand types"
+text cmpgen "pool generation operand types"
+text cmpfree "pool free operand types"
+text cmpload "pool load operand types"
+text cmpsval "pool store value"
+text cmpstor "pool store operand types"
+text cmslnon "slice access through a non-slice register"
+text cmslro "store into a read-only bytes slice"
+text cmslidx "slice index is not an integer"
+text cmslel "slice element is u64"
+text cmtrap "trap code %llu"
+text cmbr "branch to block %u"
+text cmcbr "branch to block %u/%u"
+text cmcond "branch condition is not bool"
+text cmretv "return value type"
+text cmcord "call to function %u from function %d (no recursion, no forward calls)"
+text cmgcall "call into or out of a kernel"
+text cmcarit "%u arguments for %u parameters"
+text cmcret "call result type"
+text cmcbind "argument %d does not bind"
+text cmcslt "slice argument %d type"
+text cmcsll "slice argument %d is not passed with its own length"
+text cmcargt "argument %d type"
+text cmalias "register v%d passed twice and written"
+text cmgsub "launch value %u"
+text cmgu32 "launch value into a non-u32 register"
+text cmshty "shared array into a non-block register"
+text cmgbnon "buffer access through a non-buffer register"
+text cmgblen "buffer v%d has no u32 length register"
+text cmgbidx "buffer index is not u32"
+text cmgbel "buffer element type"
+text cmgsv "store into a view buffer"
+text cmshsub "shuffle %u"
+text cmshv "shuffle value is not u32 or f32"
+text cmshd "shuffle distance is not u32"
+text cmmad "mad needs f32 operands"
+text cmopc2 "opcode %u"
+
+fn c2_ff rule view uchar * ii long fmt view uchar * to long
+ret c2_fail rule get cfi 0 ii fmt
+end
+
+note Range of uses and destination, slice/buffer redefinition (the head of check_insn).
+fn c2_ihead ii long to long
+nv = c2_nv
+nu = c2_uses ii
+for k long nu
+u = get cus k
+if or lt u 0 ge u nv
+c2_a1 u
+ret c2_ff cropr ii cmopr
+end
+end
+s = c2_is ii
+op = get cop s
+dst = get cdst s
+d = c2_defs ii
+iscall = eq op cqcall
+nd = ne d -1
+if and iscall eq dst -1
+nd = false
+end
+if not iscall
+if and c2_defop op lt dst 0
+ret c2_ff cropr ii cmnodst
+end
+end
+if nd
+if or lt d 0 ge d nv
+c2_a1 d
+ret c2_ff cropr ii cmdstr
+end
+end
+if lt d 0
+ret 0
+end
+ret c2_iredef ii d
+end
+
+fn c2_iredef ii long d long to long
+np = c2_np
+c2_a1 d
+if c2_slice c2_vs d
+ret c2_ff crslw ii cmslrd
+end
+if and lt d np gt d 0
+if c2_slice c2_vs sub d 1
+ret c2_ff crslw ii cmsllrd
+end
+end
+if c2_gbuf c2_vs d
+ret c2_ff crgbuf ii cmgbrd
+end
+if and gt d 0 lt d np
+if c2_gbuf c2_vs sub d 1
+ret c2_ff crgbuf ii cmgblrd
+end
+end
+ret 0
+end
+
+fn c2_imov ii long td long ta long to long
+if or c2_slice ta c2_slice td
+ret c2_ff crslesc ii cmslcp
+end
+if or c2_isref td c2_isref ta
+if or not c2_shape td ta not c2_bind get ctk td get ctk ta
+ret c2_ff crtmov ii cmmovr
+end
+ret 0
+end
+if or not c2_same td ta not c2_scal td
+ret c2_ff crtmov ii cmmovt
+end
+ret 0
+end
+
+fn c2_ibin ii long sb long td long ta long tb long to long
+if or lt sb 1 ge sb 13
+c2_a1 sb
+ret c2_ff crsubop ii cmbinop
+end
+if or eq sb 11 eq sb 12
+if or or not c2_kv get cts td not c2_same td ta not c2_same td tb
+ret c2_ff crtbin ii cmminmx
+end
+ret 0
+end
+if or eq get cts td 13 eq get cts ta 13
+if not or or eq sb 1 eq sb 2 eq sb 3
+c2_a1 sb
+ret c2_ff crtbin ii cmf32op
+end
+if or not c2_same td ta not c2_same td tb
+ret c2_ff crtbin ii cmf32t
+end
+ret 0
+end
+if or eq sb 9 eq sb 10
+if or or not c2_int get cts td not c2_same td ta not c2_int get cts tb
+ret c2_ff crtbin ii cmshift
+end
+ret 0
+end
+if or or eq sb 6 eq sb 7 eq sb 8
+if or or not c2_scal td not c2_same td ta not c2_same td tb
+ret c2_ff crtbin ii cmbitw
+end
+ret 0
+end
+if or or not c2_int get cts td not c2_same td ta not c2_same td tb
+ret c2_ff crtbin ii cmarith
+end
+ret 0
+end
+
+fn c2_iun ii long sb long td long ta long to long
+if or lt sb 1 ge sb 8
+c2_a1 sb
+ret c2_ff crsubop ii cmunop
+end
+if not c2_same td ta
+ret c2_ff crtun ii cmundif
+end
+s = get cts td
+bad = ne s 13
+if eq sb 3
+bad = ne s 1
+end
+if eq sb 1
+bad = not or c2_int s eq s 13
+end
+if eq sb 2
+bad = not c2_int s
+end
+if bad
+ret c2_ff crtun ii cmunty
+end
+ret 0
+end
+
+fn c2_icmp ii long sb long td long ta long tb long to long
+if or lt sb 1 ge sb 7
+c2_a1 sb
+ret c2_ff crsubop ii cmcmpop
+end
+if or or ne get cts td 1 not c2_scal ta not c2_same ta tb
+ret c2_ff crtcmp ii cmcmpt
+end
+ret 0
+end
+
+fn c2_icast ii long td long ta long to long
+d = get cts td
+a = get cts ta
+if or eq d 13 eq a 13
+if not or and eq d 13 eq a 4 and eq d 4 eq a 13
+ret c2_ff crtcast ii cmcastf
+end
+ret 0
+end
+if or not c2_int d not c2_int a
+ret c2_ff crtcast ii cmcasti
+end
+ret 0
+end
+
+fn c2_ialloc ii long op long td long ta long tb long to long
+if or not c2_isref td ne get ctk td 1
+ret c2_ff crtall ii cmallo
+end
+bad = ne get cts ta 5
+if c2_isarr td
+bad = ne get cts ta get cte td
+end
+if bad
+ret c2_ff crtall ii cmalinit
+end
+if eq op cqaalloc
+if not c2_u64 tb
+ret c2_ff crtall ii cmahnd
+end
+end
+ret 0
+end
+
+fn c2_iidx ii long op long td long ta long tb long tc long to long
+if not c2_isarr ta
+ret c2_ff crtidx ii cmidxa
+end
+if not c2_int get cts tb
+ret c2_ff crtidx ii cmidxi
+end
+if eq op cqload
+if ne get cts td get cte ta
+ret c2_ff crtidx ii cmidxe
+end
+else
+if ne get cts tc get cte ta
+ret c2_ff crtidx ii cmidxe
+end
+end
+if and eq op cqstore eq get ctk ta 2
+ret c2_ff crro ii cmstsh
+end
+ret 0
+end
+
+note FLOAD/FSTORE. b is the raw element-index register (-1 none); tb its slot when in range, else -1.
+fn c2_ifld ii long td long ta long b long tc long to long
+if not c2_isstr ta
+ret c2_ff crtfld ii cmfldns
+end
+st = sub get cti ta 1
+imm = get cimm c2_is ii
+if ge imm ulong get csnf st
+put cvu 0 imm
+c2_s1 st
+ret c2_ff crtfld ii cmfldn
+end
+q = add mul st 16 long imm
+c2_s2 st add 100 q
+bad = ne b -1
+if ne get cfal q 0
+bad = true
+if ge b 0
+bad = not c2_int get cts c2_vs b
+end
+end
+if bad
+ret c2_ff crtfld ii cmfldei
+end
+ret c2_ifld2 ii td ta tc q
+end
+
+fn c2_ifld2 ii long td long ta long tc long q long to long
+fs = get cfs q
+op = c2_op ii
+if eq op cqfload
+if ne get cts td fs
+ret c2_ff crtfld ii cmfldt
+end
+else
+if ne get cts tc fs
+ret c2_ff crtfld ii cmfldt
+end
+end
+if eq op cqfstore
+if eq get ctk ta 2
+ret c2_ff crro ii cmfstsh
+end
+end
+ret 0
+end
+
+fn c2_ihandle ii long op long td long ta long tb long tc long to long
+s = c2_is ii
+if eq op cqaopen
+if not c2_u64 td
+ret c2_ff crthnd ii cmahnd
+end
+imm = get cimm s
+if or lt imm 1 gt imm 64
+put cvu 0 imm
+ret c2_ff cracap ii cmarcap
+end
+ret 0
+end
+if or eq op cqadest eq op cqpclose
+if not c2_u64 ta
+ret c2_ff crthnd ii cmhndl
+end
+ret 0
+end
+if eq op cqpopen
+if not c2_u64 td
+ret c2_ff crthnd ii cmpoolid
+end
+if not c2_val get csub s
+c2_a1 get csub s
+ret c2_ff crtpool ii cmpelt
+end
+n = get cnag s
+if or lt n 1 gt n 16
+c2_a1 n
+ret c2_ff crpcap ii cmpcap
+end
+ret 0
+end
+ret c2_ipool ii op td ta tb tc
+end
+
+fn c2_ipool ii long op long td long ta long tb long tc long to long
+if eq op cqhalloc
+ok = and c2_u64 td c2_u64 tb
+if not and ok c2_val get cts ta
+ret c2_ff crtpool ii cmpalo
+end
+ret 0
+end
+if eq op cqhgen
+if not c2_u64x3 td ta tb
+ret c2_ff crtpool ii cmpgen
+end
+ret 0
+end
+if eq op cqhfree
+if not c2_u64x3 ta tb tc
+ret c2_ff crtpool ii cmpfree
+end
+ret 0
+end
+if eq op cqhload
+ok2 = c2_u64x3 ta tb tc
+if not and ok2 c2_val get cts td
+ret c2_ff crtpool ii cmpload
+end
+ret 0
+end
+note HSTORE
+v = get carg mul c2_is ii 6
+if or lt v 0 ge v c2_nv
+ret c2_ff cropr ii cmpsval
+end
+if not c2_u64x3 ta tb tc
+ret c2_ff crtpool ii cmpstor
+end
+ret 0
+end
+
+fn c2_u64x3 x long y long z long to bool
+if not c2_u64 x
+ret false
+end
+if not c2_u64 y
+ret false
+end
+ret c2_u64 z
+end
+
+fn c2_islice ii long op long td long ta long tb long tc long to long
+if not c2_slice ta
+ret c2_ff crtslc ii cmslnon
+end
+if and eq op cqsstore ne get cts ta 12
+ret c2_ff crslw ii cmslro
+end
+if not c2_int get cts tb
+ret c2_ff crtslc ii cmslidx
+end
+bad = false
+if eq op cqsload
+bad = not c2_u64 td
+else
+bad = not c2_u64 tc
+end
+if bad
+ret c2_ff crtslc ii cmslel
+end
+ret 0
+end
+
+fn c2_ictl ii long op long ta long to long
+s = c2_is ii
+nb = c2_nb
+if eq op cqtrap
+imm = get cimm s
+if or lt imm 1 gt imm 14
+put cvu 0 imm
+ret c2_ff crtrap ii cmtrap
+end
+ret 0
+end
+if eq op cqbr
+if ge get ct s nb
+c2_a1 get ct s
+ret c2_ff crcfgt ii cmbr
+end
+ret 0
+end
+if eq op cqcbr
+if or ge get ct s nb ge get cf s nb
+c2_a2 get ct s get cf s
+ret c2_ff crcfgt ii cmcbr
+end
+if ne get cts ta 1
+ret c2_ff crtcond ii cmcond
+end
+ret 0
+end
+note RET
+rs = add mul get cfi 0 481 480
+a = get ca s
+bad = ne a -1
+if ne get cts rs 0
+bad = lt a 0
+if not bad
+bad = not c2_same c2_vs a rs
+end
+end
+if bad
+ret c2_ff crtret ii cmretv
+end
+ret 0
+end
+
+fn c2_icall ii long to long
+s = c2_is ii
+fi = get cfi 0
+g = get ccal s
+if ge g fi
+c2_a2 g fi
+ret c2_ff crcord ii cmcord
+end
+if or ne get cgk fi 0 ne get cgk g 0
+ret c2_ff crgcall ii cmgcall
+end
+n = get cnag s
+if ne n get cgnp g
+c2_a2 n get cgnp g
+ret c2_ff crarity ii cmcarit
+end
+rs = add mul g 481 480
+d = get cdst s
+bad = ne d -1
+if ne get cts rs 0
+bad = or lt d 0 ge d c2_nv
+if not bad
+bad = not c2_same c2_vs d rs
+end
+end
+if bad
+ret c2_ff crtcall ii cmcret
+end
+for k long n
+if ne c2_icarg ii s g k 0
+ret -1
+end
+end
+ret 0
+end
+
+fn c2_icarg ii long s long g long k long to long
+r = get carg add mul s 6 k
+pa = c2_vs r
+pp = add mul g 481 k
+c2_a1 k
+if c2_isref pp
+ok = c2_shape pa pp
+if not and ok c2_bind get ctk pp get ctk pa
+ret c2_ff crtcall ii cmcbind
+end
+else
+if c2_slice pp
+if ne get cts pa get cts pp
+ret c2_ff crtcall ii cmcslt
+end
+if c2_cslen s k r
+ret c2_ff crtcall ii cmcsll
+end
+else
+if not c2_same pa pp
+ret c2_ff crtcall ii cmcargt
+end
+end
+end
+ret c2_calias ii s g k
+end
+
+note true when the slice argument k (register r) is not followed by its length register r+1.
+fn c2_cslen s long k long r long to bool
+if ge add k 1 get cnag s
+ret true
+end
+q = get carg add mul s 6 add k 1
+ret ne q add r 1
+end
+
+fn c2_calias ii long s long g long k long to long
+pp = add mul g 481 k
+if not or c2_isref pp eq get cts pp 12
+ret 0
+end
+shp = ne get ctk pp 2
+for j long k
+if c2_aliasj s g j k shp
+c2_a1 get carg add mul s 6 k
+ret c2_ff cralias ii cmalias
+end
+end
+ret 0
+end
+
+fn c2_aliasj s long g long j long k long shp bool to bool
+base = mul s 6
+if ne get carg add base j get carg add base k
+ret false
+end
+if shp
+ret true
+end
+ret ne get ctk add mul g 481 j 2
+end
+
+fn c2_igpu ii long op long td long ta long tb long tc long to long
+s = c2_is ii
+if eq op cqgpu
+sb = get csub s
+if or lt sb 1 ge sb 6
+c2_a1 sb
+ret c2_ff crsubop ii cmgsub
+end
+if ne get cts td 4
+ret c2_ff crtgpu ii cmgu32
+end
+ret 0
+end
+if eq op cqshared
+if not c2_isblk td
+ret c2_ff crtgpu ii cmshty
+end
+ret 0
+end
+if or eq op cqgload eq op cqgstore
+if not c2_gbuf ta
+ret c2_ff crtgpu ii cmgbnon
+end
+a = get ca s
+if ne get cts c2_vs c2_i16 add a 1 4
+c2_a1 a
+ret c2_ff crtgpu ii cmgblen
+end
+if ne get cts tb 4
+ret c2_ff crtgpu ii cmgbidx
+end
+if eq op cqgload
+if ne get cts td get cte ta
+ret c2_ff crtgpu ii cmgbel
+end
+else
+if ne get cts tc get cte ta
+ret c2_ff crtgpu ii cmgbel
+end
+end
+if and eq op cqgstore ne get cts ta 15
+ret c2_ff crgsv ii cmgsv
+end
+ret 0
+end
+if eq op cqsync
+ret 0
+end
+if eq op cqshfl
+if ne get csub s 1
+c2_a1 get csub s
+ret c2_ff crsubop ii cmshsub
+end
+if or not c2_kv get cts ta not c2_same td ta
+ret c2_ff crtgpu ii cmshv
+end
+if ne get cts tb 4
+ret c2_ff crtgpu ii cmshd
+end
+ret 0
+end
+if eq op cqmad
+bad = ne get cts td 13
+if ne get cts ta 13
+bad = true
+end
+if ne get cts tb 13
+bad = true
+end
+if ne get cts tc 13
+bad = true
+end
+if bad
+ret c2_ff crtgpu ii cmmad
+end
+ret 0
+end
+c2_a1 op
+ret c2_ff cropc ii cmopc2
+end
+
+note Slot of register r when 0 <= r < nv, else -1 (the C's NULL type pointer, never read on a path
+note that reaches here with an out-of-range operand).
+fn c2_tslot r long to long
+if and ge r 0 lt r c2_nv
+ret c2_vs r
+end
+ret -1
+end
+
+fn c2_insn ii long to long
+if ne c2_ihead ii 0
+ret -1
+end
+s = c2_is ii
+op = get cop s
+sb = get csub s
+d = c2_defs ii
+td = c2_tslot d
+ta = c2_tslot get ca s
+tb = c2_tslot get cb s
+tc = c2_tslot get cc s
+if eq op cqconst
+if not c2_scal td
+ret c2_ff crtcon ii cmcnsc
+end
+if not c2_canonv get cts td get cimm s
+put cvu 0 get cimm s
+ret c2_ff crccan ii cmcncan
+end
+ret 0
+end
+if eq op cqmov
+ret c2_imov ii td ta
+end
+if eq op cqbin
+ret c2_ibin ii sb td ta tb
+end
+if eq op cqun
+ret c2_iun ii sb td ta
+end
+if eq op cqcmp
+ret c2_icmp ii sb td ta tb
+end
+if eq op cqcast
+ret c2_icast ii td ta
+end
+if or eq op cqalloc eq op cqaalloc
+ret c2_ialloc ii op td ta tb
+end
+if eq op cqrel
+if or not c2_isref ta ne get ctk ta 1
+ret c2_ff crtrel ii cmrel
+end
+ret 0
+end
+if or eq op cqload eq op cqstore
+ret c2_iidx ii op td ta tb tc
+end
+if or eq op cqfload eq op cqfstore
+ret c2_ifld ii td ta get cb s tc
+end
+if and ge op cqaopen le op cqhstore
+ret c2_ihandle ii op td ta tb tc
+end
+if or eq op cqsload eq op cqsstore
+ret c2_islice ii op td ta tb tc
+end
+if or or or eq op cqtrap eq op cqbr eq op cqcbr eq op cqret
+ret c2_ictl ii op ta
+end
+if eq op cqcall
+ret c2_icall ii
+end
+ret c2_igpu ii op td ta tb tc
+end
diff --git a/seed/oscgpu/c2main.om b/seed/oscgpu/c2main.om
new file mode 100644
index 000000000..a167a1a37
--- /dev/null
+++ b/seed/oscgpu/c2main.om
@@ -0,0 +1,588 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2main.om: check_func and c2_check_unit of src/checker2/c2_check.c and the `check` command of
+note src/checker2/checker2_main.c (judge, slurp, usage). Only `checker2 check <unit.ir>` is ported:
+note every other command line, `version` and `receipt ...` included, prints the C usage line and exits 2.
+note Output contract (equal to the C, compared by tests/checker2/om_diff.sh):
+note   stdout  checker2=ACCEPT ir_sha256=H                                             exit 0
+note           checker2=REJECT rule=R func=F insn=I ir_sha256=H detail=D              exit 1
+note   stderr  checker2: cannot open P: strerror(errno)   or   checker2: cannot read P  exit 2
+note   stderr  the usage line                                                         exit 2
+note H is the SHA-256 of every byte of the file. A file of 2^28 bytes or more is refused as unreadable,
+note exactly where slurp's doubling buffer stops (cap reaches 1 << 28 with the buffer full).
+
+text crfname "C2-FUNC-NAME"
+text cmfname "function %s defined twice"
+text crfpar "C2-FUNC-PARAMS"
+text cmfpar "%u parameters, %u registers"
+text crgkern "C2-GPU-KERNEL"
+text cmkvoid "a kernel returns nothing and carries no requires/ensures"
+text cmkthr "%u threads per block (32..1024, a multiple of 32)"
+text crfret "C2-FUNC-RETURN"
+text cmfret "function returns a non-scalar"
+text crtinv "C2-TYPE-INVALID"
+text cmtinv "register v%d has an invalid type"
+text crgtype "C2-GPU-TYPE"
+text cmgtyk "register v%d: type %u is not allowed in a kernel"
+text cmgtyh "register v%d: type %u is not allowed in a host function"
+text cmshpar "shared array v%d is a parameter"
+text cmgbpar "buffer register v%d is not a parameter followed by its u32 length"
+text cmgbsit "buffer v%d sits in the length register of v%d"
+text crslpar "C2-SLICE-PARAM"
+text cmslpar "slice register v%d is not a parameter followed by its u64 length"
+text cmslsit "slice v%d sits in the length register of v%d"
+
+note A buffer (u32 length, S_U32 4, rule C2-GPU-BUFFER) or slice (u64 length, S_U64 5, rule
+note C2-SLICE-PARAM) register x = slot of vreg r: a parameter followed by its length register, never
+note itself in the length register of an earlier one. The r + 1 test is first, as the C's ||.
+fn c2_fbuf fi long r long x long np long to long
+bad = ge add r 1 np
+if not bad
+bad = ne get cts add x 1 4
+end
+if bad
+c2_a1 r
+ret c2_fail crgbuf fi -1 cmgbpar
+end
+if gt r 0
+if c2_gbuf sub x 1
+c2_a2 r sub r 1
+ret c2_fail crgbuf fi -1 cmgbsit
+end
+end
+ret 0
+end
+
+fn c2_fsl fi long r long x long np long to long
+bad = ge add r 1 np
+if not bad
+bad = ne get cts add x 1 5
+end
+if bad
+c2_a1 r
+ret c2_fail crslpar fi -1 cmslpar
+end
+if gt r 0
+if c2_slice sub x 1
+c2_a2 r sub r 1
+ret c2_fail crslpar fi -1 cmslsit
+end
+end
+ret 0
+end
+
+note One register of check_func's type loop (C 1532-1552).
+fn c2_freg fi long r long kern bool to long
+x = add mul fi 481 r
+np = get cgnp fi
+if not c2_ctype x
+c2_a1 r
+ret c2_fail crtinv fi -1 cmtinv
+end
+s = get cts x
+kt = or or c2_gbuf x c2_isblk x eq s 13
+if kern
+if not or or kt eq s 1 eq s 4
+c2_a2 r s
+ret c2_fail crgtype fi -1 cmgtyk
+end
+else
+if kt
+c2_a2 r s
+ret c2_fail crgtype fi -1 cmgtyh
+end
+end
+if c2_isblk x
+if lt r np
+c2_a1 r
+ret c2_fail crgsh fi -1 cmshpar
+end
+end
+if c2_gbuf x
+ret c2_fbuf fi r x np
+end
+if c2_slice x
+ret c2_fsl fi r x np
+end
+ret 0
+end
+
+note check_func's header checks (C 1521-1552).
+fn c2_fhdr fi long to long
+for g long fi
+if c2_gnameq g fi
+c2_s1 add 1000 fi
+ret c2_fail crfname fi -1 cmfname
+end
+end
+kern = ne get cgk fi 0
+np = get cgnp fi
+nv = get cgnv fi
+mx = long 6
+if kern
+mx = 32
+end
+if or gt np mx gt np nv
+c2_a2 np nv
+ret c2_fail crfpar fi -1 cmfpar
+end
+rs = get cts add mul fi 481 480
+if kern
+if or or ne rs 0 ne get cgrq fi 0 ne get cgen fi 0
+ret c2_fail crgkern fi -1 cmkvoid
+end
+th = get cgth fi
+if or or lt th 32 gt th 1024 ne rem th 32 0
+c2_a1 th
+ret c2_fail crgkern fi -1 cmkthr
+end
+end
+if not or eq rs 0 c2_val rs
+ret c2_fail crfret fi -1 cmfret
+end
+for r long nv
+if ne c2_freg fi r kern 0
+ret -1
+end
+end
+ret 0
+end
+
+note The C allocates its per-function context Fx with calloc: blk_of, succ, nsucc, reach, dom, ndefs,
+note def_insn and quiet start at zero for every function. These are their globals.
+fn c2_freset to void
+for i long 4096
+put cblk i 0
+end
+for i long 32768
+put cbs i 0
+end
+for i long 1024
+put csuc i 0
+end
+for i long 512
+put cnsu i 0
+put creach i 0
+end
+for i long 480
+put cnd i 0
+put cdi i 0
+end
+put cquiet 0 0
+end
+
+note check_func (C 1518-1576): the phases in the C's order, the first failure wins.
+fn c2_cfunc fi long to long
+put cfi 0 fi
+if ne c2_fhdr fi 0
+ret -1
+end
+kern = ne get cgk fi 0
+c2_freset
+if ne c2_bcfg 0
+ret -1
+end
+for i long c2_ni
+if ne c2_insn i 0
+ret -1
+end
+end
+c2_lcfg
+c2_cdefs
+if ne c2_kops 0
+ret -1
+end
+if kern
+if ne c2_kuni 0
+ret -1
+end
+end
+if ne c2_hands 0
+ret -1
+end
+if ne c2_cdef 0
+ret -1
+end
+if ne c2_loops 0
+ret -1
+end
+if ne c2_own 0
+ret -1
+end
+if kern
+if ne c2_races 0
+ret -1
+end
+end
+ret 0
+end
+
+fn c2_cunit to long
+if ne c2_cstructs 0
+ret -1
+end
+for fi long get cnfn 0
+if ne c2_cfunc fi 0
+ret -1
+end
+end
+ret 0
+end
+
+note ---------------------------------------------------------------- command line
+
+text cusage "usage: checker2 check <unit.ir> | version | receipt issue|tbs|attach|verify ... (see source header)\n"
+text ccheck "check"
+text cpre "checker2: "
+text copen "cannot open "
+text cread "cannot read "
+text ccolon ": "
+text cnl "\n"
+text cacc "checker2=ACCEPT ir_sha256="
+text crej "checker2=REJECT rule="
+text cfunc " func="
+text cinsn " insn="
+text csha " ir_sha256="
+text cdetl " detail="
+text chex "0123456789abcdef"
+note glibc strerror texts for the errnos open(O_RDONLY) can return; any other is "Unknown error N".
+text ce1 "Operation not permitted"
+text ce2 "No such file or directory"
+text ce4 "Interrupted system call"
+text ce5 "Input/output error"
+text ce6 "No such device or address"
+text ce12 "Cannot allocate memory"
+text ce13 "Permission denied"
+text ce14 "Bad address"
+text ce16 "Device or resource busy"
+text ce19 "No such device"
+text ce20 "Not a directory"
+text ce21 "Is a directory"
+text ce22 "Invalid argument"
+text ce23 "Too many open files in system"
+text ce24 "Too many open files"
+text ce26 "Text file busy"
+text ce27 "File too large"
+text ce30 "Read-only file system"
+text ce36 "File name too long"
+text ce40 "Too many levels of symbolic links"
+text ce75 "Value too large for defined data type"
+text ce95 "Operation not supported"
+text ce11 "Resource temporarily unavailable"
+text ceunk "Unknown error "
+
+note The path argument (Linux caps one argument at 128 KiB, MAX_ARG_STRLEN) and its length.
+global cpth uchar 131072
+global cptn long 1
+
+note Writes all of cob[0 .. cobn) to fd. A failed or empty write ends it, as printf's result is ignored.
+fn c2_flush fd int to void
+n = get cobn 0
+o = long 0
+while lt o n bound 999999
+k = write fd cob ulong o ulong sub n o
+if le k 0
+break
+end
+o = add o k
+end
+put cobn 0 0
+end
+
+fn c2_ostart to void
+put cobn 0 0
+put cocap 0 8192
+end
+
+fn c2_opath to void
+for i long get cptn 0
+c2_oc get cpth i
+if eq get cobn 0 8192
+c2_flush 2
+end
+end
+end
+
+fn c2_strerr e long to void
+if eq e 1
+c2_ot ce1
+ret
+end
+if eq e 2
+c2_ot ce2
+ret
+end
+if eq e 4
+c2_ot ce4
+ret
+end
+if eq e 5
+c2_ot ce5
+ret
+end
+if eq e 6
+c2_ot ce6
+ret
+end
+if eq e 11
+c2_ot ce11
+ret
+end
+if eq e 12
+c2_ot ce12
+ret
+end
+if eq e 13
+c2_ot ce13
+ret
+end
+c2_strer2 e
+end
+
+fn c2_strer2 e long to void
+if eq e 14
+c2_ot ce14
+ret
+end
+if eq e 16
+c2_ot ce16
+ret
+end
+if eq e 19
+c2_ot ce19
+ret
+end
+if eq e 20
+c2_ot ce20
+ret
+end
+if eq e 21
+c2_ot ce21
+ret
+end
+if eq e 22
+c2_ot ce22
+ret
+end
+if eq e 23
+c2_ot ce23
+ret
+end
+if eq e 24
+c2_ot ce24
+ret
+end
+c2_strer3 e
+end
+
+fn c2_strer3 e long to void
+if eq e 26
+c2_ot ce26
+ret
+end
+if eq e 27
+c2_ot ce27
+ret
+end
+if eq e 30
+c2_ot ce30
+ret
+end
+if eq e 36
+c2_ot ce36
+ret
+end
+if eq e 40
+c2_ot ce40
+ret
+end
+if eq e 75
+c2_ot ce75
+ret
+end
+if eq e 95
+c2_ot ce95
+ret
+end
+c2_ot ceunk
+c2_od e
+end
+
+note "checker2: cannot open P: E\n" (e > 0, the errno) on stderr; exit 2.
+fn c2_nopen e long to int
+c2_ostart
+c2_ot cpre
+c2_ot copen
+c2_flush 2
+c2_opath
+c2_ot ccolon
+c2_strerr e
+c2_ot cnl
+c2_flush 2
+ret 2
+end
+
+note "checker2: cannot read P\n" on stderr; exit 2.
+fn c2_nread to int
+c2_ostart
+c2_ot cpre
+c2_ot cread
+c2_flush 2
+c2_opath
+c2_ot cnl
+c2_flush 2
+ret 2
+end
+
+fn c2_usage to int
+c2_ostart
+c2_ot cusage
+c2_flush 2
+ret 2
+end
+
+note Lower-case hex of the 32 digest bytes.
+fn c2_ohex d view uchar 32 to void
+for i ulong 32
+x = get d i
+c2_oc get chex ulong shr x 4
+c2_oc get chex ulong and x 15
+end
+end
+
+note Appends k bytes of chunk to cbuf from position t while they fit in its 16 MiB.
+fn c2_keep b view uchar 65536 t long k long to void
+for i long k
+p = add t i
+if ge p 16777216
+ret
+end
+put cbuf p get b i
+end
+end
+
+note Reads the file at the path: every byte into the hash, the first 16 MiB into cbuf, cn the total.
+note Returns 0, -1 cannot open (errno in crv), -2 cannot read. A read error or 2^28 bytes is -2,
+note after the C: slurp's buffer doubles from 64 KiB and gives up full at 1 << 28 bytes.
+note Bounds: each pass of the inner loop adds at least one byte or ends the read, and the file stops
+note at 2^28 bytes, so 1024 x 999999 passes are more than enough; a slower source traps 4 (fail closed).
+fn c2_slurp hc edit shactx to long
+n = get cptn 0
+if eq n 0
+put crv 0 2
+ret -1
+end
+if gt n 4095
+put crv 0 36
+ret -1
+end
+fd = fopen cpth 0 ulong n 0 0
+if lt fd 0
+put crv 0 ulong neg fd
+ret -1
+end
+b = new uchar 65536 0
+t = long 0
+st = long 1
+for j long 1024
+if ne st 1
+break
+end
+while true bound 999999
+k = read int fd b 0 65536
+if lt k 0
+st = -2
+break
+end
+if eq k 0
+st = 0
+break
+end
+c2_h2 hc b k
+c2_keep b t k
+t = add t k
+if ge t 268435456
+st = -2
+break
+end
+end
+end
+r = fclose int fd
+put cn 0 t
+ret st
+end
+
+fn c2_h2 hc edit shactx b view uchar 65536 k long to void
+c2h_upd hc part b 0 ulong k
+end
+
+note judge (C 126-143): decode, check, print the verdict line.
+fn c2_judge to int
+hc = new uchar 104 0
+dg = new uchar 32 0
+c2h_init hc
+s = c2_slurp hc
+if eq s -1
+ret c2_nopen long get crv 0
+end
+if ne s 0
+ret c2_nread
+end
+c2h_final hc dg
+put cfail 0 0
+rc = c2_decode
+if eq rc 0
+rc = c2_cunit
+end
+c2_ostart
+if eq rc 0
+c2_ot cacc
+c2_ohex dg
+c2_ot cnl
+c2_flush 1
+ret 0
+end
+c2_ot crej
+for i long get crln 0
+c2_oc get crul i
+end
+c2_ot cfunc
+c2_od get cvf 0
+c2_ot cinsn
+c2_od get cvi 0
+c2_ot csha
+c2_ohex dg
+c2_ot cdetl
+for i long get cdtn 0
+c2_oc get cdet i
+end
+c2_ot cnl
+c2_flush 1
+ret 1
+end
+
+fn main to int
+c2_init
+na = argcnt
+if lt na 2
+ret c2_usage
+end
+w = new uchar 8 0
+k = argread 1 w 0 8
+if ne k 5
+ret c2_usage
+end
+for i ulong 5
+if ne get w i get ccheck i
+ret c2_usage
+end
+end
+if ne na 3
+ret c2_usage
+end
+k = argread 2 cpth 0 131072
+if lt k 0
+ret c2_usage
+end
+put cptn 0 k
+ret c2_judge
+end
diff --git a/seed/oscgpu/c2out.om b/seed/oscgpu/c2out.om
new file mode 100644
index 000000000..9382cf607
--- /dev/null
+++ b/seed/oscgpu/c2out.om
@@ -0,0 +1,147 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2out.om: output staging and the verdict formatter (the vsnprintf of c2_check.c fail(), with a
+note 160-byte detail buffer: at most 159 bytes kept). Appenders write into cob up to cocap bytes.
+
+fn c2_oc x uchar to void
+n = get cobn 0
+if lt n get cocap 0
+put cob n x
+put cobn 0 add n 1
+end
+end
+
+fn c2_ot s view uchar * to void
+for i ulong len s
+c2_oc get s i
+end
+end
+
+fn c2_ou v ulong to void
+d = new uchar 24 0
+n = long 0
+x = v
+while true bound 30
+put d n uchar add 48 rem x 10
+n = add n 1
+x = div x 10
+if eq x 0
+break
+end
+end
+while gt n 0 bound 30
+n = sub n 1
+c2_oc get d n
+end
+end
+
+fn c2_od v long to void
+if lt v 0
+c2_oc 45
+c2_ou ulong neg v
+ret
+end
+c2_ou ulong v
+end
+
+note Name references: 0..15 struct k, 100 + k*16 + f field f of struct k, 1000 + fi function fi.
+fn c2_oname r long to void
+if lt r 100
+for i long get csnl r
+c2_oc get csn add mul r 64 i
+end
+ret
+end
+if lt r 1000
+q = sub r 100
+for i long get cfnl q
+c2_oc get cfn add mul q 64 i
+end
+ret
+end
+g = sub r 1000
+for i long get cgnl g
+c2_oc get cgn add mul g 64 i
+end
+end
+
+note Formats fmt with cv (in order for %d %u %zu), cvu (%llu) and cvs (%s) into cob from 0.
+fn c2_fmt fmt view uchar * to void
+k = long 0
+q = long 0
+i = ulong 0
+n = len fmt
+while lt i n bound 999999
+x = get fmt i
+if ne x 37
+c2_oc x
+i = add i 1
+continue
+end
+y = get fmt add i 1
+if eq y 100
+c2_od get cv k
+k = add k 1
+i = add i 2
+continue
+end
+if eq y 117
+c2_ou ulong get cv k
+k = add k 1
+i = add i 2
+continue
+end
+if eq y 122
+c2_ou ulong get cv k
+k = add k 1
+i = add i 3
+continue
+end
+if eq y 115
+c2_oname get cvs q
+q = add q 1
+i = add i 2
+continue
+end
+note %llu
+c2_ou get cvu 0
+i = add i 4
+end
+end
+
+note Record the first failure: rule, function, instruction, formatted detail. Returns -1.
+fn c2_fail rule view uchar * fi long ii long fmt view uchar * to long
+put cfail 0 1
+put cvf 0 fi
+put cvi 0 ii
+for i ulong len rule
+put crul i get rule i
+end
+put crln 0 long len rule
+put cobn 0 0
+put cocap 0 159
+c2_fmt fmt
+n = get cobn 0
+for i long n
+put cdet i get cob i
+end
+put cdtn 0 n
+ret -1
+end
+
+fn c2_a1 x long to void
+put cv 0 x
+end
+
+fn c2_a2 x long y long to void
+put cv 0 x
+put cv 1 y
+end
+
+fn c2_s1 x long to void
+put cvs 0 x
+end
+
+fn c2_s2 x long y long to void
+put cvs 0 x
+put cvs 1 y
+end
diff --git a/seed/oscgpu/c2own.om b/seed/oscgpu/c2own.om
new file mode 100644
index 000000000..4441fec21
--- /dev/null
+++ b/seed/oscgpu/c2own.om
@@ -0,0 +1,450 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2own.om: check_ownership of src/checker2/c2_check.c (own_use, own_kill, own_birth, own_step).
+note May-states: 1 not yet holding / not opened, 2 live / open, 4 dead / closed. coao arena object
+note (its arena handle or -1), coor borrow origin, coin in-states at b*480+r, colv live blocks,
+note cst the current states. In the quiet pass (cquiet[0] = 1) every report is skipped and the
+note transfer goes on, exactly like the C's OF macro.
+
+text crodead "C2-OWN-USE-DEAD"
+text cmouse "owner v%d used after it was released or moved (every path)"
+text cmomove "owner v%d moved after it was released or moved (every path)"
+text crobor "C2-BORROW-OUTLIVES-OWNER"
+text cmobor "borrow v%d used after its owner v%d is gone (every path)"
+text crolk "C2-OWN-LEAK"
+text cmoover "owner v%d overwritten while it still holds an object (every path)"
+text croad "C2-ARENA-DEAD"
+text cmoad "allocation from arena v%d after it was destroyed (every path)"
+text crorel "C2-OWN-RELEASE-ARENA"
+text cmorel "release of arena object v%d"
+text crodbl "C2-OWN-DOUBLE-RELEASE"
+text cmodbl "v%d released when it holds nothing (every path)"
+text croam "C2-OWN-ARENA-MOVE"
+text cmoam "move involving arena object"
+text cmoamp "arena object v%d passed to an own parameter"
+text cmoboth "register v%d holds both arena and pool objects"
+text crhre "C2-HANDLE-REOPEN"
+text cmhre "handle v%d reopened while open"
+text crhdc "C2-HANDLE-DOUBLE-CLOSE"
+text cmhdc "handle v%d closed when not open (every path)"
+text crhdd "C2-HANDLE-DEAD"
+text cmhdd "pool v%d used when not open (every path)"
+text crhlk "C2-HANDLE-LEAK"
+text cmhlk "v%d still open at return (every path)"
+text cmolk "v%d still owns an object at return (every path)"
+
+fn c2_track r long to bool
+x = c2_vs r
+ret and eq get cts x 10 eq get ctk x 1
+end
+
+fn c2_quiet to bool
+ret ne get cquiet 0 0
+end
+
+fn c2_nlive r long to bool
+ret eq and get cst r 2 0
+end
+
+fn c2_ouse i long r long to long
+if and c2_track r c2_nlive r
+if not c2_quiet
+c2_a1 r
+ret c2_fail crodead get cfi 0 i cmouse
+end
+end
+g = get coor r
+if ge g 0
+if c2_nlive g
+if not c2_quiet
+c2_a2 r g
+ret c2_fail crobor get cfi 0 i cmobor
+end
+end
+end
+ret 0
+end
+
+fn c2_okill i long r long to long
+if c2_nlive r
+if not c2_quiet
+c2_a1 r
+ret c2_fail crodead get cfi 0 i cmomove
+end
+end
+put cst r 4
+ret 0
+end
+
+fn c2_obirth i long r long to long
+if eq get cst r 2
+if not c2_quiet
+c2_a1 r
+ret c2_fail crolk get cfi 0 i cmoover
+end
+end
+put cst r 2
+ret 0
+end
+
+fn c2_ostep i long to long
+s = c2_is i
+op = get cop s
+if eq op cqalloc
+ret c2_obirth i get cdst s
+end
+if eq op cqaalloc
+b = get cb s
+if and c2_nlive b not c2_quiet
+c2_a1 b
+ret c2_fail croad get cfi 0 i cmoad
+end
+ret c2_obirth i get cdst s
+end
+if eq op cqrel
+ret c2_orel i get ca s
+end
+if eq op cqmov
+ret c2_omov i s
+end
+if or or eq op cqload eq op cqstore or eq op cqfload eq op cqfstore
+ret c2_ouse i get ca s
+end
+if eq op cqcall
+ret c2_ocall i s
+end
+ret c2_ostep2 i s op
+end
+
+fn c2_orel i long a long to long
+if and ge get coao a 0 not c2_quiet
+c2_a1 a
+ret c2_fail crorel get cfi 0 i cmorel
+end
+if and c2_nlive a not c2_quiet
+c2_a1 a
+ret c2_fail crodbl get cfi 0 i cmodbl
+end
+put cst a 4
+ret 0
+end
+
+fn c2_omov i long s long to long
+a = get ca s
+d = get cdst s
+if c2_track a
+if eq get ctk c2_vs d 1
+if or ge get coao a 0 ge get coao d 0
+if not c2_quiet
+ret c2_fail croam get cfi 0 i cmoam
+end
+end
+if ne c2_okill i a 0
+ret -1
+end
+ret c2_obirth i d
+end
+ret c2_ouse i a
+end
+if c2_isref c2_vs a
+ret c2_ouse i a
+end
+ret 0
+end
+
+fn c2_ocall i long s long to long
+g = get ccal s
+for k long get cnag s
+r = get carg add mul s 6 k
+if c2_isref c2_vs r
+if ne c2_ouse i r 0
+ret -1
+end
+if eq get ctk add mul g 481 k 1
+if ne c2_ocarg i r 0
+ret -1
+end
+end
+end
+end
+ret 0
+end
+
+fn c2_ocarg i long r long to long
+if and ge get coao r 0 not c2_quiet
+c2_a1 r
+ret c2_fail croam get cfi 0 i cmoamp
+end
+ret c2_okill i r
+end
+
+fn c2_ostep2 i long s long op long to long
+if or eq op cqaopen eq op cqpopen
+d = get cdst s
+if and ne and get cst d 2 0 not c2_quiet
+c2_a1 d
+ret c2_fail crhre get cfi 0 i cmhre
+end
+put cst d 2
+ret 0
+end
+if or eq op cqadest eq op cqpclose
+ret c2_oclose i s op
+end
+if or or eq op cqhalloc eq op cqhgen or eq op cqhfree eq op cqhload
+ret c2_opool i s op
+end
+if eq op cqhstore
+ret c2_opool i s op
+end
+if eq op cqret
+ret c2_oret i
+end
+ret 0
+end
+
+fn c2_oclose i long s long op long to long
+a = get ca s
+if and c2_nlive a not c2_quiet
+c2_a1 a
+ret c2_fail crhdc get cfi 0 i cmhdc
+end
+put cst a 4
+if eq op cqadest
+for r long c2_nv
+if and eq get coao r a ne get cst r 1
+put cst r 4
+end
+end
+end
+ret 0
+end
+
+fn c2_opool i long s long op long to long
+h = get ca s
+if eq op cqhalloc
+h = get cb s
+end
+if and c2_nlive h not c2_quiet
+c2_a1 h
+ret c2_fail crhdd get cfi 0 i cmhdd
+end
+ret 0
+end
+
+fn c2_oret i long to long
+for r long c2_nv
+if eq get cst r 2
+if lt c2_oret1 i r 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_oret1 i long r long to long
+hd = false
+di = get cdi r
+if ge di 0
+op = c2_op di
+hd = or eq op cqaopen eq op cqpopen
+end
+if c2_quiet
+ret 0
+end
+if hd
+c2_a1 r
+ret c2_fail crhlk get cfi 0 i cmhlk
+end
+if and c2_track r lt get coao r 0
+c2_a1 r
+ret c2_fail crolk get cfi 0 i cmolk
+end
+ret 0
+end
+
+fn c2_own to long
+nv = c2_nv
+for r long nv
+put coao r -1
+put coor r -1
+end
+for i long c2_ni
+s = c2_is i
+if eq get cop s cqaalloc
+put coao get cdst s get cb s
+end
+end
+for i long c2_ni
+if c2_oboth i
+c2_a1 get cdst c2_is i
+ret c2_fail croam get cfi 0 i cmoboth
+end
+end
+c2_origin
+for r long nv
+if eq get coor r -2
+put coor r -1
+end
+end
+c2_oflow
+put cquiet 0 0
+for b long c2_nb
+if ne get colv b 0
+if lt c2_orep b 0
+ret -1
+end
+end
+end
+ret 0
+end
+
+fn c2_oboth i long to bool
+s = c2_is i
+op = get cop s
+d = get cdst s
+if eq op cqalloc
+ret ge get coao d 0
+end
+if eq op cqaalloc
+ret ne get coao d get cb s
+end
+ret false
+end
+
+fn c2_origin to void
+ch = true
+while ch bound 999999
+ch = false
+for i long c2_ni
+if c2_orig1 i
+ch = true
+end
+end
+end
+end
+
+fn c2_orig1 i long to bool
+s = c2_is i
+if ne get cop s cqmov
+ret false
+end
+d = get cdst s
+x = c2_vs d
+if or not c2_isref x eq get ctk x 1
+ret false
+end
+a = get ca s
+root = get coor a
+if eq get ctk c2_vs a 1
+root = a
+end
+cur = get coor d
+nw = long -2
+if and eq cur -1 ge root 0
+nw = root
+else
+if eq cur root
+nw = cur
+end
+end
+if lt d c2_np
+nw = -2
+end
+if and ne nw cur ne cur -2
+put coor d nw
+ret true
+end
+ret false
+end
+
+fn c2_oflow to void
+nv = c2_nv
+nb = c2_nb
+for b long nb
+put colv b 0
+for r long nv
+put coin add mul b 480 r 0
+end
+end
+for r long nv
+put coin r 1
+if lt r c2_np
+if c2_track r
+put coin r 2
+end
+end
+end
+put colv 0 1
+put cquiet 0 1
+ch = true
+while ch bound 999999
+ch = false
+for b long nb
+if ne get colv b 0
+if c2_oblk b
+ch = true
+end
+end
+end
+end
+end
+
+note The quiet transfer of block b; true when a successor's live flag or in-state grew.
+fn c2_oblk b long to bool
+nv = c2_nv
+for r long nv
+put cst r get coin add mul b 480 r
+end
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+if eq c2_op i cqtrap
+ret false
+end
+z = c2_ostep i
+i = add i 1
+end
+ch = false
+for k long get cnsu b
+if c2_omerge get csuc add mul b 2 k nv
+ch = true
+end
+end
+ret ch
+end
+
+fn c2_omerge sc long nv long to bool
+ch = false
+if eq get colv sc 0
+put colv sc 1
+ch = true
+end
+for r long nv
+o = add mul sc 480 r
+m = or get coin o get cst r
+if ne m get coin o
+put coin o m
+ch = true
+end
+end
+ret ch
+end
+
+fn c2_orep b long to long
+for r long c2_nv
+put cst r get coin add mul b 480 r
+end
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+if eq c2_op i cqtrap
+ret 0
+end
+if lt c2_ostep i 0
+ret -1
+end
+i = add i 1
+end
+ret 0
+end
diff --git a/seed/oscgpu/c2race.om b/seed/oscgpu/c2race.om
new file mode 100644
index 000000000..e2f42331e
--- /dev/null
+++ b/seed/oscgpu/c2race.om
@@ -0,0 +1,1063 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2race.om: kernel_races of src/checker2/c2_check.c (C2-GPU-SHARED-RACE, C2-GPU-GLOBAL-RACE).
+note Nodes: cnk kind, cna a, cnb b, cnh h, cnv v; cnn[0] the count (node 0 is the opaque tree).
+note Kinds: 0 OPAQUE 1 CONST 2 INV 3 THREAD 4 BLOCK 5 BATCH 6 LO 7 HI 8 LOOP 9 ADD 10 MUL 11 DIV 12 REM.
+note Natural loops at cbloop + 8h. Accesses x: cxi insn, cxr ref, cxb block, cxm phase mask,
+note cxs store, cxe tree; facts: cxnl/cxlt (lt pairs at x*64+2k), cxnf/cxfi/cxfv (fixes at x*32+k).
+note Digit lists: cdgl slot sl at sl*1024, count cdgn[sl]. A BIN's operand trees are built a then b.
+
+text crshr "C2-GPU-SHARED-RACE"
+text crglr "C2-GPU-GLOBAL-RACE"
+text cmrdiff "v%d is accessed at two different indexes (insns %u and %u)"
+text cmrinj "the index of v%d is not one-to-one"
+text cmrloop "a loop counter is used as an index outside its loop"
+text cmrcov "two threads can reach the same element of v%d"
+
+fn c2_mk4 k long a long b long h long v ulong to long
+nn = get cnn 0
+for i long nn
+if gt i 0
+if c2_ndeq i k a b h
+if eq get cnv i v
+ret i
+end
+end
+end
+end
+if ge nn 4096
+ret 0
+end
+put cnk nn k
+put cna nn a
+put cnb nn b
+put cnh nn h
+put cnv nn v
+put cnn 0 add nn 1
+ret nn
+end
+
+fn c2_ndeq i long k long a long b long h long to bool
+if ne get cnk i k
+ret false
+end
+if ne get cna i a
+ret false
+end
+if ne get cnb i b
+ret false
+end
+ret eq get cnh i h
+end
+
+fn c2_mk k long a long b long v ulong to long
+ret c2_mk4 k a b 0 v
+end
+
+fn c2_isdig k long to bool
+ret and ge k 3 le k 8
+end
+
+fn c2_thdig k long to bool
+ret or or eq k 3 eq k 6 eq k 7
+end
+
+fn c2_rloop h long b long to bool
+ret c2_btest add cbloop mul h 8 b
+end
+
+note loop_digit: init/inc search, then the latch, then the guard.
+fn c2_ldig c long to long
+init = long -1
+inc = long -1
+for i long c2_ni
+if eq c2_defs i c
+if c2_ldinc i c
+inc = i
+else
+if c2_ldini i
+init = i
+end
+end
+end
+end
+if or lt init 0 lt inc 0
+ret 0
+end
+ret c2_ldig2 c init inc
+end
+
+fn c2_ldinc i long c long to bool
+s = c2_is i
+if or ne get cop s cqbin ne get csub s 1
+ret false
+end
+if ne get ca s c
+ret false
+end
+ob = get cb s
+if not c2_sconst ob
+ret false
+end
+ret eq c2_sval ob ulong 1
+end
+
+fn c2_ldini i long to bool
+s = c2_is i
+op = get cop s
+if eq op cqconst
+ret true
+end
+if eq op cqmov
+ret c2_sconst get ca s
+end
+ret false
+end
+
+fn c2_ldig2 c long init long inc long to long
+lb = get cblk inc
+t = c2_is c2_blast lb
+if ne and add inc 2 cmask32 c2_bend lb
+ret 0
+end
+if ne get cop t cqbr
+ret 0
+end
+h = get ct t
+if not c2_dom h lb
+ret 0
+end
+nl = long 0
+for p long c2_nb
+if and ne get creach p 0 c2_hassuc p h
+if c2_dom h p
+nl = add nl 1
+end
+end
+end
+if ne nl 1
+ret 0
+end
+if c2_rloop h get cblk init
+ret 0
+end
+ret c2_ldig3 c h
+end
+
+note The bound: the first loop block whose guard `lt c K` / `ge c K` exits the loop; K is its CMP's b.
+fn c2_ldig3 c long h long to long
+for g long c2_nb
+if and ne get creach g 0 c2_rloop h g
+gin = c2_lgin g c h
+if ge gin 0
+ret c2_mk4 8 c gin h c2_sval get cb c2_is get cdi get ca c2_is c2_blast g
+end
+end
+end
+ret c2_mk4 8 c -1 h ulong 0
+end
+
+note For guard block g of the loop at h: the loop-side target, or -1.
+fn c2_lgin g long c long h long to long
+t = c2_is c2_blast g
+if ne get cop t cqcbr
+ret -1
+end
+tt = get ct t
+tf = get cf t
+if eq tt tf
+ret -1
+end
+ci = get cdi get ca t
+if lt ci 0
+ret -1
+end
+if ne get cblk ci g
+ret -1
+end
+ret c2_lgin2 c2_is ci c h tt tf
+end
+
+fn c2_lgin2 cm long c long h long tt long tf long to long
+if ne get cop cm cqcmp
+ret -1
+end
+if ne get ca cm c
+ret -1
+end
+if not c2_sconst get cb cm
+ret -1
+end
+it = c2_rloop h tt
+inf = c2_rloop h tf
+sb = get csub cm
+if and eq sb 3 and it not inf
+ret tt
+end
+if and eq sb 6 and inf not it
+ret tf
+end
+ret -1
+end
+
+fn c2_comb sb long ta long tb long to long
+if or eq ta 0 eq tb 0
+ret 0
+end
+if or eq sb 1 eq sb 3
+lo = ta
+hi = tb
+if gt ta tb
+lo = tb
+hi = ta
+end
+if eq sb 1
+ret c2_mk 9 lo hi ulong 0
+end
+ret c2_mk 10 lo hi ulong 0
+end
+if or eq sb 4 eq sb 5
+ret c2_combd sb ta tb
+end
+ret 0
+end
+
+fn c2_combd sb long ta long tb long to long
+if ne get cnk tb 1
+ret 0
+end
+k = get cnv tb
+if eq k ulong 0
+ret 0
+end
+if eq get cnk ta 3
+t = ulong get cthr 0
+if eq sb 4
+if eq k ulong 1
+ret ta
+end
+if ge k t
+ret c2_mk 1 0 0 ulong 0
+end
+ret c2_mk 7 0 0 k
+end
+if eq k ulong 1
+ret c2_mk 1 0 0 ulong 0
+end
+if ge k t
+ret ta
+end
+ret c2_mk 6 0 0 k
+end
+if eq sb 4
+ret c2_mk 11 ta tb ulong 0
+end
+ret c2_mk 12 ta tb ulong 0
+end
+
+fn c2_btree r long to long
+if ne get cts c2_vs r 4
+ret 0
+end
+nd = get cnd r
+if lt r c2_np
+if eq nd 1
+ret c2_mk 2 r 0 ulong 0
+end
+ret 0
+end
+if eq nd 2
+ret c2_ldig r
+end
+if or ne nd 1 lt get cdi r 0
+ret 0
+end
+s = c2_is get cdi r
+op = get cop s
+if eq op cqconst
+ret c2_mk 1 0 0 get cimm s
+end
+if eq op cqmov
+ret c2_tree get ca s
+end
+if eq op cqgpu
+ret c2_tgpu get csub s
+end
+if eq op cqbin
+ta = c2_tree get ca s
+tb = c2_tree get cb s
+ret c2_comb get csub s ta tb
+end
+ret 0
+end
+
+fn c2_tgpu sb long to long
+if eq sb 1
+ret c2_mk 3 0 0 ulong 0
+end
+if eq sb 2
+ret c2_mk 4 0 0 ulong 0
+end
+if eq sb 4
+ret c2_mk 5 0 0 ulong 0
+end
+ret c2_mk 2 neg sb 0 ulong 0
+end
+
+fn c2_tree r long to long
+if or lt r 0 ge r c2_nv
+ret 0
+end
+m = get cmemo r
+if eq m -2
+ret 0
+end
+if ge m 0
+ret m
+end
+put cmemo r -2
+n = c2_btree r
+put cmemo r n
+ret n
+end
+
+note digits(n) appended to list sl; 0, or -1 for an opaque node or more than 16 digits.
+fn c2_digs n long sl long to long
+k = get cnk n
+if eq k 0
+ret -1
+end
+if c2_isdig k
+base = mul sl 1024
+m = get cdgn sl
+for i long m
+if eq get cdgl add base i n
+ret 0
+end
+end
+if ge m 16
+ret -1
+end
+put cdgl add base m n
+put cdgn sl add m 1
+ret 0
+end
+if ge k 9
+if lt c2_digs get cna n sl 0
+ret -1
+end
+ret c2_digs get cnb n sl
+end
+ret 0
+end
+
+fn c2_dig0 n long sl long to long
+put cdgn sl 0
+ret c2_digs n sl
+end
+
+fn c2_dfree n long to bool
+if ne c2_dig0 n 0 0
+ret false
+end
+ret eq get cdgn 0 0
+end
+
+fn c2_disj a long b long to bool
+if ne c2_dig0 a 0 0
+ret false
+end
+if ne c2_dig0 b 1 0
+ret false
+end
+for i long get cdgn 0
+for j long get cdgn 1
+if not c2_disj1 get cdgl i get cdgl add 1024 j
+ret false
+end
+end
+end
+ret true
+end
+
+fn c2_disj1 p long q long to bool
+if eq p q
+ret false
+end
+pk = get cnk p
+qk = get cnk q
+if and c2_thdig pk c2_thdig qk
+if ne get cnv p get cnv q
+ret false
+end
+ret or and eq pk 6 eq qk 7 and eq pk 7 eq qk 6
+end
+ret true
+end
+
+fn c2_umax to ulong
+ret sub ulong 0 ulong 1
+end
+
+fn c2_sadd a ulong b ulong to ulong
+s = add a b
+if lt s a
+ret c2_umax
+end
+ret s
+end
+
+fn c2_smul a ulong b ulong to ulong
+if ne a ulong 0
+if gt b div c2_umax a
+ret c2_umax
+end
+end
+ret mul a b
+end
+
+fn c2_maxv n long sb long to ulong
+k = get cnk n
+v = get cnv n
+t = ulong get cthr 0
+if eq k 1
+ret v
+end
+if eq k 3
+ret sub t ulong 1
+end
+if eq k 6
+if lt v t
+ret sub v ulong 1
+end
+ret sub t ulong 1
+end
+if eq k 7
+ret div sub t ulong 1 v
+end
+if eq k 8
+ret c2_maxl n sb
+end
+ret c2_maxv2 n sb k
+end
+
+fn c2_maxl n long sb long to ulong
+b = get cnb n
+if ge b 0
+if c2_dom b sb
+v = get cnv n
+if eq v ulong 0
+ret ulong 0
+end
+ret sub v ulong 1
+end
+end
+ret c2_umax
+end
+
+fn c2_maxv2 n long sb long k long to ulong
+a = get cna n
+b = get cnb n
+if eq k 9
+x = c2_maxv a sb
+ret c2_sadd x c2_maxv b sb
+end
+if eq k 10
+x = c2_maxv a sb
+ret c2_smul x c2_maxv b sb
+end
+if eq k 11
+ret div c2_maxv a sb get cnv b
+end
+if eq k 12
+m = c2_maxv a sb
+q = sub get cnv b ulong 1
+if lt m q
+ret m
+end
+ret q
+end
+ret c2_umax
+end
+
+fn c2_less y long mm long sb long ax long to bool
+if eq get cnk mm 1
+if lt c2_maxv y sb get cnv mm
+ret true
+end
+end
+ret c2_ltfact y mm ax
+end
+
+fn c2_ltfact y long mm long ax long to bool
+for i long get cxnl ax
+o = add mul ax 64 mul i 2
+if eq get cxlt o y
+if eq get cxlt add o 1 mm
+ret true
+end
+end
+end
+ret false
+end
+
+fn c2_inj n long sb long ax long to bool
+k = get cnk n
+if c2_isdig k
+ret true
+end
+if c2_dfree n
+ret true
+end
+if eq k 10
+a = get cna n
+b = get cnb n
+if and eq get cnk a 1 ne get cnv a ulong 0
+ret c2_inj b sb ax
+end
+if and eq get cnk b 1 ne get cnv b ulong 0
+ret c2_inj a sb ax
+end
+ret false
+end
+if ne k 9
+ret false
+end
+for o long 2
+r = c2_inj1 n o sb ax
+if ge r 0
+ret eq r 1
+end
+end
+ret false
+end
+
+note One orientation o of an ADD: 1 or 0 to return that, -1 to go on.
+fn c2_inj1 n long o long sb long ax long to long
+m = get cna n
+y = get cnb n
+if eq o 1
+m = get cnb n
+y = get cna n
+end
+if c2_dfree y
+if c2_inj m sb ax
+ret 1
+end
+ret 0
+end
+if ne get cnk m 10
+ret -1
+end
+for q long 2
+if c2_inj2 m q y sb ax
+ret 1
+end
+end
+ret -1
+end
+
+fn c2_inj2 m long q long y long sb long ax long to bool
+a = get cna m
+mm = get cnb m
+if eq q 1
+a = get cnb m
+mm = get cna m
+end
+if not c2_dfree mm
+ret false
+end
+if not c2_less y mm sb ax
+ret false
+end
+if not c2_inj a sb ax
+ret false
+end
+if not c2_inj y sb ax
+ret false
+end
+ret c2_disj a y
+end
+
+fn c2_lhold n long sb long to bool
+if ne c2_dig0 n 0 0
+ret false
+end
+for i long get cdgn 0
+p = get cdgl i
+if eq get cnk p 8
+if not c2_rloop get cnh p sb
+ret false
+end
+end
+end
+ret true
+end
+
+fn c2_acond r long pol bool ax long dp long to void
+if or gt dp 32 lt r 0
+ret
+end
+if ne get cnd r 1
+ret
+end
+di = get cdi r
+if lt di 0
+ret
+end
+s = c2_is di
+op = get cop s
+sb = get csub s
+if eq op cqmov
+c2_acond get ca s pol ax add dp 1
+ret
+end
+if and eq op cqun eq sb 3
+c2_acond get ca s not pol ax add dp 1
+ret
+end
+want = long 7
+if pol
+want = 6
+end
+if and eq op cqbin eq sb want
+c2_acond get ca s pol ax add dp 1
+c2_acond get cb s pol ax add dp 1
+ret
+end
+if ne op cqcmp
+ret
+end
+if ne get cts c2_vs get ca s 4
+ret
+end
+c2_acmp s pol ax get cblk di
+end
+
+fn c2_acmp s long pol bool ax long blk long to void
+ta = c2_tree get ca s
+tb = c2_tree get cb s
+if or eq ta 0 eq tb 0
+ret
+end
+if not c2_lhold ta blk
+ret
+end
+if not c2_lhold tb blk
+ret
+end
+kc = get csub s
+if not pol
+kc = c2_ncc kc
+end
+n = get cxnl ax
+if and or eq kc 3 eq kc 5 lt n 32
+o = add mul ax 64 mul n 2
+if eq kc 3
+put cxlt o ta
+put cxlt add o 1 tb
+else
+put cxlt o tb
+put cxlt add o 1 ta
+end
+put cxnl ax add n 1
+end
+if eq kc 1
+c2_afix ta tb ax
+end
+end
+
+fn c2_ncc kc long to long
+if eq kc 6
+ret 3
+end
+if eq kc 4
+ret 5
+end
+if eq kc 2
+ret 1
+end
+ret 0
+end
+
+fn c2_afix ta long tb long ax long to void
+nf = get cxnf ax
+if ge nf 32
+ret
+end
+x = ta
+y = tb
+if eq get cnk ta 1
+x = tb
+y = ta
+end
+xk = get cnk x
+if and eq get cnk y 1 and c2_isdig xk ne xk 8
+o = add mul ax 32 nf
+put cxfi o x
+put cxfv o get cnv y
+put cxnf ax add nf 1
+end
+end
+
+fn c2_facts sb long ax long to void
+put cxnl ax 0
+put cxnf ax 0
+for g long c2_nb
+if ne get creach g 0
+t = c2_is c2_blast g
+if eq get cop t cqcbr
+if ne get ct t get cf t
+c2_fside get ct t get ca t true sb ax
+c2_fside get cf t get ca t false sb ax
+end
+end
+end
+end
+end
+
+fn c2_fside s long r long pol bool sb long ax long to void
+if ne get cnpr s 1
+ret
+end
+if not c2_dom s sb
+ret
+end
+c2_acond r pol ax 0
+end
+
+fn c2_covers e long pa long qa long wb bool wa bool to bool
+if ne c2_dig0 e 0 0
+ret false
+end
+c2_cfixa pa qa
+th = or c2_cvhas 3 c2_cvlohi
+if not th
+ret false
+end
+if wb
+if not c2_cvhas 4
+ret false
+end
+end
+if wa
+ret c2_cvhas 5
+end
+ret true
+end
+
+fn c2_cfixa pa long qa long to void
+for i long get cxnf pa
+c2_cfixb add mul pa 32 i qa
+end
+end
+
+fn c2_cfixb oa long qa long to void
+for j long get cxnf qa
+c2_cfix oa add mul qa 32 j
+end
+end
+
+fn c2_cvhas k long to bool
+for i long get cdgn 0
+if eq get cnk get cdgl i k
+ret true
+end
+end
+ret false
+end
+
+fn c2_cvlohi to bool
+for i long get cdgn 0
+p = get cdgl i
+if eq get cnk p 6
+if c2_chi get cnv p
+ret true
+end
+end
+end
+ret false
+end
+
+fn c2_cfix oa long ob long to void
+x = get cxfi oa
+if ne x get cxfi ob
+ret
+end
+if eq get cxfv oa get cxfv ob
+n = get cdgn 0
+put cdgl n x
+put cdgn 0 add n 1
+end
+end
+
+fn c2_chi v ulong to bool
+for j long get cdgn 0
+q = get cdgl j
+if and eq get cnk q 7 eq get cnv q v
+ret true
+end
+end
+ret false
+end
+
+fn c2_rpair p long q long rule view uchar * wb bool wa bool to long
+w = c2_rchk p q wb wa
+if eq w 0
+ret 0
+end
+qi = get cxi q
+c2_a1 get cxr q
+if eq w 1
+put cv 0 get cxr p
+put cv 1 get cxi p
+put cv 2 qi
+ret c2_fail rule get cfi 0 qi cmrdiff
+end
+if eq w 2
+ret c2_fail rule get cfi 0 qi cmrinj
+end
+if eq w 3
+ret c2_fail rule get cfi 0 qi cmrloop
+end
+ret c2_fail rule get cfi 0 qi cmrcov
+end
+
+note race_pair's four tests in order: 0 pass, 1 different trees, 2 not one-to-one, 3 loop digit
+note outside its loop, 4 not covered.
+fn c2_rchk p long q long wb bool wa bool to long
+e = get cxe q
+pe = get cxe p
+if or eq pe 0 ne pe e
+ret 1
+end
+sb = get cxb q
+if not c2_inj e sb q
+ret 2
+end
+if not c2_lhold e sb
+ret 3
+end
+if not c2_covers e p q wb wa
+ret 4
+end
+ret 0
+end
+
+fn c2_rloops nb long to void
+for h long nb
+c2_bzero add cbloop mul h 8
+end
+for h long nb
+n = long 0
+lp = add cbloop mul h 8
+for p long nb
+if and ne get creach p 0 c2_hassuc p h
+if c2_dom h p
+c2_bset lp p
+put cstk n p
+n = add n 1
+end
+end
+end
+if gt n 0
+c2_bset lp h
+c2_rgrow lp n nb
+end
+end
+end
+
+fn c2_rgrow lp long n0 long nb long to void
+n = n0
+while gt n 0 bound 999999
+n = sub n 1
+b = get cstk n
+for p long nb
+if and ne get creach p 0 not c2_btest lp p
+if c2_hassuc p b
+c2_bset lp p
+put cstk n p
+n = add n 1
+end
+end
+end
+end
+end
+
+fn c2_rphase nb long to void
+ns = long 0
+for i long c2_ni
+if and eq c2_op i cqsync lt ns 63
+ns = add ns 1
+put csyn ns i
+end
+end
+put cnsy 0 ns
+for b long nb
+put cpout b ulong 0
+end
+ch = true
+while ch bound 999999
+ch = false
+for b long nb
+if ne get creach b 0
+if c2_rph1 b nb
+ch = true
+end
+end
+end
+end
+end
+
+fn c2_rph1 b long nb long to bool
+m = ulong 0
+if eq b 0
+m = ulong 1
+end
+for p long nb
+if and ne get creach p 0 c2_hassuc p b
+m = or m get cpout p
+end
+end
+put cpin b m
+m = c2_rsync b m
+if eq m get cpout b
+ret false
+end
+put cpout b m
+ret true
+end
+
+note The phase mask after walking block b from m (every sync line sets its own bit).
+fn c2_rsync b long m0 ulong to ulong
+m = m0
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+m = c2_rsyn1 i m
+i = add i 1
+end
+ret m
+end
+
+fn c2_rsyn1 i long m ulong to ulong
+if ne c2_op i cqsync
+ret m
+end
+r = m
+for s long add get cnsy 0 1
+if and gt s 0 eq get csyn s i
+r = shl ulong 1 s
+end
+end
+ret r
+end
+
+fn c2_races to long
+nb = c2_nb
+put cthr 0 get cgth get cfi 0
+put cnn 0 1
+put cnk 0 0
+for r long c2_nv
+put cmemo r -1
+end
+for p long nb
+put cnpr p 0
+end
+for p long nb
+if ne get creach p 0
+for k long get cnsu p
+q = get csuc add mul p 2 k
+put cnpr q add get cnpr q 1
+end
+end
+end
+c2_rloops nb
+c2_rphase nb
+na = c2_racc nb
+ret c2_rpairs na
+end
+
+fn c2_racc nb long to long
+na = long 0
+for b long nb
+if ne get creach b 0
+na = c2_racc1 b na
+end
+end
+ret na
+end
+
+fn c2_racc1 b long na0 long to long
+na = na0
+m = get cpin b
+i = c2_bfirst b
+e = c2_bend b
+while lt i e bound 4097
+m = c2_rsyn1 i m
+s = c2_is i
+op = get cop s
+if or or eq op cqload eq op cqstore or eq op cqgload eq op cqgstore
+put cxi na i
+put cxr na get ca s
+put cxb na b
+put cxm na m
+put cxs na 0
+if or eq op cqstore eq op cqgstore
+put cxs na 1
+end
+put cxe na c2_tree get cb s
+c2_facts b na
+na = add na 1
+end
+i = add i 1
+end
+ret na
+end
+
+fn c2_wantg sb long to bool
+for i long c2_ni
+s = c2_is i
+if and eq get cop s cqgpu eq get csub s sb
+ret true
+end
+end
+ret false
+end
+
+fn c2_rpairs na long to long
+wb = c2_wantg 2
+wa = c2_wantg 4
+for p long na
+q = p
+while lt q na bound 4097
+if lt c2_rpq p q wb wa 0
+ret -1
+end
+q = add q 1
+end
+end
+ret 0
+end
+
+fn c2_rpq p long q long wb bool wa bool to long
+if ne get cxr p get cxr q
+ret 0
+end
+if and eq get cxs p 0 eq get cxs q 0
+ret 0
+end
+op = c2_op get cxi p
+if or eq op cqload eq op cqstore
+if eq and get cxm p get cxm q ulong 0
+ret 0
+end
+if lt c2_rpair p q crshr false false 0
+ret -1
+end
+ret c2_rpair q p crshr false false
+end
+if lt c2_rpair p q crglr wb wa 0
+ret -1
+end
+ret c2_rpair q p crglr wb wa
+end
diff --git a/seed/oscgpu/c2sha.om b/seed/oscgpu/c2sha.om
new file mode 100644
index 000000000..ca57eaca1
--- /dev/null
+++ b/seed/oscgpu/c2sha.om
@@ -0,0 +1,302 @@
+note SPDX-License-Identifier: Apache-2.0
+note c2sha.om: the ir_sha256 of checker2 (FIPS 180-4 SHA-256). A copy of om/sha256/sha256-om2.om with the
+note functions renamed into the c2h_ prefix (one concatenated unit has one namespace), export dropped
+note (program mode) and sha256_hash dropped (the CLI hashes the file in chunks: init, update, final).
+note It sits right after c2glob.om because a layout must precede the first fn of the unit.
+note Upstream invariants (om/sha256/sha256-om2.om header) hold unchanged.
+
+layout shactx 104
+field state uint 8 at 0 little
+field count ulong at 32 little
+field buf uchar 64 at 40 little
+end
+
+note K[0..63]: the first 32 bits of the fractional parts of the cube roots of the first 64 primes.
+note Copied mechanically from seed/qualification/om2/fixtures/sha256-k.dec (tool-computed, never typed).
+fn c2h_kinit k edit uint 64 to void
+put k 0 0x428a2f98
+put k 1 0x71374491
+put k 2 0xb5c0fbcf
+put k 3 0xe9b5dba5
+put k 4 0x3956c25b
+put k 5 0x59f111f1
+put k 6 0x923f82a4
+put k 7 0xab1c5ed5
+put k 8 0xd807aa98
+put k 9 0x12835b01
+put k 10 0x243185be
+put k 11 0x550c7dc3
+put k 12 0x72be5d74
+put k 13 0x80deb1fe
+put k 14 0x9bdc06a7
+put k 15 0xc19bf174
+put k 16 0xe49b69c1
+put k 17 0xefbe4786
+put k 18 0x0fc19dc6
+put k 19 0x240ca1cc
+put k 20 0x2de92c6f
+put k 21 0x4a7484aa
+put k 22 0x5cb0a9dc
+put k 23 0x76f988da
+put k 24 0x983e5152
+put k 25 0xa831c66d
+put k 26 0xb00327c8
+put k 27 0xbf597fc7
+put k 28 0xc6e00bf3
+put k 29 0xd5a79147
+put k 30 0x06ca6351
+put k 31 0x14292967
+put k 32 0x27b70a85
+put k 33 0x2e1b2138
+put k 34 0x4d2c6dfc
+put k 35 0x53380d13
+put k 36 0x650a7354
+put k 37 0x766a0abb
+put k 38 0x81c2c92e
+put k 39 0x92722c85
+put k 40 0xa2bfe8a1
+put k 41 0xa81a664b
+put k 42 0xc24b8b70
+put k 43 0xc76c51a3
+put k 44 0xd192e819
+put k 45 0xd6990624
+put k 46 0xf40e3585
+put k 47 0x106aa070
+put k 48 0x19a4c116
+put k 49 0x1e376c08
+put k 50 0x2748774c
+put k 51 0x34b0bcb5
+put k 52 0x391c0cb3
+put k 53 0x4ed8aa4a
+put k 54 0x5b9cca4f
+put k 55 0x682e6ff3
+put k 56 0x748f82ee
+put k 57 0x78a5636f
+put k 58 0x84c87814
+put k 59 0x8cc70208
+put k 60 0x90befffa
+put k 61 0xa4506ceb
+put k 62 0xbef9a3f7
+put k 63 0xc67178f2
+end
+
+note H(0): the first 32 bits of the fractional parts of the square roots of the first 8 primes
+note (fixtures/sha256-iv.dec).
+fn c2h_iv s edit uint 8 to void
+put s 0 0x6a09e667
+put s 1 0xbb67ae85
+put s 2 0x3c6ef372
+put s 3 0xa54ff53a
+put s 4 0x510e527f
+put s 5 0x9b05688c
+put s 6 0x1f83d9ab
+put s 7 0x5be0cd19
+end
+
+note Message schedule of the block m[o .. o+64). w is fresh: its incoming contents are never read.
+note The compiler proves that every get of w reads an element written earlier in this function
+note (error 27 otherwise): w[0..16) are the block's big-endian words, w[16..64) the FIPS recurrence.
+fn c2h_sched w edit uint 64 fresh m view uchar * o ulong to void
+q = ulong 0
+x = uint 0
+y = uint 0
+for i ulong 16 unroll
+q = add o mul i 4
+x = uint get m q
+x = or shl x 8 uint get m add q 1
+x = or shl x 8 uint get m add q 2
+put w i or shl x 8 uint get m add q 3
+end
+for i ulong 48 unroll
+x = get w add i 1
+y = get w add i 14
+x = add add get w i get w add i 9 xor xor rotr x 7 rotr x 18 shr x 3
+put w add i 16 add x xor xor rotr y 17 rotr y 19 shr y 10
+end
+end
+
+note The 64 rounds on the chaining value s. One round body, emitted 64 times by unroll; i is a constant
+note in each copy, so get kt i and get w i need no run-time check. uint arithmetic wraps mod 2^32.
+note Ch(e,f,g) = (e and f) xor (not e and g) is written g xor (e and (f xor g)); Maj(a,b,c) =
+note (a and b) xor (a and c) xor (b and c) is written (a and b) or (c and (a or b)). Both are bitwise
+note identities. h first becomes T1, then T1 + T2, which is the next a; the names then shift by one.
+note The sums are built a term per line and each Sigma in two lines through t: 12 names are live, and
+note omc hands out 16 registers with no spilling (error 12 under compiler-s1/s2 for longer lines).
+fn c2h_rnds s edit uint 8 w view uint 64 kt view uint 64 to void
+a = get s 0
+b = get s 1
+c = get s 2
+d = get s 3
+e = get s 4
+f = get s 5
+g = get s 6
+h = get s 7
+t = uint 0
+for i ulong 64 unroll
+h = add h get kt i
+h = add h get w i
+t = xor rotr e 6 rotr e 11
+t = xor t rotr e 25
+h = add h t
+h = add h xor g and e xor f g
+d = add d h
+t = xor rotr a 2 rotr a 13
+t = xor t rotr a 22
+h = add h t
+t = and c or a b
+h = add h or and a b t
+t = h
+h = g
+g = f
+f = e
+e = d
+d = c
+c = b
+b = a
+a = t
+end
+put s 0 add get s 0 a
+put s 1 add get s 1 b
+put s 2 add get s 2 c
+put s 3 add get s 3 d
+put s 4 add get s 4 e
+put s 5 add get s 5 f
+put s 6 add get s 6 g
+put s 7 add get s 7 h
+end
+
+note One block m[o .. o+64) into s. sched and rounds stay calls: inlined, their names would share
+note one 16-register frame with this function's parameters (no spilling, error 12).
+fn c2h_comp s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * o ulong to void
+c2h_sched w m o
+c2h_rnds s w kt
+end
+
+note The whole blocks of m (len m is a multiple of 64 and at most 2^25, so under 2^19 passes).
+fn c2h_run s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void
+for j ulong shr len m 6
+c2h_comp s w kt m shl j 6
+end
+end
+
+note The whole blocks of m (len m a multiple of 64). A rolled loop traps 4 after 1000000 passes
+note (OMEGESE.md section 2; omc s_for), so m is cut into runs of 2^25 bytes (2^19 blocks):
+note len m = top * 2^44 + mid * 2^25 + rest, and no loop passes 2^20 times. top reaches 1000000
+note only above 1.7e19 bytes, which no AArch64 address space holds.
+fn c2h_blks s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void
+q = ulong 0
+for a ulong shr len m 44
+for b ulong 0x80000
+c2h_run s w kt part m q 0x2000000
+q = add q 0x2000000
+end
+end
+for b ulong and shr len m 25 0x7ffff
+c2h_run s w kt part m q 0x2000000
+q = add q 0x2000000
+end
+c2h_run s w kt part m q sub len m q
+end
+
+note Pad the k pending bytes already in p (k < 64; p was all zero past them): 0x80, zeros, and the
+note 64-bit big-endian bit length of the n-byte message in the last 8 bytes of one or two blocks.
+fn c2h_fin s edit uint 8 w edit uint 64 kt view uint 64 p edit uchar 128 k ulong n ulong to void
+put p k 0x80
+e = ulong 64
+if ge k 56
+e = 128
+end
+bits = shl n 3
+for i ulong 8 unroll
+put p sub e add i 1 uchar and shr bits mul i 8 0xff
+end
+c2h_comp s w kt view p 0
+if eq e 128
+c2h_comp s w kt view p 64
+end
+end
+
+fn c2h_init c edit shactx to void
+s = new uint 8 0
+c2h_iv s
+for i ulong 8 unroll
+put c state i get s i
+end
+put c count 0
+end
+
+note k bytes of d from o into the context's buffer at bi (bi + k <= 64). A function of its own: inside
+note absorb the copy loop needs more than the 16 registers (error 12 under compiler-s4).
+fn c2h_tobuf c edit shactx bi ulong d view uchar * o ulong k ulong to void
+for i ulong k
+put c buf add bi i get d add o i
+end
+end
+
+note Whole blocks are hashed straight from d; the bytes that complete a pending block go through blk.
+fn c2h_absorb c edit shactx d view uchar * bi ulong to void
+n = len d
+s = new uint 8 0
+w = new uint 64 0
+kt = new uint 64 0
+blk = new uchar 64 0
+c2h_kinit kt
+for i ulong 8 unroll
+put s i get c state i
+end
+off = ulong 0
+if gt bi 0
+off = sub 64 bi
+for i ulong bi
+put blk i get c buf i
+end
+for i ulong off
+put blk add bi i get d i
+end
+c2h_comp s w kt view blk 0
+end
+nb = shr sub n off 6
+c2h_blks s w kt part d off shl nb 6
+off = add off shl nb 6
+c2h_tobuf c 0 d off sub n off
+for i ulong 8 unroll
+put c state i get s i
+end
+end
+
+note Any length, including 0 and >= 2^32. lt n sub 64 bi cannot wrap (bi < 64); add bi n could.
+fn c2h_upd c edit shactx d view uchar * to void
+n = len d
+cnt = get c count
+bi = and cnt 63
+put c count add cnt n
+if lt n sub 64 bi
+c2h_tobuf c bi d 0 n
+ret
+end
+c2h_absorb c d bi
+end
+
+fn c2h_final c edit shactx o out uchar 32 to void
+s = new uint 8 0
+w = new uint 64 0
+kt = new uint 64 0
+p = new uchar 128 0
+v = ulong 0
+c2h_kinit kt
+for i ulong 8 unroll
+put s i get c state i
+end
+cnt = get c count
+k = and cnt 63
+for i ulong k
+put p i get c buf i
+end
+c2h_fin s w kt p k cnt
+for i ulong 8 unroll
+v = ulong get s i
+for j ulong 4 unroll
+put o add mul i 4 j uchar and shr v sub 24 mul j 8 0xff
+end
+end
+end
diff --git a/seed/oscgpu/gpuemit.om b/seed/oscgpu/gpuemit.om
new file mode 100644
index 000000000..1ee6dd962
--- /dev/null
+++ b/seed/oscgpu/gpuemit.om
@@ -0,0 +1,904 @@
+note seed/oscgpu/gpuemit.om: lower (one OSC instruction), the division by a number, edge_target,
+note emit_block, finish and osc_gpu_lower of src/omega_osc_gpu.c.
+
+global gjs int 64
+
+note ---- division by a number (Granlund and Montgomery, as udiv_const)
+fn gpu_cl2 d uint to uint
+l = uint 0
+while lt l 32 bound 40
+if ge shl 1 ulong l ulong d
+break
+end
+l = add l 1
+end
+ret l
+end
+
+fn gpu_udiv q int n int dv uint to void
+if eq and dv sub dv 1 0
+bw_shr q n gpu_cl2 dv
+ret
+end
+l = gpu_cl2 dv
+x = sub shl 1 ulong l ulong dv
+p = add div mul 4294967296 x ulong dv 1
+m = uint and p 4294967295
+if eq get gmut 0 8
+m = add m 1
+end
+t4 = gpu_t 4
+t5 = gpu_t 5
+bw_movi t4 m 0
+bw_imadhi t5 n t4
+bw_imadi t4 t5 4294967295 n
+bw_shr t4 t4 1
+bw_iadd t4 t4 t5
+bw_shr q t4 sub l 1
+end
+
+note ---- one instruction, by kind
+fn gpu_lgpu i int to int
+s = gpu_ix i
+d = gpu_r get idst s
+sb = get isub s
+if eq sb 1
+bw_s2r d 33
+ret 0
+end
+if eq sb 2
+bw_s2r d 37
+put gkm 7 1
+ret 0
+end
+if eq sb 4
+bw_s2r d 38
+put gkm 8 1
+ret 0
+end
+if eq sb 3
+bw_ldc32 d add 896 get gkm 4
+ret 0
+end
+if eq sb 5
+bw_ldc32 d add 896 get gkm 5
+ret 0
+end
+r = gpu_f2 67 long sb -1
+ret -1
+end
+
+fn gpu_lshfl i int to int
+s = gpu_ix i
+sb = get isub s
+c = gpu_sconst get ib s
+if or or ne sb 1 lt c 1 gt c 31
+r = gpu_f1 70
+ret -1
+end
+bw_shfl gpu_r get idst s gpu_r get ia s uint c
+ret 0
+end
+
+fn gpu_lglob i int to int
+s = gpu_ix i
+a = get ia s
+p = gpu_r a
+n = gpu_r add a 1
+x = gpu_r get ib s
+bw_ge x n
+bw_trap 3 1 -1
+bw_imadw get grg 2 x 4 p
+if eq get iop s ogld
+d = gpu_r get idst s
+bw_i0 11
+bw_f d get grg 2 -1 -1
+put gci 5 get grg 0
+pr = int -1
+if eq get gmut 0 7
+pr = 0
+end
+bw_e 2 pr
+bw_movi d 0 1
+ret 0
+end
+bw_ge get grg 5 get grg 3
+bw_i0 12
+bw_f -1 get grg 2 gpu_r get ic s -1
+put gci 5 get grg 0
+pr = int -1
+if eq get gmut 0 1
+pr = 0
+end
+bw_e 4 pr
+ret 0
+end
+
+fn gpu_lshr i int to int
+s = gpu_ix i
+a = get ia s
+if ne get vtref gpu_vx a 4
+r = gpu_f1 71
+ret -1
+end
+x = gpu_r get ib s
+t0 = gpu_t 0
+t1 = gpu_t 1
+bw_movi t0 get gshl a 0
+bw_ge x t0
+bw_trap 3 1 -1
+bw_movi t1 get gsho a 0
+bw_imadi t1 x 4 t1
+if eq get iop s 9
+d = gpu_r get idst s
+bw_i0 49
+bw_f d t1 -1 -1
+bw_e 2 -1
+bw_movi d 0 1
+ret 0
+end
+bw_ge get grg 5 get grg 3
+bw_i0 50
+bw_f -1 t1 gpu_r get ic s -1
+pr = int -1
+if eq get gmut 0 1
+pr = 0
+end
+bw_e 4 pr
+ret 0
+end
+
+fn gpu_lf2u d int a int to void
+t0 = gpu_t 0
+t1 = gpu_t 1
+t2 = gpu_t 2
+t3 = gpu_t 3
+bw_movi t0 3212836864 0
+bw_fsetp a t0 4
+bw_bool t1 1
+bw_movi t0 1333788672 0
+bw_fsetp a t0 1
+bw_bool t2 1
+bw_lop t1 t1 t2 192
+bw_var1 65 t3 a
+bw_mov d t3 0
+bw_ge t1 get grg 3
+bw_trap 5 -1 d
+end
+
+fn gpu_lcast i int to int
+s = gpu_ix i
+fr = gpu_ty get ia s
+tt = gpu_ty get idst s
+d = gpu_r get idst s
+a = gpu_r get ia s
+if and eq fr 4 eq tt 13
+bw_i0 64
+bw_f d a -1 -1
+bw_e 0 0
+ret 0
+end
+if and eq fr 13 eq tt 4
+gpu_lf2u d a
+ret 0
+end
+gpu_fb 72
+gpu_ps fr
+gpu_pt 73
+gpu_ps tt
+gpu_fe
+ret -1
+end
+
+fn gpu_lun i int to int
+s = gpu_ix i
+t = gpu_ty get ia s
+d = gpu_r get idst s
+a = gpu_r get ia s
+sb = get isub s
+t0 = gpu_t 0
+if and eq sb 1 eq t 4
+bw_imadi d a 4294967295 -1
+ret 0
+end
+if and eq sb 1 eq t 13
+bw_movi t0 2147483648 0
+bw_lop d a t0 60
+ret 0
+end
+if and eq sb 2 eq t 4
+bw_lop d a -1 15
+ret 0
+end
+if and eq sb 3 eq t 1
+bw_lop d a get grg 3 60
+ret 0
+end
+if and eq sb 4 eq t 13
+bw_movi t0 1069066811 0
+bw_f2 32 t0 a t0
+bw_var1 47 d t0
+ret 0
+end
+if and eq sb 5 eq t 13
+bw_var1 40 d a
+ret 0
+end
+if and eq sb 6 eq t 13
+bw_var1 41 d a
+ret 0
+end
+if and eq sb 7 eq t 13
+bw_var1 41 t0 a
+bw_var1 40 d t0
+ret 0
+end
+gpu_fb 74
+gpu_pi long sb
+gpu_pt 75
+gpu_ps t
+gpu_fe
+ret -1
+end
+
+fn gpu_lcmp i int to int
+s = gpu_ix i
+t = gpu_ty get ia s
+d = gpu_r get idst s
+a = gpu_r get ia s
+b = gpu_r get ib s
+sb = get isub s
+if eq t 13
+if or lt sb 1 gt sb 6
+r = gpu_f2 76 long sb -1
+ret -1
+end
+c = uint 2
+if eq sb 2
+c = 13
+end
+if eq sb 3
+c = 1
+end
+if eq sb 4
+c = 3
+end
+if eq sb 5
+c = 4
+end
+if eq sb 6
+c = 6
+end
+bw_fsetp a b c
+bw_bool d 1
+ret 0
+end
+if and ne t 4 ne t 1
+gpu_fb 77
+gpu_ps t
+gpu_fe
+ret -1
+end
+if eq sb 3
+bw_ge a b
+bw_bool d -1
+ret 0
+end
+if eq sb 6
+bw_ge a b
+bw_bool d 1
+ret 0
+end
+if eq sb 5
+bw_ge b a
+bw_bool d -1
+ret 0
+end
+if eq sb 4
+bw_ge b a
+bw_bool d 1
+ret 0
+end
+if or eq sb 1 eq sb 2
+t0 = gpu_t 0
+bw_lop t0 a b 60
+bw_ge t0 get grg 3
+pr = int -1
+if eq sb 2
+pr = 1
+end
+bw_bool d pr
+ret 0
+end
+r = gpu_f2 76 long sb -1
+ret -1
+end
+
+fn gpu_lshift d int a int b int sb uchar to void
+t0 = gpu_t 0
+t1 = gpu_t 1
+t2 = gpu_t 2
+t3 = gpu_t 3
+one = get grg 3
+bw_movi t1 32 0
+bw_ge b t1
+if eq sb 9
+bw_shl t0 a b -1
+else
+bw_imadi t2 b 4294967295 t1
+bw_andi t2 t2 31
+bw_ge b one
+bw_mov t0 a -1
+bw_shl t3 one t2 1
+bw_i0 53
+bw_f t0 a t3 -1
+bw_e 0 1
+bw_ge b t1
+end
+bw_mov d t0 0
+bw_trap 7 1 d
+end
+
+fn gpu_ldiv i int d int a int sb uchar to int
+c = gpu_sconst get ib gpu_ix i
+if lt c 1
+r = gpu_f1 81
+ret -1
+end
+dv = uint c
+t0 = gpu_t 0
+gpu_udiv t0 a dv
+if eq sb 4
+bw_mov d t0 0
+else
+bw_imadi d t0 sub 0 dv a
+end
+ret 0
+end
+
+fn gpu_lbinu i int to int
+s = gpu_ix i
+d = gpu_r get idst s
+a = gpu_r get ia s
+b = gpu_r get ib s
+sb = get isub s
+t0 = gpu_t 0
+t1 = gpu_t 1
+if eq sb 6
+bw_lop d a b 192
+ret 0
+end
+if eq sb 7
+bw_lop d a b 252
+ret 0
+end
+if eq sb 8
+bw_lop d a b 60
+ret 0
+end
+if eq sb 1
+bw_iadd t0 a b
+bw_ge t0 a
+bw_mov d t0 0
+if ne get gmut 0 3
+bw_trap 1 -1 d
+end
+ret 0
+end
+if eq sb 2
+bw_imadi t0 b 4294967295 a
+bw_ge a b
+bw_mov d t0 0
+bw_trap 1 -1 d
+ret 0
+end
+if eq sb 3
+bw_imadhi t1 a b
+bw_imad t0 a b -1
+bw_ge t1 get grg 3
+bw_mov d t0 0
+bw_trap 1 1 d
+ret 0
+end
+if eq sb 11
+bw_ge a b
+bw_mov t0 b 0
+bw_mov t0 a -1
+bw_mov d t0 0
+ret 0
+end
+if eq sb 12
+bw_ge a b
+bw_mov t0 a 0
+bw_mov t0 b -1
+bw_mov d t0 0
+ret 0
+end
+if or eq sb 4 eq sb 5
+r = gpu_ldiv i d a sb
+ret r
+end
+if or eq sb 9 eq sb 10
+gpu_lshift d a b sb
+ret 0
+end
+r = gpu_f2 82 long sb -1
+ret -1
+end
+
+fn gpu_lbin i int to int
+s = gpu_ix i
+t = gpu_ty get ia s
+d = gpu_r get idst s
+a = gpu_r get ia s
+b = gpu_r get ib s
+sb = get isub s
+if eq t 13
+op = int -1
+if eq sb 1
+op = 30
+end
+if eq sb 2
+op = 31
+end
+if eq sb 3
+op = 32
+end
+if eq sb 11
+op = 36
+end
+if eq sb 12
+op = 37
+end
+if lt op 0
+r = gpu_f2 78 long sb -1
+ret -1
+end
+bw_f2 op d a b
+ret 0
+end
+if eq t 1
+lut = uint 0
+if eq sb 6
+lut = 192
+end
+if eq sb 7
+lut = 252
+end
+if eq sb 8
+lut = 60
+end
+if eq lut 0
+r = gpu_f2 79 long sb -1
+ret -1
+end
+bw_lop d a b lut
+ret 0
+end
+if ne t 4
+gpu_fb 80
+gpu_ps t
+gpu_fe
+ret -1
+end
+r = gpu_lbinu i
+ret r
+end
+
+note lower: one OSC instruction; 0 or -1 (failed)
+fn gpu_lower1 i int to int
+s = gpu_ix i
+o = get iop s
+if eq o 1
+bw_movi gpu_r get idst s uint and get iimm s 4294967295 0
+ret 0
+end
+if eq o 2
+t = gpu_ty get idst s
+if and and ne t 4 ne t 13 ne t 1
+gpu_fb 66
+gpu_ps t
+gpu_fe
+ret -1
+end
+bw_mov gpu_r get idst s gpu_r get ia s 0
+ret 0
+end
+if eq o ogpu
+r = gpu_lgpu i
+ret r
+end
+if eq o oshar
+ret 0
+end
+if eq o osync
+bw_bar
+ret 0
+end
+if eq o 12
+x = get iimm s
+if or eq x 0 ge x 16
+gpu_fb 68
+gpu_pu x
+gpu_pt 69
+gpu_fe
+ret -1
+end
+bw_trap int x 0 -1
+ret 0
+end
+if eq o oshfl
+r = gpu_lshfl i
+ret r
+end
+if eq o omad
+bw_i0 33
+bw_f gpu_r get idst s gpu_r get ia s gpu_r get ib s gpu_r get ic s
+bw_e 0 0
+ret 0
+end
+if or eq o ogld eq o ogst
+r = gpu_lglob i
+ret r
+end
+if or eq o 9 eq o 10
+r = gpu_lshr i
+ret r
+end
+if eq o 6
+r = gpu_lcast i
+ret r
+end
+if eq o 4
+r = gpu_lun i
+ret r
+end
+if eq o 5
+r = gpu_lcmp i
+ret r
+end
+if eq o 3
+r = gpu_lbin i
+ret r
+end
+r = gpu_f2 83 long o 84
+ret -1
+end
+
+note ---- layout
+fn gpu_inreg r int u int to bool
+if lt u 0
+ret false
+end
+x = gpu_bhas add 513 r u
+ret x
+end
+
+fn gpu_etgt u int v int to int
+nr = get gnr 0
+inner = int -1
+for r int nr
+if eq get grj r v
+if gpu_inreg r u
+if lt inner 0
+inner = r
+else
+c = gpu_bcnt add 513 r
+e = gpu_bcnt add 513 inner
+if lt c e
+inner = r
+end
+end
+end
+end
+end
+na = get gna v
+arm = na
+for k int na
+x = gpu_inreg get gam add mul v 16 k u
+if not x
+arm = k
+break
+end
+end
+if ge inner 0
+if and ne arm 0 gt na 0
+gpu_fb 44
+gpu_pi long u
+gpu_pt 45
+gpu_pi long v
+gpu_pt 46
+gpu_fe
+ret 0
+end
+ret get gry inner
+end
+if lt arm na
+ret add get gaa v arm
+end
+ret get gba v
+end
+
+fn gpu_ejoin b int i int nj int to void
+r = get gjs i
+put gry r bw_here
+op = int 55
+if eq get gmut 0 2
+op = 0
+end
+bw_i0 op
+put gci 7 get grb r
+bw_e 9 0
+p = get grp r
+par = int -1
+if ge p 0
+if eq get grj p b
+par = p
+end
+end
+nx = false
+if lt add i 1 nj
+if eq get gjs add i 1 par
+nx = true
+end
+end
+if and ge par 0 not nx
+q = bw_branch 0
+gpu_addfix q 1 par 0
+else
+if and lt par 0 lt add i 1 nj
+q = bw_branch 0
+gpu_addfix q 2 b 0
+end
+end
+end
+
+fn gpu_eterm b int to void
+s = gpu_ix gpu_term b
+o = get iop s
+if eq o 13
+q = bw_branch 0
+gpu_addfix q 0 b get ibt s
+ret
+end
+if eq o 14
+bw_ge gpu_r get ia s get grg 3
+q = bw_branch 1
+gpu_addfix q 0 b get ibt s
+q = bw_branch 0
+gpu_addfix q 0 b get ibf s
+ret
+end
+bw_i0 45
+bw_e 6 0
+end
+
+fn gpu_eblk b int to void
+put gbf b bw_here
+nr = get gnr 0
+nj = int 0
+for r int nr
+if eq get grj r b
+put gjs nj r
+nj = add nj 1
+end
+end
+i = int 1
+while lt i nj bound 99
+k = i
+while gt k 0 bound 99
+x = gpu_bcnt add 513 get gjs k
+y = gpu_bcnt add 513 get gjs sub k 1
+if ge x y
+break
+end
+t = get gjs k
+put gjs k get gjs sub k 1
+put gjs sub k 1 t
+k = sub k 1
+end
+i = add i 1
+end
+for j int nj
+gpu_ejoin b j nj
+end
+put gaa b bw_here
+na = get gna b
+for j int na
+r = get gam add mul b 16 j
+put grs r bw_here
+bw_i0 54
+put gci 7 get grb r
+bw_im 2
+bw_e 8 0
+end
+put gba b bw_here
+x = gpu_bf b
+e = gpu_term b
+while lt x e bound 999999
+r = gpu_lower1 x
+if lt r 0
+ret
+end
+x = add x 1
+end
+gpu_eterm b
+put gbl b sub bw_here 1
+end
+
+note ---- finish
+fn gpu_fix1 k int to void
+p = get gfa k
+kd = get gfk k
+a = get gfx k
+tg = int 0
+if eq kd 0
+tg = gpu_etgt a get gfy k
+end
+if eq kd 1
+tg = get gry a
+end
+if eq kd 2
+tg = get gaa a
+end
+if lt tg 0
+r = gpu_f1 59
+ret
+end
+put gxim p gpu_u32 sub tg p
+if eq tg p
+r = gpu_f1 60
+end
+end
+
+fn gpu_stretch to void
+f = get gfn 0
+nv = int get fnvr f
+nb = get gnb 0
+for v int nv
+bv = get gmap v
+if lt bv 0
+continue
+end
+lo = get gvfd bv
+hi = get gvlu bv
+for b int nb
+if gpu_vhas b v
+x = get gbf b
+if or lt lo 0 lt x lo
+lo = x
+end
+if gt x hi
+hi = x
+end
+end
+if gpu_vhas add 512 b v
+x = get gbl b
+if or lt lo 0 lt x lo
+lo = x
+end
+if gt x hi
+hi = x
+end
+end
+end
+put gvfd bv lo
+put gvlu bv hi
+end
+end
+
+fn gpu_finish to int
+n = get gnf 0
+for k int n
+if ne get gfail 0 0
+break
+end
+gpu_fix1 k
+end
+nr = get gnr 0
+for r int nr
+if ne get gfail 0 0
+break
+end
+bs = get grs r
+bz = get gry r
+if or or lt bs 0 lt bz 0 lt bz bs
+q = gpu_f2 61 long get grh r 62
+ret -1
+end
+put gxim bs gpu_u32 sub add bz 1 bs
+end
+if ne get gfail 0 0
+ret -1
+end
+last = sub get gcnt 0 1
+if ne get gmut 0 4
+gpu_stretch
+end
+put gvlu get grg 1 last
+put gvlu get grg 3 last
+put gvlu get grg 4 last
+put gvlu get grg 5 last
+put gulu get grg 0 last
+ret 0
+end
+
+note ---- osc_gpu_lower of function gfn: 0 ok, -1 refused (message in gerr)
+fn gpu_reset to void
+put gcnt 0 0
+put gnv 0 0
+put gnu 0 0
+put gee 0 0
+put gpen 0 0
+put gld 0 0
+put gfail 0 0
+put gern 0 0
+put gsel 0 0
+put gnf 0 0
+put gnr 0 0
+for k ulong 16
+put gkm k 0
+end
+for k ulong 32
+put gpk k 0
+put gpe k 0
+put gpo k 0
+end
+for b ulong 512
+put gbf b 0
+put gbl b 0
+put gaa b 0
+put gba b 0
+put gna b 0
+end
+end
+
+fn gpu_lower to int
+gpu_reset
+f = get gfn 0
+th = get fthr f
+put gkm 0 th
+if ne get fkind f 1
+r = gpu_f1 27
+ret -1
+end
+if or or lt th 32 gt th 1024 ne rem th 32 0
+r = gpu_f2 28 long th -1
+ret -1
+end
+r = gpu_cfg
+if lt r 0
+ret -1
+end
+r = gpu_params
+if lt r 0
+ret -1
+end
+gpu_unif
+gpu_live
+r = gpu_regions
+if lt r 0
+ret -1
+end
+gpu_prolog
+nb = get gnb 0
+for b int nb
+if ne get gfail 0 0
+break
+end
+gpu_eblk b
+end
+if and eq get gfail 0 0 ne get gee 0 0
+r = gpu_f1 63
+end
+if ne get gfail 0 0
+ret -1
+end
+bw_tail
+if ne get gee 0 0
+r = gpu_f1 64
+ret -1
+end
+r = gpu_finish
+ret r
+end
diff --git a/seed/oscgpu/gpuir.om b/seed/oscgpu/gpuir.om
new file mode 100644
index 000000000..df24527e6
--- /dev/null
+++ b/seed/oscgpu/gpuir.om
@@ -0,0 +1,735 @@
+note seed/oscgpu/gpuir.om: the BlackwellIR builder, the emitter helpers and the dump writer of the .om
+note GPU lowering. Port of omega_bw_ir_alloc_vreg / alloc_vreg64 / alloc_uvreg64 / omega_bw_ir_append
+note (src/omega_blackwell_codegen.c) and of the emitter of src/omega_bw_em.h, exactly. Units are
+note concatenated: cat oscir.om gpuir.om gpulow.om gpumain.om. Globals start with g, functions with
+note gpu_ or bw_. The encoder is not here: it consumes the dump this unit writes.
+
+note ---- the program being built (BlackwellIRProgram)
+global gxop uchar 1024
+global gxd int 1024
+global gx1 int 1024
+global gx2 int 1024
+global gx3 int 1024
+global gxu int 1024
+global gxim uint 1024
+global gxct uint 1024
+global gxun uchar 1024
+global gxp0 uchar 1024
+global gxpn uchar 1024
+global gxbr uchar 1024
+global gcnt int 1
+note vreg intervals: first_def, last_use, bundle size 1 or 2
+global gvfd int 256
+global gvlu int 256
+global gvbs uchar 256
+global gnv int 1
+global gufd int 32
+global gulu int 32
+global gnu int 1
+
+note ---- the emitter (Em): err, pending, loop starts, loop depth
+global gee int 1
+global gpen uint 1
+global glp int 4
+global gld int 1
+note the instruction being formed: op dst src1 src2 src3 ureg uniform bar_reg; and its imm
+global gci int 8
+global gcim uint 1
+
+note ---- the kernel record (OscGpuKernel) as numbers: 0 threads 1 shared_bytes 2 nparams 3 status_off
+note 4 blocks_off 5 batches_off 6 arg_words 7 reads_block 8 reads_batch 9 regions 10 region_bars
+global gkm uint 16
+global gpk uchar 32
+global gpe uchar 32
+global gpo uint 32
+note the kernel function index and the mutant number (osc_gpu_mutant)
+global gfn ulong 1
+global gmut int 1
+
+note ---- failure: first message wins; gsel picks the writer target (0 output, 1 message, 2 discard)
+global gfail uchar 1
+global gerr uchar 256
+global gern ulong 1
+global gsel uchar 1
+global gob uchar 1048576
+global gop ulong 1
+global gtof uint 128
+
+note message pieces; id = line number from 0
+text gtx "bwir 1\nname \nthreads \nshared_bytes \nnparams \nparam \nstatus_off \nblocks_off \nbatches_off \narg_words \nreads_block \nreads_batch \nregions \nregion_bars \ncount \nnum_vregs \nnum_uvregs \nra 0 0 0\nv \nu \ni \nend\nREFUSED decode: \nREFUSED: no function \n in \nREFUSED build: \n: \nnot a kernel\nbad thread count \nblock \n does not end in br, cbr or ret\n: a branch with no post-dominator\n: two joins for one region\nmore than 64 reconvergence regions\n: a varying region entered at two blocks (\n, \n)\n, 0)\n: a varying region nothing enters\na varying region (head block \n) can run after a varying ret; v1 refuses it\ntwo varying regions overlap without nesting\nmore than 16 reconvergence barriers needed at once\ntoo many regions start at block \nedge \n -> \n leaves one region and is inside the next\nbuffer parameter \n without its length\nbuffer of \nparameter \n of type \narguments need \n words; the launcher passes 32\nregister \n: only shared arrays may be references in a kernel\nshared arrays need \n bytes\nmore registers than the builder holds\na branch target was never laid out\na branch to itself\nregion at block \n: its join is laid out before its head\nthe program is longer than the builder holds (1024 instructions)\nthe program is longer than the builder holds\ntoo many branches\nmov of a \nunknown launch value \ntrap code \n outside 1..15\ndown needs a number 1 to 31\nload/store on a non-shared array\ncast \n to \nunary op \n on \ncompare \ncompare on \nfloat op \nbool op \nbinary op on \ndiv/rem need a number other than 0 as the divisor\nuint op \ninstruction \n is not allowed in a kernel\nvoid\nbool\nu8\nu16\nu32\nu64\ni8\ni16\ni32\ni64\nref\nbytes\ncells\nf32\ngview\ngedit\n?\nOK\nARG\nMAGIC\nUNKNOWN_VERSION\nTRUNCATED\nOVERSIZED\nTRAILING\nRANGE\nTEXT\nINVALID\nVERSION_MISMATCH\nNONCANONICAL\n?\nusage: gpu <unit.ir> <kernel> <out.bwir> <mutant 0..8>\ngpu: cannot read the unit\ngpu: cannot write the dump\n"
+
+note ---- writer
+fn gpu_init to void
+k = uint 0
+put gtof 0 0
+p = ulong 0
+n = len gtx
+while lt p n bound 999999
+if ge k 127
+break
+end
+c = get gtx p
+if eq c 10
+k = add k 1
+put gtof k uint add p 1
+end
+p = add p 1
+end
+end
+
+fn gpu_pc c uchar to void
+s = get gsel 0
+if eq s 0
+p = get gop 0
+if lt p 1048576
+put gob p c
+put gop 0 add p 1
+end
+end
+if eq s 1
+n = get gern 0
+if lt n 255
+put gerr n c
+put gern 0 add n 1
+end
+end
+end
+
+note one piece of gtx
+fn gpu_pt id int to void
+p = ulong get gtof id
+while true bound 999999
+c = get gtx p
+if eq c 10
+break
+end
+gpu_pc c
+p = add p 1
+end
+end
+
+fn gpu_pu x ulong to void
+d = new uchar 24 0
+n = int 0
+y = x
+while true bound 30
+put d n uchar add 48 rem y 10
+n = add n 1
+y = div y 10
+if eq y 0
+break
+end
+end
+while gt n 0 bound 30
+n = sub n 1
+gpu_pc get d n
+end
+end
+
+fn gpu_pi x long to void
+if lt x 0
+gpu_pc 45
+gpu_pu ulong neg x
+else
+gpu_pu ulong x
+end
+end
+
+note an int as a C %u of a (uint32_t) conversion
+fn gpu_u32 x int to uint
+if lt x 0
+ret uint add long x 4294967296
+end
+ret uint x
+end
+
+fn gpu_nl to void
+gpu_pc 10
+end
+
+note an OscScalar name (osc_scalar_name)
+fn gpu_ps s uchar to void
+if gt s 15
+gpu_pt 101
+else
+gpu_pt add 85 int s
+end
+end
+
+note the kernel's name bytes
+fn gpu_pname to void
+f = get gfn 0
+n = get fnlen f
+for k ulong ulong n
+gpu_pc get fname add mul f 64 k
+end
+end
+
+note ---- failure (fail of omega_osc_gpu.c): begin with piece id; the caller appends; gpu_fe ends
+fn gpu_fb id int to void
+if ne get gfail 0 0
+put gsel 0 2
+else
+put gsel 0 1
+put gern 0 0
+gpu_pname
+gpu_pt 26
+end
+put gfail 0 1
+gpu_pt id
+end
+
+fn gpu_fe to void
+put gsel 0 0
+end
+
+note fail with one piece and no argument
+fn gpu_f1 id int to int
+gpu_fb id
+gpu_fe
+ret -1
+end
+
+note fail: piece a, number x, piece b (b < 0: none)
+fn gpu_f2 a int x long b int to int
+gpu_fb a
+gpu_pi x
+if ge b 0
+gpu_pt b
+end
+gpu_fe
+ret -1
+end
+
+note ---- builder (omega_bw_ir_alloc_*)
+fn bw_alv sz uchar to int
+v = get gnv 0
+if ge v 256
+put gee 0 -1
+ret -1
+end
+put gnv 0 add v 1
+put gvfd v -1
+put gvlu v -1
+put gvbs v sz
+ret v
+end
+
+fn bw_v to int
+r = bw_alv 1
+ret r
+end
+
+fn bw_v64 to int
+r = bw_alv 2
+ret r
+end
+
+fn bw_uv64 to int
+v = get gnu 0
+if ge v 32
+put gee 0 -1
+ret -1
+end
+put gnu 0 add v 1
+put gufd v -1
+put gulu v -1
+ret v
+end
+
+fn bw_tv v int x int to void
+if ge v 0
+if lt v get gnv 0
+if lt get gvfd v 0
+put gvfd v x
+end
+if gt x get gvlu v
+put gvlu v x
+end
+end
+end
+end
+
+fn bw_tu v int x int to void
+if ge v 0
+if lt v get gnu 0
+if lt get gufd v 0
+put gufd v x
+end
+if gt x get gulu v
+put gulu v x
+end
+end
+end
+end
+
+note omega_bw_ir_append of the instruction in gci/gcim with control ctl and predicate p0/pn
+fn bw_app ctl uint p0 uchar pn uchar to int
+n = get gcnt 0
+if ge n 1024
+ret -1
+end
+put gcnt 0 add n 1
+put gxop n uchar get gci 0
+put gxd n get gci 1
+put gx1 n get gci 2
+put gx2 n get gci 3
+put gx3 n get gci 4
+put gxu n get gci 5
+put gxim n get gcim 0
+put gxct n ctl
+put gxun n uchar get gci 6
+put gxp0 n p0
+put gxpn n pn
+put gxbr n uchar get gci 7
+un = ne get gci 6 0
+if not un
+bw_tv get gci 1 n
+end
+bw_tv get gci 2 n
+bw_tv get gci 3 n
+bw_tv get gci 4 n
+if un
+bw_tu get gci 1 n
+end
+bw_tu get gci 5 n
+ret n
+end
+
+note ---- emitter (omega_bw_em.h)
+note I0: the op, every register -1, everything else 0
+fn bw_i0 op int to void
+put gci 0 op
+put gci 1 -1
+put gci 2 -1
+put gci 3 -1
+put gci 4 -1
+put gci 5 -1
+put gci 6 0
+put gci 7 0
+put gcim 0 0
+end
+
+note dst, src1, src2, src3
+fn bw_f d int a int b int c int to void
+put gci 1 d
+put gci 2 a
+put gci 3 b
+put gci 4 c
+end
+
+fn bw_im x uint to void
+put gcim 0 x
+end
+
+fn bw_cw s uint wb uint rb uint w uint to uint
+ret or or or shl s 9 shl wb 14 shl rb 17 shl w 20
+end
+
+note emit with E's predicate (0 always, 1 @P0, -1 @!P0). kind: 0 FIXED 1 PRED 2 VAR 3 UVAR 4 STORE
+note 5 SYNC 6 EXIT 7 BRA 8 BSSY 9 BSYNC
+fn bw_e kind int pred int to void
+w = get gpen 0
+p0 = uchar 0
+pn = uchar 0
+if ne pred 0
+p0 = 1
+if lt pred 0
+pn = 1
+end
+end
+c = uint 0
+np = uint 0
+if eq kind 0
+c = bw_cw 6 7 7 w
+end
+if eq kind 1
+c = bw_cw 14 7 7 w
+end
+if eq kind 2
+c = or bw_cw 4 0 1 w 8192
+np = 3
+end
+if eq kind 3
+c = or bw_cw 4 2 7 w 8192
+np = 4
+end
+if eq kind 4
+c = or bw_cw 4 7 1 w 8192
+np = 2
+end
+if eq kind 5
+c = bw_cw 6 7 7 w
+end
+if or eq kind 6 eq kind 7
+c = bw_cw 5 7 7 w
+if ne p0 0
+np = w
+end
+end
+if eq kind 8
+c = or bw_cw 1 7 7 w 8192
+end
+if eq kind 9
+c = or bw_cw 5 7 7 w 8192
+end
+put gpen 0 np
+r = bw_app c p0 pn
+if lt r 0
+put gee 0 -1
+end
+end
+
+fn bw_here to int
+ret get gcnt 0
+end
+
+fn bw_ldcu64 d int x uint to void
+bw_i0 7
+bw_f d -1 -1 -1
+bw_im x
+put gci 6 1
+bw_e 3 0
+end
+
+fn bw_ldc64 d int x uint to void
+bw_i0 5
+bw_f d -1 -1 -1
+bw_im x
+bw_e 2 0
+end
+
+fn bw_ldc32 d int x uint to void
+bw_i0 4
+bw_f d -1 -1 -1
+bw_im x
+bw_e 2 0
+end
+
+fn bw_s2r d int sr uint to void
+bw_i0 3
+bw_f d -1 -1 -1
+bw_im sr
+bw_e 2 0
+end
+
+fn bw_imadw d int a int x uint c int to void
+bw_i0 9
+bw_f d a -1 c
+bw_im x
+bw_e 0 0
+end
+
+fn bw_andi d int a int x uint to void
+bw_i0 18
+bw_f d a -1 -1
+bw_im x
+bw_e 0 0
+end
+
+fn bw_sts32 a int v int pred int to void
+bw_i0 50
+bw_f -1 a v -1
+bw_e 4 pred
+end
+
+fn bw_bar to void
+bw_i0 48
+bw_e 5 0
+end
+
+fn bw_shfl d int a int x uint to void
+bw_i0 42
+bw_f d a -1 -1
+bw_im x
+bw_e 2 0
+end
+
+fn bw_bra t int to void
+bw_i0 46
+bw_im gpu_u32 sub t bw_here
+bw_e 7 0
+end
+
+fn bw_patch p int t int to void
+if eq get gee 0 0
+put gxim p gpu_u32 sub t p
+end
+end
+
+fn bw_tail to void
+bw_i0 45
+bw_e 6 0
+bw_i0 46
+r = bw_app 1032192 0 0
+if lt r 0
+put gee 0 -1
+end
+end
+
+fn bw_lbeg to void
+d = get gld 0
+if ge d 4
+put gee 0 -1
+ret
+end
+put glp d bw_here
+put gld 0 add d 1
+end
+
+fn bw_lend to void
+d = get gld 0
+if le d 0
+put gee 0 -1
+ret
+end
+d = sub d 1
+put gld 0 d
+s = get glp d
+e = sub bw_here 1
+n = get gnv 0
+for v int n
+x = get gvfd v
+y = get gvlu v
+if and and ge x 0 lt x s and ge y s lt y e
+put gvlu v e
+end
+end
+end
+
+note ---- the G helpers of omega_osc_gpu.c
+fn bw_mov d int a int pred int to void
+bw_i0 51
+bw_f d a -1 -1
+bw_im 240
+bw_e 0 pred
+end
+
+fn bw_movi d int x uint pred int to void
+bw_i0 2
+bw_f d -1 -1 -1
+bw_im x
+bw_e 0 pred
+end
+
+fn bw_lop d int a int b int lut uint to void
+bw_i0 51
+bw_f d a b -1
+bw_im lut
+bw_e 0 0
+end
+
+fn bw_imad d int a int b int c int to void
+bw_i0 8
+bw_f d a b c
+bw_e 0 0
+end
+
+fn bw_imadi d int a int x uint c int to void
+bw_i0 8
+bw_f d a -1 c
+bw_im x
+bw_e 0 0
+end
+
+fn bw_imadhi d int a int b int to void
+bw_i0 53
+bw_f d a b -1
+bw_e 0 0
+end
+
+fn bw_iadd d int a int b int to void
+bw_i0 14
+bw_f d a b -1
+bw_e 0 0
+end
+
+fn bw_shr d int a int n uint to void
+if eq n 0
+bw_mov d a 0
+ret
+end
+bw_i0 17
+bw_f d a -1 -1
+bw_im n
+bw_e 0 0
+end
+
+fn bw_shl d int a int b int pred int to void
+bw_i0 52
+bw_f d a b -1
+bw_e 0 pred
+end
+
+fn bw_ge a int b int to void
+bw_i0 28
+bw_f -1 a b -1
+bw_e 1 0
+end
+
+fn bw_fsetp a int b int code uint to void
+bw_i0 34
+bw_f -1 a b -1
+bw_im or 66060288 shl code 12
+bw_e 1 0
+end
+
+fn bw_f2 op int d int a int b int to void
+bw_i0 op
+bw_f d a b -1
+bw_e 0 0
+end
+
+fn bw_var1 op int d int a int to void
+bw_i0 op
+bw_f d a -1 -1
+bw_e 2 0
+end
+
+fn bw_bool d int pred int to void
+bw_movi d 0 0
+bw_movi d 1 pred
+end
+
+note ---- the named registers: 0 udesc 1 st 2 a0 3 one 4 zero 5 poison 6..11 T0..T5
+global grg int 12
+
+fn gpu_t i int to int
+ret get grg add 6 i
+end
+
+fn bw_trap code int pred int d int to void
+bw_i0 12
+bw_f -1 get grg 1 get grg 3 -1
+bw_im mul 4 uint code
+put gci 5 get grg 0
+bw_e 4 pred
+bw_movi get grg 5 1 pred
+if ge d 0
+bw_movi d 0 pred
+end
+end
+
+fn bw_branch pred int to int
+p = bw_here
+bw_i0 46
+bw_im 1
+bw_e 7 pred
+ret p
+end
+
+note ---- the dump (om_oracle dump(): the canonical text of a lowering)
+fn gpu_kv id int x uint to void
+gpu_pt id
+gpu_pu ulong x
+gpu_nl
+end
+
+fn gpu_dhead to void
+gpu_pt 0
+gpu_nl
+gpu_pt 1
+gpu_pname
+gpu_nl
+gpu_kv 2 get gkm 0
+gpu_kv 3 get gkm 1
+gpu_kv 4 get gkm 2
+n = get gkm 2
+for i uint n
+gpu_pt 5
+gpu_pu ulong i
+gpu_pc 32
+gpu_pu ulong get gpk i
+gpu_pc 32
+gpu_pu ulong get gpe i
+gpu_pc 32
+gpu_pu ulong get gpo i
+gpu_nl
+end
+gpu_kv 6 get gkm 3
+gpu_kv 7 get gkm 4
+gpu_kv 8 get gkm 5
+gpu_kv 9 get gkm 6
+gpu_kv 10 get gkm 7
+gpu_kv 11 get gkm 8
+gpu_kv 12 get gkm 9
+gpu_kv 13 get gkm 10
+gpu_kv 14 uint get gcnt 0
+gpu_kv 15 uint get gnv 0
+gpu_kv 16 uint get gnu 0
+gpu_pt 17
+gpu_nl
+end
+
+note " x" for a signed number
+fn gpu_sp x long to void
+gpu_pc 32
+gpu_pi x
+end
+
+fn gpu_dregs to void
+n = get gnv 0
+for v int n
+gpu_pt 18
+gpu_pi long v
+gpu_sp long v
+gpu_sp long get gvfd v
+gpu_sp long get gvlu v
+gpu_sp -1
+b = get gvbs v
+gpu_sp long b
+gpu_sp long sub b 1
+gpu_sp 0
+gpu_sp 0
+gpu_sp -1
+gpu_nl
+end
+m = get gnu 0
+for u int m
+gpu_pt 19
+gpu_pi long u
+gpu_sp long u
+gpu_sp long get gufd u
+gpu_sp long get gulu u
+gpu_sp -1
+gpu_sp 0
+gpu_sp 1
+gpu_sp 0
+gpu_sp 0
+gpu_sp -1
+gpu_nl
+end
+end
+
+fn gpu_dinsn to void
+n = get gcnt 0
+for i int n
+gpu_pt 20
+gpu_pi long i
+gpu_sp long get gxop i
+gpu_sp long get gxd i
+gpu_sp long get gx1 i
+gpu_sp long get gx2 i
+gpu_sp long get gx3 i
+gpu_sp long get gxu i
+gpu_sp long get gxim i
+gpu_sp long get gxct i
+gpu_sp long get gxun i
+gpu_sp long get gxp0 i
+gpu_sp long get gxpn i
+gpu_sp 0
+gpu_sp 0
+gpu_sp 0
+gpu_sp 0
+gpu_sp long get gxbr i
+gpu_nl
+end
+gpu_pt 21
+gpu_nl
+end
+
+fn gpu_dump to void
+gpu_dhead
+gpu_dregs
+gpu_dinsn
+end
diff --git a/seed/oscgpu/gpulow.om b/seed/oscgpu/gpulow.om
new file mode 100644
index 000000000..0591fe221
--- /dev/null
+++ b/seed/oscgpu/gpulow.om
@@ -0,0 +1,1029 @@
+note seed/oscgpu/gpulow.om: the lowering of one OSC IR kernel function to BlackwellIR, a port of
+note src/omega_osc_gpu.c (cfg, uniformity, regions, liveness, params_and_layout, prologue, lower,
+note emit_block, finish) including every osc_gpu_mutant 1..8. Reads the decoded unit of oscir.om.
+
+note ---- bitsets: block sets of 9 words (blocks 0..512), vreg sets of 8 words (vregs 0..479)
+note block-set ids: 0..512 post-dominators, 513..576 regions, 577 scratch m, 578 scratch n,
+note 579 noregion, 580 all
+global gbs ulong 5229
+note vreg-set ids: 0..511 live_in, 512..1023 live_out, 1024.. use, 1536.. def, 2048 out, 2049 in
+global gvs ulong 16400
+
+note ---- analysis state
+global gnb int 1
+global gns int 512
+global gsc int 1024
+global gipd int 512
+global gstk int 1024
+global gus int 4
+global gvar uchar 480
+global gdiv uchar 512
+note regions: head, join, bar, parent, bssy_at, bsync_at; count
+global grh int 64
+global grj int 64
+global grb int 64
+global grp int 64
+global grs int 64
+global gry int 64
+global gnr int 1
+global gna int 512
+global gam int 8192
+note layout
+global gmap int 480
+global gsho uint 480
+global gshl uint 480
+global garg uint 480
+note block positions
+global gbf int 512
+global gbl int 512
+global gaa int 512
+global gba int 512
+note fixes: at, kind (0 edge, 1 bsync, 2 arms), a, b
+global gfa int 4096
+global gfk int 4096
+global gfx int 4096
+global gfy int 4096
+global gnf int 1
+
+note ---- unit access
+fn gpu_ix i int to ulong
+ret add mul get gfn 0 4096 ulong i
+end
+
+fn gpu_vx v int to ulong
+ret add mul get gfn 0 480 ulong v
+end
+
+fn gpu_bx b int to ulong
+ret add mul get gfn 0 512 ulong b
+end
+
+fn gpu_bf b int to int
+ret int get bfst gpu_bx b
+end
+
+fn gpu_term b int to int
+s = gpu_bx b
+ret sub add int get bfst s int get bcnt s 1
+end
+
+fn gpu_ty v int to uchar
+ret get vts gpu_vx v
+end
+
+fn gpu_r v int to int
+ret get gmap v
+end
+
+note ---- block sets
+fn gpu_bw s int i int to ulong
+ret add mul ulong s 9 ulong shr i 6
+end
+
+fn gpu_bhas s int i int to bool
+w = get gbs gpu_bw s i
+ret eq and shr w ulong and i 63 1 1
+end
+
+fn gpu_bset s int i int to void
+x = gpu_bw s i
+put gbs x or get gbs x shl 1 ulong and i 63
+end
+
+fn gpu_bclr s int to void
+b = mul ulong s 9
+for k ulong 9
+put gbs add b k 0
+end
+end
+
+fn gpu_bcopy d int s int to void
+x = mul ulong d 9
+y = mul ulong s 9
+for k ulong 9
+put gbs add x k get gbs add y k
+end
+end
+
+fn gpu_band d int s int to void
+x = mul ulong d 9
+y = mul ulong s 9
+for k ulong 9
+p = add x k
+q = get gbs add y k
+put gbs p and get gbs p q
+end
+end
+
+fn gpu_bor d int s int to void
+x = mul ulong d 9
+y = mul ulong s 9
+for k ulong 9
+p = add x k
+q = get gbs add y k
+put gbs p or get gbs p q
+end
+end
+
+fn gpu_beq a int b int to bool
+x = mul ulong a 9
+y = mul ulong b 9
+for k ulong 9
+q = get gbs add y k
+if ne get gbs add x k q
+ret false
+end
+end
+ret true
+end
+
+note a within b
+fn gpu_bsub a int b int to bool
+x = mul ulong a 9
+y = mul ulong b 9
+for k ulong 9
+q = not get gbs add y k
+if ne and get gbs add x k q 0
+ret false
+end
+end
+ret true
+end
+
+fn gpu_bmeet a int b int to bool
+x = mul ulong a 9
+y = mul ulong b 9
+for k ulong 9
+q = get gbs add y k
+if ne and get gbs add x k q 0
+ret true
+end
+end
+ret false
+end
+
+fn gpu_pop w ulong to int
+n = int 0
+x = w
+while ne x 0 bound 65
+x = and x sub x 1
+n = add n 1
+end
+ret n
+end
+
+fn gpu_bcnt s int to int
+x = mul ulong s 9
+n = int 0
+for k ulong 9
+c = gpu_pop get gbs add x k
+n = add n c
+end
+ret n
+end
+
+note ---- vreg sets
+fn gpu_vhas s int i int to bool
+w = get gvs add mul ulong s 8 ulong shr i 6
+ret eq and shr w ulong and i 63 1 1
+end
+
+fn gpu_vset s int i int to void
+x = add mul ulong s 8 ulong shr i 6
+put gvs x or get gvs x shl 1 ulong and i 63
+end
+
+fn gpu_vclr s int to void
+b = mul ulong s 8
+for k ulong 8
+put gvs add b k 0
+end
+end
+
+note ---- instruction uses and defs (insn_uses, insn_def)
+fn gpu_uses i int to int
+s = gpu_ix i
+o = get iop s
+a = get ia s
+b = get ib s
+c = get ic s
+put gus 0 a
+put gus 1 b
+put gus 2 c
+if or or or eq o 2 eq o 4 eq o 6 eq o 14
+ret 1
+end
+if or or or eq o 3 eq o 5 eq o 9 eq o oshfl
+ret 2
+end
+if or eq o 10 eq o omad
+ret 3
+end
+if eq o ogld
+put gus 1 add a 1
+put gus 2 b
+ret 3
+end
+if eq o ogst
+put gus 1 add a 1
+put gus 2 b
+put gus 3 c
+ret 4
+end
+if eq o 15
+if ge a 0
+ret 1
+end
+end
+ret 0
+end
+
+fn gpu_def i int to int
+s = gpu_ix i
+o = get iop s
+if or or or or or eq o 1 eq o 2 eq o 3 eq o 4 eq o 5 eq o 6
+ret get idst s
+end
+if or or or or or eq o 9 eq o ogpu eq o oshar eq o ogld eq o oshfl eq o omad
+ret get idst s
+end
+ret -1
+end
+
+note single_const: the one u32 value of vreg v (defined once, by a CONST, not a parameter); -1 if not
+fn gpu_sconst v int to long
+f = get gfn 0
+n = int get fnin f
+defs = int 0
+val = long 0
+for i int n
+d = gpu_def i
+if eq d v
+defs = add defs 1
+s = gpu_ix i
+if ne get iop s 1
+ret -1
+end
+val = long and get iimm s 4294967295
+end
+end
+if ne defs 1
+ret -1
+end
+if lt v int get fnpar f
+ret -1
+end
+ret val
+end
+
+note ---- cfg: successors, post-dominators, immediate post-dominators
+fn gpu_succ to int
+nb = get gnb 0
+for b int nb
+t = gpu_term b
+s = gpu_ix t
+o = get iop s
+put gns b 0
+k = mul b 2
+if eq o 13
+put gsc k get ibt s
+put gns b 1
+end
+if eq o 14
+put gsc k get ibt s
+put gsc add k 1 get ibf s
+put gns b 2
+end
+if and ne o 13 and ne o 14 ne o 15
+r = gpu_f2 29 long b 30
+ret -1
+end
+end
+ret 0
+end
+
+fn gpu_pdom to void
+x = get gnb 0
+gpu_bclr 580
+for d int add x 1
+gpu_bset 580 d
+end
+for b int x
+gpu_bcopy b 580
+end
+gpu_bclr x
+gpu_bset x x
+ch = true
+while ch bound 999999
+ch = false
+b = sub x 1
+while ge b 0 bound 999999
+n = get gns b
+k = mul b 2
+if eq n 0
+gpu_bcopy 578 x
+else
+gpu_bcopy 578 get gsc k
+if eq n 2
+gpu_band 578 get gsc add k 1
+end
+end
+gpu_bset 578 b
+if not gpu_beq 578 b
+gpu_bcopy b 578
+ch = true
+end
+b = sub b 1
+end
+end
+end
+
+fn gpu_ipdom to void
+x = get gnb 0
+for b int x
+put gipd b -1
+w = sub gpu_bcnt b 1
+for d int add x 1
+if ne d b
+if gpu_bhas b d
+c = gpu_bcnt d
+if eq c w
+put gipd b d
+break
+end
+end
+end
+end
+end
+end
+
+fn gpu_cfg to int
+f = get gfn 0
+put gnb 0 int get fnbl f
+r = gpu_succ
+if lt r 0
+ret -1
+end
+gpu_pdom
+gpu_ipdom
+ret 0
+end
+
+note reach_from(b, j) into set 577
+fn gpu_reach b int j int to void
+gpu_bclr 577
+sp = int 0
+n = get gns b
+for k int n
+y = get gsc add mul b 2 k
+if ne y j
+if not gpu_bhas 577 y
+gpu_bset 577 y
+put gstk sp y
+sp = add sp 1
+end
+end
+end
+while gt sp 0 bound 999999
+sp = sub sp 1
+x = get gstk sp
+m = get gns x
+for k int m
+y = get gsc add mul x 2 k
+if ne y j
+if not gpu_bhas 577 y
+gpu_bset 577 y
+put gstk sp y
+sp = add sp 1
+end
+end
+end
+end
+end
+
+note ---- uniformity
+fn gpu_isvar b int i int to bool
+if ne get gdiv b 0
+ret true
+end
+s = gpu_ix i
+o = get iop s
+if or or eq o ogld eq o 9 eq o oshfl
+ret true
+end
+if and eq o ogpu eq get isub s 1
+ret true
+end
+n = gpu_uses i
+for k int n
+if ne get gvar get gus k 0
+ret true
+end
+end
+ret false
+end
+
+fn gpu_unif1 to bool
+ch = false
+nb = get gnb 0
+for b int nb
+x = gpu_bf b
+e = add gpu_term b 1
+i = x
+while lt i e bound 999999
+d = gpu_def i
+if ge d 0
+if eq get gvar d 0
+v = gpu_isvar b i
+if v
+put gvar d 1
+ch = true
+end
+end
+end
+i = add i 1
+end
+end
+ret ch
+end
+
+fn gpu_unif2 to bool
+ch = false
+nb = get gnb 0
+for b int nb
+s = gpu_ix gpu_term b
+if eq get iop s 14
+if ne get gvar get ia s 0
+j = get gipd b
+if lt j 0
+j = nb
+end
+gpu_reach b j
+for x int nb
+if gpu_bhas 577 x
+if eq get gdiv x 0
+put gdiv x 1
+ch = true
+end
+end
+end
+end
+end
+end
+ret ch
+end
+
+fn gpu_unif to void
+for v ulong 480
+put gvar v 0
+end
+for b ulong 512
+put gdiv b 0
+end
+ch = true
+while ch bound 999999
+a = gpu_unif1
+c = gpu_unif2
+ch = or a c
+end
+end
+
+note ---- liveness
+fn gpu_lv0 to void
+nb = get gnb 0
+for b int nb
+u = add 1024 b
+d = add 1536 b
+gpu_vclr u
+gpu_vclr d
+gpu_vclr b
+gpu_vclr add 512 b
+x = gpu_bf b
+e = add gpu_term b 1
+i = x
+while lt i e bound 999999
+n = gpu_uses i
+for k int n
+w = get gus k
+if not gpu_vhas d w
+gpu_vset u w
+end
+end
+y = gpu_def i
+if ge y 0
+gpu_vset d y
+end
+i = add i 1
+end
+end
+end
+
+note out = the union of live_in of the successors of b, into vset 2048
+fn gpu_lvo b int to void
+gpu_vclr 2048
+n = get gns b
+for k int n
+y = mul ulong get gsc add mul b 2 k 8
+for w ulong 8
+p = add 16384 w
+q = get gvs add y w
+put gvs p or get gvs p q
+end
+end
+end
+
+note one block of the liveness pass; true when live_in or live_out changed
+fn gpu_lv1 b int to bool
+gpu_lvo b
+ch = false
+xi = mul ulong b 8
+xo = mul ulong add 512 b 8
+xu = mul ulong add 1024 b 8
+xd = mul ulong add 1536 b 8
+for w ulong 8
+z = get gvs add 16384 w
+e = not get gvs add xd w
+q = or get gvs add xu w and z e
+if ne q get gvs add xi w
+put gvs add xi w q
+ch = true
+end
+if ne z get gvs add xo w
+put gvs add xo w z
+ch = true
+end
+end
+ret ch
+end
+
+fn gpu_live to void
+gpu_lv0
+nb = get gnb 0
+ch = true
+while ch bound 999999
+ch = false
+b = sub nb 1
+while ge b 0 bound 999999
+c = gpu_lv1 b
+if c
+ch = true
+end
+b = sub b 1
+end
+end
+end
+
+note ---- regions
+note the head of the region in set 577 for branch block b; -2 when refused
+fn gpu_head b int to int
+h = int -1
+nb = get gnb 0
+for u int nb
+if not gpu_bhas 577 u
+n = get gns u
+for k int n
+v = get gsc add mul u 2 k
+if gpu_bhas 577 v
+if and ge h 0 ne h v
+gpu_fb 29
+gpu_pi long b
+gpu_pt 34
+gpu_pi long h
+gpu_pt 35
+gpu_pi long v
+gpu_pt 36
+gpu_fe
+ret -2
+end
+h = v
+end
+end
+end
+end
+if gpu_bhas 577 0
+if and ge h 0 ne h 0
+gpu_fb 29
+gpu_pi long b
+gpu_pt 34
+gpu_pi long h
+gpu_pt 37
+gpu_fe
+ret -2
+end
+h = 0
+end
+if lt h 0
+r = gpu_f2 29 long b 38
+ret -2
+end
+ret h
+end
+
+fn gpu_reg1 b int to int
+j = get gipd b
+if lt j 0
+r = gpu_f2 29 long b 31
+ret -1
+end
+gpu_reach b j
+if eq j get gnb 0
+gpu_bor 579 577
+ret 0
+end
+gpu_bset 577 b
+nr = get gnr 0
+dup = int -1
+for r int nr
+if gpu_beq add 513 r 577
+dup = r
+end
+end
+if ge dup 0
+if ne get grj dup j
+r = gpu_f2 29 long b 32
+ret -1
+end
+ret 0
+end
+if ge nr 64
+r = gpu_f1 33
+ret -1
+end
+h = gpu_head b
+if lt h -1
+ret -1
+end
+gpu_bcopy add 513 nr 577
+put grh nr h
+put grj nr j
+put grp nr -1
+put grs nr -1
+put gry nr -1
+put grb nr 0
+put gnr 0 add nr 1
+ret 0
+end
+
+fn gpu_nest to int
+nr = get gnr 0
+for a int nr
+best = int -1
+for b int nr
+if ne b a
+x = gpu_bsub add 513 a add 513 b
+y = gpu_bsub add 513 b add 513 a
+z = gpu_bmeet add 513 a add 513 b
+if and and not x not y z
+r = gpu_f1 41
+ret -1
+end
+if and x not y
+if lt best 0
+best = b
+else
+c = gpu_bcnt add 513 b
+e = gpu_bcnt add 513 best
+if lt c e
+best = b
+end
+end
+end
+end
+end
+put grp a best
+end
+ret 0
+end
+
+fn gpu_conf a int b int to bool
+x = gpu_bsub add 513 a add 513 b
+y = gpu_bsub add 513 b add 513 a
+if or x y
+ret true
+end
+nr = get gnr 0
+for c int nr
+if and ne c a ne c b
+p = gpu_bsub add 513 a add 513 c
+q = gpu_bsub add 513 b add 513 c
+if and p q
+ret true
+end
+end
+end
+ret false
+end
+
+fn gpu_bars to int
+nr = get gnr 0
+used = uint 0
+for a int nr
+busy = uint 0
+for b int a
+c = gpu_conf a b
+if c
+busy = or busy shl 1 uint get grb b
+end
+end
+bar = uint 0
+while lt bar 16 bound 17
+if eq and shr busy bar 1 0
+break
+end
+bar = add bar 1
+end
+if ge bar 16
+r = gpu_f1 42
+ret -1
+end
+if eq get gmut 0 5
+put grb a 0
+else
+put grb a int bar
+end
+used = or used shl 1 bar
+end
+put gkm 9 uint nr
+put gkm 10 uint gpu_pop ulong used
+ret 0
+end
+
+fn gpu_arms to int
+for b ulong 512
+put gna b 0
+end
+nr = get gnr 0
+for r int nr
+h = get grh r
+pos = get gna h
+if ge pos 16
+q = gpu_f2 43 long h -1
+ret -1
+end
+put gna h add pos 1
+c = gpu_bcnt add 513 r
+while gt pos 0 bound 17
+p = get gam add mul h 16 sub pos 1
+e = gpu_bcnt add 513 p
+if ge e c
+break
+end
+put gam add mul h 16 pos p
+pos = sub pos 1
+end
+put gam add mul h 16 pos r
+end
+ret 0
+end
+
+fn gpu_regions to int
+put gnr 0 0
+gpu_bclr 579
+nb = get gnb 0
+for b int nb
+s = gpu_ix gpu_term b
+if eq get iop s 14
+if ne get gvar get ia s 0
+r = gpu_reg1 b
+if lt r 0
+ret -1
+end
+end
+end
+end
+nr = get gnr 0
+for r int nr
+h = get grh r
+if gpu_bhas 579 h
+q = gpu_f2 39 long h 40
+ret -1
+end
+end
+r = gpu_nest
+if lt r 0
+ret -1
+end
+r = gpu_bars
+if lt r 0
+ret -1
+end
+r = gpu_arms
+ret r
+end
+
+note ---- parameters and layout
+fn gpu_par1 v int off uint to uint
+k = get gkm 2
+s = gpu_ty v
+if or eq s 4 or eq s 13 eq s 1
+kd = uchar 3
+if eq s 13
+kd = 4
+end
+if eq s 1
+kd = 5
+end
+put gpk k kd
+put gpe k 0
+put gpo k off
+put garg v off
+ret add off 4
+end
+ret 0
+end
+
+note one parameter; returns the next offset, or 4294967295 when refused; *v advances by gstk[0]
+fn gpu_param v int off uint to uint
+f = get gfn 0
+np = int get fnpar f
+k = get gkm 2
+s = gpu_ty v
+put gstk 0 1
+if or eq s 14 eq s 15
+if ge add v 1 np
+r = gpu_f2 47 long v 48
+ret 4294967295
+end
+if ne gpu_ty add v 1 4
+r = gpu_f2 47 long v 48
+ret 4294967295
+end
+o = and add off 7 not uint 7
+kd = uchar 1
+if eq s 15
+kd = 2
+end
+el = get vtel gpu_vx v
+put gpk k kd
+put gpe k el
+put gpo k o
+if and ne el 4 ne el 13
+gpu_fb 49
+gpu_ps el
+gpu_fe
+ret 4294967295
+end
+put garg v o
+put garg add v 1 add o 8
+put gstk 0 2
+ret add o 12
+end
+if or eq s 4 or eq s 13 eq s 1
+n = gpu_par1 v off
+ret n
+end
+gpu_fb 50
+gpu_pi long v
+gpu_pt 51
+gpu_ps s
+gpu_fe
+ret 4294967295
+end
+
+fn gpu_layout to int
+f = get gfn 0
+nv = int get fnvr f
+sh = uint 0
+for v int nv
+put gmap v -1
+s = gpu_ty v
+if eq s 10
+x = gpu_vx v
+if ne get vtref x 4
+r = gpu_f2 54 long v 55
+ret -1
+end
+put gsho v sh
+put gshl v get vtlen x
+sh = add sh mul 4 get vtlen x
+continue
+end
+if or eq s 14 eq s 15
+r = bw_v64
+put gmap v r
+continue
+end
+if or eq s 4 or eq s 13 eq s 1
+r = bw_v
+put gmap v r
+continue
+end
+gpu_fb 54
+gpu_pi long v
+gpu_pt 51
+gpu_ps s
+gpu_fe
+ret -1
+end
+if gt sh 49152
+r = gpu_f2 56 long sh 57
+ret -1
+end
+put gkm 1 sh
+if ne get gee 0 0
+r = gpu_f1 58
+ret -1
+end
+ret 0
+end
+
+fn gpu_params to int
+f = get gfn 0
+np = int get fnpar f
+off = uint 0
+put gkm 2 0
+v = int 0
+while lt v np bound 999999
+off = gpu_param v off
+if eq off 4294967295
+ret -1
+end
+put gkm 2 add get gkm 2 1
+v = add v get gstk 0
+end
+off = and add off 7 not uint 7
+put gkm 3 off
+put gkm 4 add off 8
+put gkm 5 add off 12
+off = add off 16
+if gt div off 4 32
+r = gpu_f2 52 long div off 4 53
+ret -1
+end
+put gkm 6 div off 4
+r = gpu_layout
+ret r
+end
+
+note ---- prologue
+fn gpu_pzero to void
+t0 = gpu_t 0
+t1 = gpu_t 1
+t2 = gpu_t 2
+bw_s2r t0 33
+bw_imadi t0 t0 4 -1
+bw_movi t1 get gkm 1 0
+bw_movi t2 mul 4 get gkm 0 0
+bs = bw_here
+bw_i0 54
+bw_im 2
+bw_e 8 0
+bw_lbeg
+top = bw_here
+bw_ge t0 t1
+out = bw_branch 1
+bw_sts32 t0 get grg 4 0
+bw_iadd t0 t0 t2
+bw_bra top
+bw_lend
+j = bw_here
+bw_i0 55
+bw_e 9 0
+bw_patch out j
+if eq get gee 0 0
+put gxim bs gpu_u32 sub add j 1 bs
+end
+bw_bar
+end
+
+fn gpu_addfix p int k int a int b int to void
+n = get gnf 0
+if ge n 4096
+r = gpu_f1 65
+ret
+end
+put gfa n p
+put gfk n k
+put gfx n a
+put gfy n b
+put gnf 0 add n 1
+end
+
+fn gpu_prolog to void
+put grg 0 bw_uv64
+put grg 1 bw_v64
+put grg 2 bw_v64
+for k ulong 9
+put grg add k 3 bw_v
+end
+bw_ldcu64 get grg 0 856
+f = get gfn 0
+nv = int get fnpar f
+for v int nv
+s = gpu_ty v
+if or eq s 14 eq s 15
+bw_ldc64 get gmap v add 896 get garg v
+else
+bw_ldc32 get gmap v add 896 get garg v
+end
+end
+bw_ldc64 get grg 1 add 896 get gkm 3
+bw_movi get grg 3 1 0
+bw_movi get grg 4 0 0
+bw_movi get grg 5 0 0
+if and ne get gkm 1 0 ne get gmut 0 6
+gpu_pzero
+end
+p = bw_branch 0
+gpu_addfix p 0 -1 0
+end
diff --git a/seed/oscgpu/gpumain.om b/seed/oscgpu/gpumain.om
new file mode 100644
index 000000000..c75bd5add
--- /dev/null
+++ b/seed/oscgpu/gpumain.om
@@ -0,0 +1,177 @@
+note seed/oscgpu/gpumain.om: the driver. gpu <unit.ir> <kernel> <out.bwir> <mutant 0..8>
+note Picks the last function of that name (as osc_gpu_build does), lowers it to BlackwellIR and
+note writes the dump; or prints one REFUSED line. Exit 0 written, 1 refused, 2 usage or I/O.
+note Build: cat seed/oscgpu/oscir.om seed/oscgpu/gpuir.om seed/oscgpu/gpulow.om
+note seed/oscgpu/gpuemit.om seed/oscgpu/gpumain.om | seed/out/omc > gpu
+
+global gkn uchar 4096
+global gkl ulong 1
+global gpth uchar 4096
+global gptl ulong 1
+global gnum uchar 16
+
+note write gob[0..gop) to fd, then empty it; -1 on a short write
+fn gpu_flush fd int to int
+n = get gop 0
+o = ulong 0
+put gop 0 0
+while lt o n bound 999999
+r = write fd gob o sub n o
+if le r 0
+ret -1
+end
+o = add o ulong r
+end
+ret 0
+end
+
+fn gpu_say fd int id int to int
+gpu_pt id
+gpu_nl
+r = gpu_flush fd
+ret r
+end
+
+note the last function whose name is the kernel argument; -1 if none
+fn gpu_find to int
+nf = get unfn 0
+kl = get gkl 0
+fn0 = int -1
+for f uint nf
+n = ulong get fnlen f
+if ne n kl
+continue
+end
+same = true
+for k ulong n
+q = get gkn k
+if ne get fname add mul ulong f 64 k q
+same = false
+end
+end
+if same
+fn0 = int f
+end
+end
+ret fn0
+end
+
+fn gpu_mutarg to int
+n = argread 4 gnum 0 15
+if lt n 1
+ret -1
+end
+if gt n 2
+ret -1
+end
+m = int 0
+for k ulong ulong n
+c = get gnum k
+if or lt c 48 gt c 57
+ret -1
+end
+m = add mul m 10 int sub c 48
+end
+if gt m 8
+ret -1
+end
+ret m
+end
+
+fn gpu_wdump to int
+gpu_dump
+n = argread 3 gpth 0 4095
+if lt n 1
+ret -1
+end
+fl = fopen gpth 0 ulong n 524481 420
+if lt fl 0
+ret -1
+end
+fd = int fl
+r = gpu_flush fd
+c = fclose fd
+if or lt r 0 ne c 0
+ret -1
+end
+ret 0
+end
+
+fn gpu_rdec rc int to void
+gpu_pt 22
+x = neg rc
+if or lt x 0 gt x 11
+gpu_pt 114
+else
+gpu_pt add 102 x
+end
+gpu_nl
+r = gpu_flush 1
+end
+
+fn main to int
+gpu_init
+if ne argcnt 5
+r = gpu_say 2 115
+ret 2
+end
+m = gpu_mutarg
+if lt m 0
+r = gpu_say 2 115
+ret 2
+end
+put gmut 0 m
+kl = argread 2 gkn 0 4095
+pl = argread 1 gpth 0 4095
+if or lt kl 0 lt pl 0
+r = gpu_say 2 115
+ret 2
+end
+put gkl 0 ulong kl
+put gptl 0 ulong pl
+rd = oscir_read_file 1
+if ne rd 0
+r = gpu_say 2 116
+ret 2
+end
+if gt get irlen 0 1048576
+put irlen 0 1048576
+end
+rc = oscir_decode
+if ne rc 0
+gpu_rdec rc
+ret 1
+end
+f = gpu_find
+if lt f 0
+gpu_pt 23
+for k ulong ulong kl
+gpu_pc get gkn k
+end
+gpu_pt 24
+for k ulong ulong pl
+gpu_pc get gpth k
+end
+gpu_nl
+r = gpu_flush 1
+ret 1
+end
+put gfn 0 ulong f
+lw = gpu_lower
+if ne lw 0
+gpu_pt 25
+n = get gern 0
+for k ulong n
+gpu_pc get gerr k
+end
+gpu_nl
+r = gpu_flush 1
+ret 1
+end
+w = gpu_wdump
+if ne w 0
+r = gpu_say 2 117
+ret 2
+end
+ret 0
+end
diff --git a/seed/oscgpu/oscir.om b/seed/oscgpu/oscir.om
new file mode 100644
index 000000000..a39bdedd2
--- /dev/null
+++ b/seed/oscgpu/oscir.om
@@ -0,0 +1,3118 @@
+note seed/oscgpu/oscir.om: strict OSC binary IR decoder and validator in seeded Omega.
+note Port of osc_ir_decode + osc_ir_validate (src/compiler/osc_ir.c); the C stays as the
+note differential oracle (tests/osc_gpu/oscir_diff.sh). No imports: concatenate this file
+note in front of its users with cat. The decoded unit lives in the contract globals below
+note (read-only for users). Private globals start with o, functions with oscir_.
+note Entry points:
+note   oscir_read_file ai ulong to int    read the file named by argv[ai] into irbuf/irlen
+note                                      (0 ok, -1 unreadable); irlen is the true length
+note   oscir_decode to int                0 ok, else the negative OscIrRefusal of osc_ir.c
+note   oscir_validate to int              0 ok, -1 refused, message in oerr / oerrn
+note A refused decode leaves every contract global zero, as osc_ir_decode memsets its unit.
+note oerr is meaningful only after a direct oscir_validate call.
+
+global irbuf uchar 4194304
+global irlen ulong 1
+global unfn uint 1
+global unst uint 1
+global fkind uchar 32
+global fthr uint 32
+global fnpar uint 32
+global fnvr uint 32
+global fnin uint 32
+global fnbl uint 32
+global fname uchar 2048
+global fnlen uint 32
+global frs uchar 32
+global frref uchar 32
+global frel uchar 32
+global frlen uint 32
+global frsid uchar 32
+global vts uchar 15360
+global vtref uchar 15360
+global vtel uchar 15360
+global vtlen uint 15360
+global vtsid uchar 15360
+global iop uchar 131072
+global isub uchar 131072
+global idst int 131072
+global ia int 131072
+global ib int 131072
+global ic int 131072
+global ibt int 131072
+global ibf int 131072
+global icall int 131072
+global inarg uchar 131072
+global iimm ulong 131072
+global iline uint 131072
+global iarg int 786432
+global bfst uint 16384
+global bcnt uint 16384
+
+note private state
+global opos ulong 1
+global orc int 1
+global onoval uchar 1
+global oerr uchar 256
+global oerrn ulong 1
+global osnm uchar 1024
+global osnl uint 16
+global osnf uint 16
+global osnc uint 16
+global osfnm uchar 16384
+global osfnl uint 256
+global osfs uchar 256
+global osfal uint 256
+global osfof uint 256
+global oreq uchar 8192
+global oreql uint 32
+global oens uchar 8192
+global oensl uint 32
+global ot uchar 4
+global otl uint 1
+global oma long 4
+global omai ulong 1
+global osl uchar 480
+global ocov uchar 4096
+global ondef uint 480
+global ohk uchar 480
+global opk uchar 480
+global obin ulong 4096
+global obout ulong 4096
+global ocur ulong 8
+global ous int 12
+global ox ulong 4
+global osb ulong 1
+global owp ulong 1
+global owd uchar 1
+global oxs uchar 65536
+global opath uchar 4096
+
+note kernel wire numbers, as osc_ir.h defines them since 451cbcb6c: kernel units are
+note encoding version 8 (OSC_IR_VERSION_KERNEL), ops OSC_I_GPU..OSC_I_MAD = 40..46.
+note Versions 6 and 7 and ops 30..39 are refused.
+const okver ulong 8
+const ogpu uchar 40
+const oshar uchar 41
+const ogld uchar 42
+const ogst uchar 43
+const osync uchar 44
+const oshfl uchar 45
+const omad uchar 46
+
+text omagic "OSC1IR"
+text ostr "void\nbool\nu8\nu16\nu32\nu64\ni8\ni16\ni32\ni64\nref\nbytes\ncells\nf32\ngview\ngedit\n?\nSLOAD\nSSTORE\nFLOAD\nFSTORE\nGLOAD\nGSTORE\n"
+note message templates, id = line number from 0; a leading @ stands for template 0
+text omt "func %d insn %u: \n@CONST bad dst vreg %d\n@CONST dst not scalar\n@CONST imm not canonical for %s\n@MOV bad vreg\n@MOV ref kind/type mismatch\n@MOV type mismatch\n@BIN bad vreg\n@BIN bad sub-op %u\n@BIN dst/a type mismatch\n@BIN operand type mismatch\n@f32 BIN sub-op %u not allowed\n@MIN/MAX need u32 or f32\n@shift of non-integer\n@shift amount not integer\n@arith BIN needs identical integer types\n@UN bad vreg\n@UN type mismatch\n@LNOT needs bool\n@NEG needs a number\n@BNOT needs integer\n@EXP/INV/RSQ/SQRT need f32\n@UN bad sub-op %u\n@CMP bad vreg\n@CMP bad cc %u\n@CMP dst not bool\n@CMP operand type mismatch\n@CAST bad vreg\n@f32 CAST needs u32 <-> f32\n@CAST needs integer types\n@ALLOC bad vreg\n@ALLOC dst not an owner\n@ALLOC struct init not u64\n@ALLOC init type != elem type\n@RELEASE bad vreg\n@RELEASE of a non-owner\n@AOPEN bad vreg\n@AOPEN handle not u64\n@AOPEN capacity out of range\n@AALLOC bad vreg\n@AALLOC dst not an owner\n@AALLOC struct init not u64\n@AALLOC init type != elem type\n@AALLOC handle not u64\n@ADESTROY handle not u64\n@POPEN pool not u64\n@POPEN slot count out of range\n@POPEN element type not scalar\n@PCLOSE pool not u64\n@handle op bad operand\n@handle op bad dst\n@handle slot/gen not u64\n@HSTORE needs one value\n@handle slot not u64\n@handle gen not u64\n@LOAD bad vreg\n@LOAD base not an array ref\n@LOAD index not integer\n@LOAD dst type != elem\n@STORE bad vreg\n@STORE through a shared borrow or non-ref\n@STORE index not integer\n@STORE value type != elem\n@%s bad vreg\n@%s base not a slice pointer\n@%s index not integer\n@%s value not u64\n@SSTORE into a bytes slice\n@%s base not a struct ref\n@%s field %llu out of range\n@field index not integer\n@scalar field with an index\n@field value type != field type\n@FSTORE through a shared borrow\n@CALL to function %d not defined earlier\n@CALL arity %u != %u\n@CALL bad arg vreg\n@CALL arg %d slice mismatch\n@CALL arg %d ref mismatch\n@CALL arg %d type mismatch\n@CALL of void function with dst\n@CALL dst type != callee return\n@GPU dst not u32\n@GPU bad value %u\n@SHARED dst not a block array\n@%s base not a global buffer\n@%s index not u32\n@%s value type != elem\n@GSTORE into a view buffer\n@SHFL bad sub-op %u\n@SHFL bad vreg\n@SHFL value not u32/f32\n@SHFL distance not u32\n@MAD bad vreg\n@MAD needs f32\n@TRAP bad code\n@BR bad target\n@CBR condition not bool\n@CBR bad target\n@RET value from void function\n@RET type mismatch\n@unknown op %u\nfunc %d: name not terminated\nfunc %d: contract text not terminated\nfunc %d: bad kind %u\nfunc %d: bad thread count %u\nfunc %d: %u params > %d\nfunc %d: bad nvregs\nfunc %d: return type must be void or scalar\nfunc %d: vreg %d has invalid type\nfunc %d: vreg %d: type %s not allowed in a kernel\nfunc %d: vreg %d: kernel type in a host function\nfunc %d: f32 return from a host function\nfunc %d: a kernel returns nothing and has no contract\nfunc %d: slice vreg %d is not a parameter pair with a u64 length\nfunc %d: buffer vreg %d is not a parameter pair with a u32 length\nfunc %d: block array %d as a parameter\nfunc %d: bad ninsns\nfunc %d: bad nblocks\nfunc %d block %d: bad range\nfunc %d: insn %u in two blocks\nfunc %d block %d: missing terminator\nfunc %d block %d: terminator before block end\nfunc %d: insn %u in no block\n@slice register redefined\n@kernel instruction in a host function\n@call to a kernel\n@op %u not allowed in a kernel\n@SHARED outside the entry block\n@block array defined more than once\n@block arrays over %u bytes\n@kernel div/rem needs a nonzero constant divisor\n@shuffle distance is not one constant 1..31\n@AOPEN handle vreg reused\n@arena handle vreg redefined\n@AALLOC handle misuse\n@ADESTROY of a non-handle\n@arena handle used as a value\n@POPEN pool vreg reused\n@pool vreg redefined\n@PCLOSE of a non-pool\n@HALLOC pool misuse\n@HALLOC init type != pool element type\n@handle pool misuse\n@HLOAD type != pool element type\n@HSTORE value type != pool element type\n@pool used as a value\n@vreg %d may be used before it is defined\nout of memory\ntoo many structs\nstruct %d: bad name\nstruct %d: duplicate name\nstruct %d: bad field count\nstruct %d field %d: bad name\nstruct %d field %d: duplicate\nstruct %d field %d: bad type\nstruct %d field %d: offset %u != %u\nstruct %d: bad size\nnull unit\ntoo many functions\n"
+
+note ---- file loader ----------------------------------------------------
+fn oscir_read_file ai ulong to int
+n = argread ai opath 0 4095
+if lt n 0
+ret -1
+end
+fd = fopen opath 0 ulong n 0 0
+if lt fd 0
+ret -1
+end
+h = int fd
+t = ulong 0
+w = false
+while lt t 4194304 bound 999999
+x = read h irbuf t sub ulong 4194304 t
+if lt x 0
+w = true
+break
+end
+if eq x 0
+break
+end
+t = add t ulong x
+end
+if eq t 4194304
+while true bound 999999
+x = read h oxs 0 65536
+if lt x 0
+w = true
+break
+end
+if eq x 0
+break
+end
+t = add t ulong x
+end
+end
+c = fclose h
+put irlen 0 t
+if w
+ret -1
+end
+ret 0
+end
+
+note ---- reader (R of osc_ir.c) ------------------------------------------
+fn oscir_fail rc int to void
+if eq get orc 0 0
+put orc 0 rc
+end
+end
+
+fn oscir_need k ulong to bool
+if ne get orc 0 0
+ret false
+end
+if gt k sub get irlen 0 get opos 0
+put orc 0 -4
+ret false
+end
+ret true
+end
+
+fn oscir_rle k ulong to ulong
+if not oscir_need k
+ret 0
+end
+p = get opos 0
+v = ulong 0
+for i ulong k
+v = or v shl ulong get irbuf add p i mul i 8
+end
+put opos 0 add p k
+ret v
+end
+
+fn oscir_rcount k ulong mx ulong to ulong
+v = oscir_rle k
+if eq get orc 0 0
+if gt v mx
+oscir_fail -5
+end
+end
+if ne get orc 0 0
+ret 0
+end
+ret v
+end
+
+fn oscir_rvr to int
+v = oscir_rle 2
+if ne get orc 0 0
+ret -1
+end
+if eq v 65535
+ret -1
+end
+if gt v 32767
+oscir_fail -7
+ret -1
+end
+ret int v
+end
+
+fn oscir_rsc to uchar
+v = oscir_rle 1
+if eq get orc 0 0
+if gt v 15
+oscir_fail -7
+end
+end
+if ne get orc 0 0
+ret 0
+end
+ret uchar v
+end
+
+note text into destination dst (0 fname, 1 osnm, 2 osfnm, 3 oreq, 4 oens) at base; returns its length
+fn oscir_rtext lb ulong mx ulong dst ulong base ulong to ulong
+k = oscir_rcount lb mx
+if not oscir_need k
+ret 0
+end
+p = get opos 0
+for i ulong k
+if eq get irbuf add p i 0
+oscir_fail -8
+ret 0
+end
+end
+for i ulong k
+c = get irbuf add p i
+j = add base i
+if eq dst 0
+put fname j c
+end
+if eq dst 1
+put osnm j c
+end
+if eq dst 2
+put osfnm j c
+end
+if eq dst 3
+put oreq j c
+end
+if eq dst 4
+put oens j c
+end
+end
+put opos 0 add p k
+ret k
+end
+
+note one type into the scratch ot (s ref elem sid) / otl (len)
+fn oscir_rtype to void
+put ot 0 0
+put ot 1 0
+put ot 2 0
+put ot 3 0
+put otl 0 0
+s = oscir_rsc
+put ot 0 s
+if ne get orc 0 0
+ret
+end
+if or eq s 14 eq s 15
+put ot 2 oscir_rsc
+ret
+end
+if ne s 10
+ret
+end
+r = oscir_rle 1
+if eq get orc 0 0
+if gt r 4
+oscir_fail -7
+ret
+end
+end
+put ot 1 uchar r
+put ot 2 oscir_rsc
+put otl 0 uint oscir_rle 2
+if eq get orc 0 0
+if eq get ot 2 0
+put ot 3 uchar oscir_rle 1
+end
+end
+end
+
+fn oscir_tovr x ulong to void
+put vts x get ot 0
+put vtref x get ot 1
+put vtel x get ot 2
+put vtlen x get otl 0
+put vtsid x get ot 3
+end
+
+fn oscir_toret f ulong to void
+put frs f get ot 0
+put frref f get ot 1
+put frel f get ot 2
+put frlen f get otl 0
+put frsid f get ot 3
+end
+
+note ---- decode_insn ------------------------------------------------------
+fn oscir_dsub s ulong to void
+put isub s uchar oscir_rle 1
+end
+
+fn oscir_dins s ulong to void
+put idst s -1
+put ia s -1
+put ib s -1
+put ic s -1
+put ibt s -1
+put ibf s -1
+put icall s -1
+put isub s 0
+put inarg s 0
+put iimm s 0
+put iline s 0
+for k ulong 6
+put iarg add mul s 6 k 0
+end
+o = uchar oscir_rle 1
+put iop s o
+if ne get orc 0 0
+ret
+end
+if eq o 1
+put idst s oscir_rvr
+put iimm s oscir_rle 8
+ret
+end
+if or or eq o 2 eq o 6 eq o 7
+put idst s oscir_rvr
+put ia s oscir_rvr
+ret
+end
+if or eq o 3 eq o 5
+oscir_dsub s
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+ret
+end
+if eq o 4
+oscir_dsub s
+put idst s oscir_rvr
+put ia s oscir_rvr
+ret
+end
+if or or eq o 8 eq o 20 eq o 22
+put ia s oscir_rvr
+ret
+end
+if eq o 18
+put idst s oscir_rvr
+put iimm s oscir_rle 1
+ret
+end
+if or or or or eq o 19 eq o 23 eq o 24 eq o 9 eq o 28
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+ret
+end
+if eq o 21
+put idst s oscir_rvr
+oscir_dsub s
+put inarg s uchar oscir_rle 1
+put iimm s oscir_rle 8
+ret
+end
+if or or eq o 25 eq o 10 eq o 29
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+ret
+end
+if eq o 26
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+ret
+end
+if eq o 27
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+put iarg mul s 6 oscir_rvr
+put inarg s 1
+ret
+end
+if eq o 16
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+put iimm s oscir_rle 1
+ret
+end
+if eq o 17
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+put iimm s oscir_rle 1
+ret
+end
+if eq o 11
+put idst s oscir_rvr
+put icall s oscir_rvr
+n = oscir_rcount 1 6
+put inarg s uchar n
+for k ulong n
+if ne get orc 0 0
+break
+end
+put iarg add mul s 6 k oscir_rvr
+end
+ret
+end
+if eq o 12
+put iimm s oscir_rle 1
+ret
+end
+if eq o 13
+put ibt s oscir_rvr
+ret
+end
+if eq o 14
+put ia s oscir_rvr
+put ibt s oscir_rvr
+put ibf s oscir_rvr
+ret
+end
+if eq o 15
+put ia s oscir_rvr
+ret
+end
+if eq o ogpu
+oscir_dsub s
+put idst s oscir_rvr
+ret
+end
+if eq o oshar
+put idst s oscir_rvr
+ret
+end
+if eq o ogld
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+ret
+end
+if eq o ogst
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+ret
+end
+if eq o osync
+ret
+end
+if eq o oshfl
+oscir_dsub s
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+ret
+end
+if eq o omad
+put idst s oscir_rvr
+put ia s oscir_rvr
+put ib s oscir_rvr
+put ic s oscir_rvr
+ret
+end
+oscir_fail -7
+end
+
+note ---- decode_func / decode_unit -----------------------------------------
+fn oscir_dfunc f ulong ver ulong to void
+n = oscir_rtext 1 63 0 mul f 64
+put fnlen f uint n
+if ge ver okver
+k = oscir_rle 1
+put fkind f uchar k
+if eq k 1
+put fthr f uint oscir_rle 2
+end
+end
+put fnpar f uint oscir_rle 1
+oscir_rtype
+oscir_toret f
+nv = oscir_rcount 2 480
+put fnvr f uint nv
+for v ulong nv
+if ne get orc 0 0
+break
+end
+oscir_rtype
+oscir_tovr add mul f 480 v
+end
+nb = oscir_rcount 2 512
+put fnbl f uint nb
+for b ulong nb
+if ne get orc 0 0
+break
+end
+x = add mul f 512 b
+put bfst x uint oscir_rle 4
+put bcnt x uint oscir_rle 4
+end
+ni = oscir_rcount 4 4096
+put fnin f uint ni
+for i ulong ni
+if ne get orc 0 0
+break
+end
+oscir_dins add mul f 4096 i
+end
+n = oscir_rtext 2 255 3 mul f 256
+put oreql f uint n
+n = oscir_rtext 2 255 4 mul f 256
+put oensl f uint n
+end
+
+fn oscir_dstruct k ulong to void
+n = oscir_rtext 1 63 1 mul k 64
+put osnl k uint n
+nf = oscir_rcount 1 16
+put osnf k uint nf
+put osnc k uint oscir_rle 2
+for j ulong nf
+if ne get orc 0 0
+break
+end
+x = add mul k 16 j
+n = oscir_rtext 1 63 2 mul x 64
+put osfnl x uint n
+put osfs x oscir_rsc
+put osfal x uint oscir_rle 2
+put osfof x uint oscir_rle 2
+end
+end
+
+note OSC_IR_ENCODED_MAX, evaluated with the C formula
+fn oscir_encmax to ulong
+fl = ulong 1
+fl = add fl 63
+fl = add fl 1
+fl = add fl 2
+fl = add fl 2
+st = ulong 1
+st = add st 63
+st = add st 1
+st = add st 2
+st = add st mul 16 fl
+fu = ulong 1
+fu = add fu 63
+fu = add fu 1
+fu = add fu 1
+fu = add fu 2
+fu = add fu 6
+fu = add fu 2
+fu = add fu mul ulong 480 6
+fu = add fu 2
+fu = add fu mul ulong 512 8
+fu = add fu 4
+fu = add fu mul ulong 4096 18
+fu = add fu mul ulong 2 add ulong 2 sub ulong 256 1
+t = ulong 8
+t = add t 1
+t = add t mul ulong 16 st
+t = add t 2
+t = add t mul ulong 32 fu
+ret t
+end
+
+fn oscir_magb i ulong to uchar
+if lt i 6
+ret get omagic i
+end
+ret 0
+end
+
+fn oscir_verok v ulong to bool
+if and ge v 1 le v 5
+ret true
+end
+ret eq v okver
+end
+
+fn oscir_dunit to int
+n = get irlen 0
+if gt n oscir_encmax
+ret -5
+end
+put opos 0 0
+put orc 0 0
+if lt n 7
+for i ulong n
+if ne get irbuf i oscir_magb i
+ret -2
+end
+end
+ret -4
+end
+for i ulong 7
+if ne get irbuf i oscir_magb i
+ret -2
+end
+end
+put opos 0 7
+ver = oscir_rle 1
+if ne get orc 0 0
+ret get orc 0
+end
+if not oscir_verok ver
+ret -3
+end
+if ge ver 2
+ns = oscir_rcount 1 16
+put unst 0 uint ns
+for k ulong ns
+if ne get orc 0 0
+break
+end
+oscir_dstruct k
+end
+end
+nf = oscir_rcount 2 32
+put unfn 0 uint nf
+for f ulong nf
+if ne get orc 0 0
+break
+end
+oscir_dfunc f ver
+end
+if ne get orc 0 0
+ret get orc 0
+end
+if ne get opos 0 n
+ret -6
+end
+if eq get onoval 0 0
+v = oscir_validate
+if ne v 0
+ret -9
+end
+end
+if ne oscir_uver ver
+ret -10
+end
+put owp 0 0
+put owd 0 0
+oscir_enc
+if ne get owd 0 0
+ret -11
+end
+if ne get owp 0 n
+ret -11
+end
+ret 0
+end
+
+fn oscir_clrf f ulong to void
+nv = ulong get fnvr f
+for v ulong nv
+x = add mul f 480 v
+put vts x 0
+put vtref x 0
+put vtel x 0
+put vtlen x 0
+put vtsid x 0
+end
+nb = ulong get fnbl f
+for b ulong nb
+x = add mul f 512 b
+put bfst x 0
+put bcnt x 0
+end
+ni = ulong get fnin f
+for i ulong ni
+x = add mul f 4096 i
+put iop x 0
+put isub x 0
+put idst x 0
+put ia x 0
+put ib x 0
+put ic x 0
+put ibt x 0
+put ibf x 0
+put icall x 0
+put inarg x 0
+put iimm x 0
+put iline x 0
+for k ulong 6
+put iarg add mul x 6 k 0
+end
+end
+for j ulong 64
+put fname add mul f 64 j 0
+end
+for j ulong 256
+put oreq add mul f 256 j 0
+put oens add mul f 256 j 0
+end
+put fkind f 0
+put fthr f 0
+put fnpar f 0
+put fnvr f 0
+put fnin f 0
+put fnbl f 0
+put fnlen f 0
+put frs f 0
+put frref f 0
+put frel f 0
+put frlen f 0
+put frsid f 0
+put oreql f 0
+put oensl f 0
+end
+
+fn oscir_clear to void
+for f ulong 32
+oscir_clrf f
+end
+for k ulong 16
+for j ulong 16
+x = add mul k 16 j
+for c ulong 64
+put osfnm add mul x 64 c 0
+end
+put osfnl x 0
+put osfs x 0
+put osfal x 0
+put osfof x 0
+end
+for c ulong 64
+put osnm add mul k 64 c 0
+end
+put osnl k 0
+put osnf k 0
+put osnc k 0
+end
+put unfn 0 0
+put unst 0 0
+put opos 0 0
+put orc 0 0
+end
+
+fn oscir_decode to int
+oscir_clear
+rc = oscir_dunit
+if ne rc 0
+oscir_clear
+end
+ret rc
+end
+
+note ---- canonical encoder used as a comparator against irbuf ---------------
+fn oscir_wb v ulong to void
+p = get owp 0
+if eq get owd 0 0
+if ge p get irlen 0
+put owd 0 1
+else
+if ne ulong get irbuf p and v 255
+put owd 0 1
+end
+end
+end
+put owp 0 add p 1
+end
+
+fn oscir_wn v ulong k ulong to void
+for i ulong k
+oscir_wb shr v mul i 8
+end
+end
+
+fn oscir_wvr x int to void
+y = long x
+if lt y 0
+y = add y 65536
+end
+oscir_wn ulong y 2
+end
+
+fn oscir_wtype s uchar r uchar e uchar l uint d uchar to void
+oscir_wb ulong s
+if or eq s 14 eq s 15
+oscir_wb ulong e
+end
+if eq s 10
+oscir_wb ulong r
+oscir_wb ulong e
+oscir_wn ulong l 2
+if ne d 0
+oscir_wb ulong d
+end
+end
+end
+
+note bytes of source src (0 fname, 1 osnm, 2 osfnm, 3 oreq, 4 oens) at base
+fn oscir_wbytes src ulong base ulong k ulong to void
+for i ulong k
+j = add base i
+c = uchar 0
+if eq src 0
+c = get fname j
+end
+if eq src 1
+c = get osnm j
+end
+if eq src 2
+c = get osfnm j
+end
+if eq src 3
+c = get oreq j
+end
+if eq src 4
+c = get oens j
+end
+oscir_wb ulong c
+end
+end
+
+fn oscir_eins s ulong to void
+o = get iop s
+oscir_wb ulong o
+if eq o 1
+oscir_wvr get idst s
+oscir_wn get iimm s 8
+ret
+end
+if or or eq o 2 eq o 6 eq o 7
+oscir_wvr get idst s
+oscir_wvr get ia s
+ret
+end
+if or eq o 3 eq o 5
+oscir_wb ulong get isub s
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+ret
+end
+if eq o 4
+oscir_wb ulong get isub s
+oscir_wvr get idst s
+oscir_wvr get ia s
+ret
+end
+if or or eq o 8 eq o 20 eq o 22
+oscir_wvr get ia s
+ret
+end
+if eq o 18
+oscir_wvr get idst s
+oscir_wb get iimm s
+ret
+end
+if or or or or eq o 19 eq o 23 eq o 24 eq o 9 eq o 28
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+ret
+end
+if eq o 21
+oscir_wvr get idst s
+oscir_wb ulong get isub s
+oscir_wb ulong get inarg s
+oscir_wn get iimm s 8
+ret
+end
+if or or eq o 25 eq o 10 eq o 29
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+ret
+end
+if eq o 26
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+ret
+end
+if eq o 27
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+oscir_wvr get iarg mul s 6
+ret
+end
+if eq o 16
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wb get iimm s
+ret
+end
+if eq o 17
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+oscir_wb get iimm s
+ret
+end
+if eq o 11
+oscir_wvr get idst s
+oscir_wvr get icall s
+n = ulong get inarg s
+oscir_wb n
+for k ulong n
+oscir_wvr get iarg add mul s 6 k
+end
+ret
+end
+if eq o 12
+oscir_wb get iimm s
+ret
+end
+if eq o 13
+oscir_wvr get ibt s
+ret
+end
+if eq o 14
+oscir_wvr get ia s
+oscir_wvr get ibt s
+oscir_wvr get ibf s
+ret
+end
+if eq o 15
+oscir_wvr get ia s
+ret
+end
+if eq o ogpu
+oscir_wb ulong get isub s
+oscir_wvr get idst s
+ret
+end
+if eq o oshar
+oscir_wvr get idst s
+ret
+end
+if eq o ogld
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+ret
+end
+if eq o ogst
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+ret
+end
+if eq o oshfl
+oscir_wb ulong get isub s
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+ret
+end
+if eq o omad
+oscir_wvr get idst s
+oscir_wvr get ia s
+oscir_wvr get ib s
+oscir_wvr get ic s
+ret
+end
+end
+
+fn oscir_wtx x ulong to void
+oscir_wtype get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_efunc f ulong ver ulong to void
+oscir_wb ulong get fnlen f
+oscir_wbytes 0 mul f 64 ulong get fnlen f
+if ge ver okver
+oscir_wb ulong get fkind f
+if eq get fkind f 1
+oscir_wn ulong get fthr f 2
+end
+end
+oscir_wb ulong get fnpar f
+oscir_wtype get frs f get frref f get frel f get frlen f get frsid f
+nv = ulong get fnvr f
+oscir_wn nv 2
+for v ulong nv
+x = add mul f 480 v
+oscir_wtx x
+end
+nb = ulong get fnbl f
+oscir_wn nb 2
+for b ulong nb
+x = add mul f 512 b
+oscir_wn ulong get bfst x 4
+oscir_wn ulong get bcnt x 4
+end
+ni = ulong get fnin f
+oscir_wn ni 4
+for i ulong ni
+oscir_eins add mul f 4096 i
+end
+oscir_wn ulong get oreql f 2
+oscir_wbytes 3 mul f 256 ulong get oreql f
+oscir_wn ulong get oensl f 2
+oscir_wbytes 4 mul f 256 ulong get oensl f
+end
+
+fn oscir_enc to void
+ver = oscir_uver
+for i ulong 7
+oscir_wb ulong oscir_magb i
+end
+oscir_wb ver
+if ge ver 2
+ns = ulong get unst 0
+oscir_wb ns
+for k ulong ns
+oscir_wb ulong get osnl k
+oscir_wbytes 1 mul k 64 ulong get osnl k
+nf = ulong get osnf k
+oscir_wb nf
+oscir_wn ulong get osnc k 2
+for j ulong nf
+x = add mul k 16 j
+oscir_wb ulong get osfnl x
+oscir_wbytes 2 mul x 64 ulong get osfnl x
+oscir_wb ulong get osfs x
+oscir_wn ulong get osfal x 2
+oscir_wn ulong get osfof x 2
+end
+end
+end
+nf = ulong get unfn 0
+oscir_wn nf 2
+for f ulong nf
+oscir_efunc f ver
+end
+end
+
+note ---- unit_version --------------------------------------------------------
+fn oscir_uver to ulong
+nf = ulong get unfn 0
+for f ulong nf
+if ne get fkind f 0
+ret okver
+end
+end
+for f ulong nf
+nv = ulong get fnvr f
+for v ulong nv
+if oscir_xsl add mul f 480 v
+ret 5
+end
+end
+end
+for f ulong nf
+ni = ulong get fnin f
+for i ulong ni
+o = get iop add mul f 4096 i
+if and ge o 21 le o 27
+ret 4
+end
+end
+end
+for f ulong nf
+ni = ulong get fnin f
+for i ulong ni
+o = get iop add mul f 4096 i
+if and ge o 18 le o 20
+ret 3
+end
+end
+end
+if ne get unst 0 0
+ret 2
+end
+ret 1
+end
+
+note ---- type predicates (osc_ir.c) ------------------------------------------
+fn oscir_isval s uchar to bool
+ret and ge s 1 le s 9
+end
+
+fn oscir_isint s uchar to bool
+ret and ge s 2 le s 9
+end
+
+fn oscir_gel e uchar to bool
+ret or eq e 4 eq e 13
+end
+
+fn oscir_tsc s uchar r uchar e uchar l uint d uchar to bool
+if not or oscir_isval s eq s 13
+ret false
+end
+ret and and and eq r 0 eq e 0 eq l 0 eq d 0
+end
+
+fn oscir_tref s uchar r uchar e uchar l uint d uchar to bool
+if ne s 10
+ret false
+end
+if or lt r 1 gt r 3
+ret false
+end
+if eq d 0
+ret and oscir_isval e and ge l 1 le l 64
+end
+if gt uint d get unst 0
+ret false
+end
+if ne e 0
+ret false
+end
+ret eq l get osnc sub ulong d 1
+end
+
+fn oscir_tsl s uchar r uchar e uchar l uint d uchar to bool
+if not or eq s 11 eq s 12
+ret false
+end
+ret and and and eq r 0 eq e 0 eq l 0 eq d 0
+end
+
+fn oscir_tgb s uchar r uchar e uchar l uint d uchar to bool
+if not or eq s 14 eq s 15
+ret false
+end
+ret and and and eq r 0 oscir_gel e eq l 0 eq d 0
+end
+
+fn oscir_tbl s uchar r uchar e uchar l uint d uchar to bool
+if ne s 10
+ret false
+end
+if ne r 4
+ret false
+end
+ret and and and oscir_gel e ge l 1 le l 12288 eq d 0
+end
+
+fn oscir_xsc x ulong to bool
+ret oscir_tsc get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_xref x ulong to bool
+ret oscir_tref get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_xsl x ulong to bool
+ret oscir_tsl get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_xgb x ulong to bool
+ret oscir_tgb get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_xbl x ulong to bool
+ret oscir_tbl get vts x get vtref x get vtel x get vtlen x get vtsid x
+end
+
+fn oscir_xis x ulong s uchar to bool
+if not oscir_xsc x
+ret false
+end
+ret eq get vts x s
+end
+
+note array ref: a ref with sid 0
+fn oscir_xarr x ulong to bool
+if not oscir_xref x
+ret false
+end
+ret eq get vtsid x 0
+end
+
+note struct ref: a ref with sid != 0
+fn oscir_xstr x ulong to bool
+if not oscir_xref x
+ret false
+end
+ret ne get vtsid x 0
+end
+
+fn oscir_xeq a ulong b ulong to bool
+if ne get vts a get vts b
+ret false
+end
+if ne get vtref a get vtref b
+ret false
+end
+if ne get vtel a get vtel b
+ret false
+end
+if ne get vtlen a get vtlen b
+ret false
+end
+ret eq get vtsid a get vtsid b
+end
+
+note type_eq of vreg slot a and the return type of function g
+fn oscir_xeqr a ulong g ulong to bool
+if ne get vts a get frs g
+ret false
+end
+if ne get vtref a get frref g
+ret false
+end
+if ne get vtel a get frel g
+ret false
+end
+if ne get vtlen a get frlen g
+ret false
+end
+ret eq get vtsid a get frsid g
+end
+
+fn oscir_xbind d ulong s ulong to bool
+if not and oscir_xref d oscir_xref s
+ret false
+end
+if ne get vtel d get vtel s
+ret false
+end
+if ne get vtlen d get vtlen s
+ret false
+end
+if ne get vtsid d get vtsid s
+ret false
+end
+rd = get vtref d
+rs = get vtref s
+if eq rd 1
+ret eq rs 1
+end
+if eq rd 3
+ret or eq rs 1 eq rs 3
+end
+ret eq rd 2
+end
+
+fn oscir_width s uchar to ulong
+if or eq s 2 eq s 6
+ret 8
+end
+if or eq s 3 eq s 7
+ret 16
+end
+if eq s 1
+ret 1
+end
+if or eq s 4 eq s 8
+ret 32
+end
+if or eq s 5 eq s 9
+ret 64
+end
+ret 0
+end
+
+fn oscir_canon s uchar v ulong to bool
+if eq s 1
+ret le v 1
+end
+if eq s 13
+ret le v 4294967295
+end
+w = oscir_width s
+if eq w 64
+ret true
+end
+if and ge s 6 le s 9
+hi = sub shl ulong 1 sub w 1 1
+lo = sub ulong 0 shl ulong 1 sub w 1
+ret or le v hi ge v lo
+end
+ret lt v shl ulong 1 w
+end
+
+fn oscir_vr x int nv uint to bool
+if lt x 0
+ret false
+end
+ret lt uint x nv
+end
+
+fn oscir_sname s uchar to long
+if le s 15
+ret long s
+end
+ret 16
+end
+
+note ---- message formatting (vsnprintf into a 256-byte buffer) --------------
+fn oscir_putc c uchar to void
+n = get oerrn 0
+if lt n 255
+put oerr n c
+put oerrn 0 add n 1
+end
+end
+
+fn oscir_putd v long to void
+dg = new uchar 24 0
+x = v
+if lt x 0
+oscir_putc 45
+end
+u = ulong 0
+if lt x 0
+u = ulong sub 0 add x 1
+u = add u 1
+else
+u = ulong x
+end
+n = ulong 0
+while true bound 30
+put dg n uchar add 48 rem u 10
+n = add n 1
+u = div u 10
+if eq u 0
+break
+end
+end
+while gt n 0 bound 30
+n = sub n 1
+oscir_putc get dg n
+end
+end
+
+fn oscir_puts id ulong to void
+k = ulong 0
+for i ulong len ostr
+c = get ostr i
+if eq c 10
+if eq k id
+ret
+end
+k = add k 1
+else
+if eq k id
+oscir_putc c
+end
+end
+end
+end
+
+fn oscir_narg to long
+i = get omai 0
+put omai 0 add i 1
+ret get oma i
+end
+
+fn oscir_fmt id ulong to void
+k = ulong 0
+p = ulong 0
+for i ulong len omt
+if eq k id
+p = i
+break
+end
+if eq get omt i 10
+k = add k 1
+end
+end
+i = p
+while lt i len omt bound 999
+c = get omt i
+if eq c 10
+break
+end
+if eq c 64
+if eq i p
+oscir_fmt 0
+i = add i 1
+continue
+end
+end
+if eq c 37
+d = get omt add i 1
+if eq d 115
+oscir_puts ulong oscir_narg
+i = add i 2
+continue
+end
+if eq d 108
+oscir_putd oscir_narg
+i = add i 4
+continue
+end
+oscir_putd oscir_narg
+i = add i 2
+continue
+end
+oscir_putc c
+i = add i 1
+end
+end
+
+fn oscir_vf id ulong a long b long c long d long to int
+put oma 0 a
+put oma 1 b
+put oma 2 c
+put oma 3 d
+put omai 0 0
+put oerrn 0 0
+oscir_fmt id
+ret -1
+end
+
+note ---- insn_uses / insn_def ----------------------------------------------------
+fn oscir_inc16 a int to int
+if eq a 32767
+ret -32768
+end
+ret add a 1
+end
+
+fn oscir_in4 o uchar a uchar b uchar c uchar d uchar to bool
+p = or eq o a eq o b
+q = or eq o c eq o d
+ret or p q
+end
+
+fn oscir_uses s ulong to ulong
+o = get iop s
+a = get ia s
+b = get ib s
+c = get ic s
+put ous 0 a
+put ous 1 b
+put ous 2 c
+p = oscir_in4 o 2 4 6 7
+p = or p oscir_in4 o 8 14 20 22
+if p
+ret 1
+end
+p = oscir_in4 o 19 23 24 3
+p = or p oscir_in4 o 5 9 oshfl oshfl
+if p
+ret 2
+end
+if oscir_in4 o 25 26 10 omad
+ret 3
+end
+if eq o 27
+put ous 3 get iarg mul s 6
+ret 4
+end
+if or eq o 28 eq o ogld
+put ous 1 oscir_inc16 a
+put ous 2 b
+ret 3
+end
+if or eq o 29 eq o ogst
+put ous 1 oscir_inc16 a
+put ous 2 b
+put ous 3 c
+ret 4
+end
+if eq o 16
+if ge b 0
+ret 2
+end
+ret 1
+end
+if eq o 17
+if ge b 0
+put ous 2 c
+ret 3
+end
+put ous 1 c
+ret 2
+end
+if eq o 11
+n = ulong get inarg s
+for k ulong n
+put ous k get iarg add mul s 6 k
+end
+ret n
+end
+if eq o 15
+if ge a 0
+ret 1
+end
+ret 0
+end
+ret 0
+end
+
+fn oscir_def s ulong to int
+o = get iop s
+if and ge o 1 le o 7
+ret get idst s
+end
+p = oscir_in4 o 9 16 28 18
+p = or p oscir_in4 o 19 21 23 24
+if p
+ret get idst s
+end
+p = oscir_in4 o 26 ogpu oshar ogld
+p = or p oscir_in4 o oshfl omad 11 11
+if p
+ret get idst s
+end
+ret -1
+end
+
+fn oscir_isterm o uchar to bool
+ret or or eq o 13 eq o 14 eq o 15
+end
+
+note ---- validate_insn ---------------------------------------------------------
+fn oscir_vi id ulong f ulong i ulong to int
+ret oscir_vf id long f long i 0 0
+end
+
+fn oscir_vi1 id ulong f ulong i ulong x long to int
+ret oscir_vf id long f long i x 0
+end
+
+note operand slots: ox[0..3] = vreg slot of dst a b c; returned mask bit k set when that operand is VR
+fn oscir_ld f ulong i ulong to ulong
+s = add mul f 4096 i
+nv = get fnvr f
+bs = mul f 480
+m = ulong 0
+v = get idst s
+if oscir_vr v nv
+put ox 0 add bs ulong v
+m = or m 1
+end
+v = get ia s
+if oscir_vr v nv
+put ox 1 add bs ulong v
+m = or m 2
+end
+v = get ib s
+if oscir_vr v nv
+put ox 2 add bs ulong v
+m = or m 4
+end
+v = get ic s
+if oscir_vr v nv
+put ox 3 add bs ulong v
+m = or m 8
+end
+ret m
+end
+
+note all operands in mask k are VR
+fn oscir_vm m ulong k ulong to bool
+ret eq and m k k
+end
+
+note slot k is a scalar of an integer type
+fn oscir_xint k ulong to bool
+x = get ox k
+ret and oscir_xsc x oscir_isint get vts x
+end
+
+note CONST MOV
+fn oscir_vins1 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+if eq o 1
+if not oscir_vm m 1
+ret oscir_vi1 1 f i long get idst s
+end
+x = get ox 0
+if not oscir_xsc x
+ret oscir_vi 2 f i
+end
+if not oscir_canon get vts x get iimm s
+ret oscir_vi1 3 f i oscir_sname get vts x
+end
+ret 0
+end
+if not oscir_vm m 3
+ret oscir_vi 4 f i
+end
+x = get ox 0
+y = get ox 1
+if oscir_xref x
+if not oscir_xbind x y
+ret oscir_vi 5 f i
+end
+ret 0
+end
+if not and oscir_xsc x oscir_xeq x y
+ret oscir_vi 6 f i
+end
+ret 0
+end
+
+note BIN
+fn oscir_vbin f ulong i ulong to int
+s = add mul f 4096 i
+m = oscir_ld f i
+if not oscir_vm m 7
+ret oscir_vi 7 f i
+end
+u = get isub s
+if or lt u 1 gt u 12
+ret oscir_vi1 8 f i long u
+end
+xa = get ox 1
+xb = get ox 2
+if not and oscir_xsc get ox 0 oscir_xeq get ox 0 xa
+ret oscir_vi 9 f i
+end
+t = get vts xa
+if eq t 13
+if not oscir_xeq xa xb
+ret oscir_vi 10 f i
+end
+p = oscir_in4 u 1 2 3 11
+p = or p eq u 12
+if not p
+ret oscir_vi1 11 f i long u
+end
+ret 0
+end
+if or eq u 11 eq u 12
+if not and eq t 4 oscir_xeq xa xb
+ret oscir_vi 12 f i
+end
+ret 0
+end
+if or eq u 9 eq u 10
+if not oscir_isint t
+ret oscir_vi 13 f i
+end
+if not oscir_xint 2
+ret oscir_vi 14 f i
+end
+ret 0
+end
+if or or eq u 6 eq u 7 eq u 8
+if not oscir_xeq xa xb
+ret oscir_vi 10 f i
+end
+ret 0
+end
+if not and oscir_isint t oscir_xeq xa xb
+ret oscir_vi 15 f i
+end
+ret 0
+end
+
+note UN
+fn oscir_vun f ulong i ulong to int
+s = add mul f 4096 i
+m = oscir_ld f i
+if not oscir_vm m 3
+ret oscir_vi 16 f i
+end
+xa = get ox 1
+if not and oscir_xsc get ox 0 oscir_xeq get ox 0 xa
+ret oscir_vi 17 f i
+end
+t = get vts xa
+u = get isub s
+if eq u 3
+if ne t 1
+ret oscir_vi 18 f i
+end
+ret 0
+end
+if eq u 1
+if not or oscir_isint t eq t 13
+ret oscir_vi 19 f i
+end
+ret 0
+end
+if eq u 2
+if not oscir_isint t
+ret oscir_vi 20 f i
+end
+ret 0
+end
+if and ge u 4 le u 7
+if ne t 13
+ret oscir_vi 21 f i
+end
+ret 0
+end
+ret oscir_vi1 22 f i long u
+end
+
+note CMP CAST
+fn oscir_vins2 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+if eq o 5
+if not oscir_vm m 7
+ret oscir_vi 23 f i
+end
+u = get isub s
+if or lt u 1 gt u 6
+ret oscir_vi1 24 f i long u
+end
+if not oscir_xis get ox 0 1
+ret oscir_vi 25 f i
+end
+xa = get ox 1
+if not and oscir_xsc xa oscir_xeq xa get ox 2
+ret oscir_vi 26 f i
+end
+ret 0
+end
+if not oscir_vm m 3
+ret oscir_vi 27 f i
+end
+xd = get ox 0
+xa = get ox 1
+if or eq get vts xd 13 eq get vts xa 13
+p = and oscir_xis xd 13 oscir_xis xa 4
+q = and oscir_xis xd 4 oscir_xis xa 13
+if not or p q
+ret oscir_vi 28 f i
+end
+ret 0
+end
+if not and oscir_xint 0 oscir_xint 1
+ret oscir_vi 29 f i
+end
+ret 0
+end
+
+note ALLOC AALLOC
+fn oscir_valloc f ulong i ulong to int
+m = oscir_ld f i
+e = ulong 30
+if eq get iop add mul f 4096 i 19
+e = 39
+m = or m 64
+end
+if eq and m 64 0
+if not oscir_vm m 3
+ret oscir_vi e f i
+end
+else
+if not oscir_vm m 7
+ret oscir_vi e f i
+end
+end
+xd = get ox 0
+xa = get ox 1
+if not and oscir_xref xd eq get vtref xd 1
+ret oscir_vi add e 1 f i
+end
+if ne get vtsid xd 0
+if not oscir_xis xa 5
+ret oscir_vi add e 2 f i
+end
+else
+if not oscir_xse xa xd
+ret oscir_vi add e 3 f i
+end
+end
+if eq e 39
+if not oscir_xis get ox 2 5
+ret oscir_vi 43 f i
+end
+end
+ret 0
+end
+
+note slot x is a scalar whose type is the element type of slot y
+fn oscir_xse x ulong y ulong to bool
+if not oscir_xsc x
+ret false
+end
+ret eq get vts x get vtel y
+end
+
+note RELEASE AOPEN ADESTROY POPEN PCLOSE
+fn oscir_vins3 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+if eq o 8
+if not oscir_vm m 2
+ret oscir_vi 34 f i
+end
+xa = get ox 1
+if not and oscir_xref xa eq get vtref xa 1
+ret oscir_vi 35 f i
+end
+ret 0
+end
+if eq o 18
+if not oscir_vm m 1
+ret oscir_vi 36 f i
+end
+if not oscir_xis get ox 0 5
+ret oscir_vi 37 f i
+end
+n = get iimm s
+if or lt n 1 gt n 64
+ret oscir_vi 38 f i
+end
+ret 0
+end
+if or eq o 20 eq o 22
+e = ulong 44
+if eq o 22
+e = 48
+end
+if not oscir_vm m 2
+ret oscir_vi e f i
+end
+if not oscir_xis get ox 1 5
+ret oscir_vi e f i
+end
+ret 0
+end
+if not oscir_vm m 1
+ret oscir_vi 45 f i
+end
+if not oscir_xis get ox 0 5
+ret oscir_vi 45 f i
+end
+n = get inarg s
+if or lt n 1 gt n 16
+ret oscir_vi 46 f i
+end
+if not oscir_isval get isub s
+ret oscir_vi 47 f i
+end
+ret 0
+end
+
+note HALLOC HGEN HFREE HLOAD HSTORE
+fn oscir_vins4 f ulong i ulong to int
+s = add mul f 4096 i
+nv = get fnvr f
+bs = mul f 480
+o = get iop s
+k = oscir_uses s
+for j ulong k
+u = get ous j
+if not oscir_vr u nv
+ret oscir_vi 49 f i
+end
+if not oscir_xsc add bs ulong u
+ret oscir_vi 49 f i
+end
+end
+d = oscir_def s
+if oscir_in4 o 23 24 26 26
+if not oscir_vr d nv
+ret oscir_vi 50 f i
+end
+if not oscir_xsc add bs ulong d
+ret oscir_vi 50 f i
+end
+end
+if or eq o 23 eq o 24
+if ne get vts add bs ulong d 5
+ret oscir_vi 51 f i
+end
+end
+if eq o 27
+if ne get inarg s 1
+ret oscir_vi 52 f i
+end
+end
+if eq o 23
+ret 0
+end
+if ne get vts add bs ulong get ib s 5
+ret oscir_vi 53 f i
+end
+if ne o 24
+if ne get vts add bs ulong get ic s 5
+ret oscir_vi 54 f i
+end
+end
+ret 0
+end
+
+note LOAD STORE
+fn oscir_vldst f ulong i ulong to int
+o = get iop add mul f 4096 i
+m = oscir_ld f i
+e = ulong 55
+v = ulong 0
+if eq o 10
+e = 59
+v = 3
+end
+if eq o 9
+if not oscir_vm m 7
+ret oscir_vi e f i
+end
+else
+if not oscir_vm m 14
+ret oscir_vi e f i
+end
+end
+xa = get ox 1
+if not oscir_ldbase o xa
+ret oscir_vi add e 1 f i
+end
+if not oscir_xint 2
+ret oscir_vi add e 2 f i
+end
+if not oscir_xse get ox v xa
+ret oscir_vi add e 3 f i
+end
+ret 0
+end
+
+note LOAD base: array ref or block; STORE base: own/mut array ref or block
+fn oscir_ldbase o uchar xa ulong to bool
+if oscir_xbl xa
+ret true
+end
+if not oscir_xarr xa
+ret false
+end
+if eq o 9
+ret true
+end
+r = get vtref xa
+ret or eq r 1 eq r 3
+end
+
+note SLOAD SSTORE
+fn oscir_vsl f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+nm = long 17
+v = ulong 0
+if eq o 29
+nm = 18
+v = 3
+end
+if not oscir_vm m 6
+ret oscir_vi1 63 f i nm
+end
+xa = get ox 1
+p = false
+if oscir_xsl xa
+if oscir_vr add get ia s 1 get fnvr f
+p = oscir_xis add xa 1 5
+end
+end
+if not p
+ret oscir_vi1 64 f i nm
+end
+if not oscir_xint 2
+ret oscir_vi1 65 f i nm
+end
+if not oscir_vm m shl ulong 1 v
+ret oscir_vi1 66 f i nm
+end
+if not oscir_xis get ox v 5
+ret oscir_vi1 66 f i nm
+end
+if eq o 29
+if ne get vts xa 12
+ret oscir_vi 67 f i
+end
+end
+ret 0
+end
+
+note FLOAD FSTORE
+fn oscir_vins6 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+nm = long 19
+v = ulong 0
+if eq o 17
+nm = 20
+v = 3
+end
+if not oscir_vm m 2
+ret oscir_vi1 68 f i nm
+end
+xa = get ox 1
+if not oscir_xstr xa
+ret oscir_vi1 68 f i nm
+end
+st = sub ulong get vtsid xa 1
+n = get iimm s
+if ge n ulong get osnf st
+ret oscir_vf 69 long f long i nm long n
+end
+ret oscir_vfs2 f i m add mul st 16 n
+end
+
+note FLOAD FSTORE after the field index check; fd = field slot
+fn oscir_vfs2 f ulong i ulong m ulong fd ulong to int
+s = add mul f 4096 i
+if ne get osfal fd 0
+p = false
+if oscir_vm m 4
+p = oscir_xint 2
+end
+if not p
+ret oscir_vi 70 f i
+end
+else
+if ne get ib s -1
+ret oscir_vi 71 f i
+end
+end
+v = ulong 0
+if eq get iop s 17
+v = 3
+end
+if not oscir_vm m shl ulong 1 v
+ret oscir_vi 72 f i
+end
+xv = get ox v
+if not oscir_xsc xv
+ret oscir_vi 72 f i
+end
+if ne get vts xv get osfs fd
+ret oscir_vi 72 f i
+end
+if eq v 3
+r = get vtref get ox 1
+if not or eq r 1 eq r 3
+ret oscir_vi 73 f i
+end
+end
+ret 0
+end
+
+note one CALL argument k: 0 ok, else the message id
+fn oscir_varg f ulong s ulong gi ulong k ulong n ulong to ulong
+a = get iarg add mul s 6 k
+if not oscir_vr a get fnvr f
+ret 76
+end
+xa = add mul f 480 ulong a
+p = add mul gi 480 k
+if oscir_xsl p
+q = false
+if oscir_xeq p xa
+if lt add k 1 n
+w = get iarg add mul s 6 add k 1
+q = eq w add a 1
+end
+end
+if not q
+ret 77
+end
+ret 0
+end
+if oscir_xref p
+if not oscir_xbind p xa
+ret 78
+end
+ret 0
+end
+if not oscir_xeq p xa
+ret 79
+end
+ret 0
+end
+
+note CALL
+fn oscir_vins7 f ulong i ulong to int
+s = add mul f 4096 i
+g = get icall s
+if not and ge g 0 lt long g long f
+ret oscir_vi1 74 f i long g
+end
+gi = ulong g
+n = ulong get inarg s
+if ne n ulong get fnpar gi
+ret oscir_vf 75 long f long i long n long get fnpar gi
+end
+for k ulong n
+e = oscir_varg f s gi k n
+if eq e 76
+ret oscir_vi 76 f i
+end
+if ne e 0
+ret oscir_vi1 e f i long k
+end
+end
+d = get idst s
+if eq get frs gi 0
+if ne d -1
+ret oscir_vi 80 f i
+end
+ret 0
+end
+if not oscir_vr d get fnvr f
+ret oscir_vi 81 f i
+end
+if not oscir_xeqr add mul f 480 ulong d gi
+ret oscir_vi 81 f i
+end
+ret 0
+end
+
+note GPU SHARED
+fn oscir_vins8 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+if eq o ogpu
+p = false
+if oscir_vm m 1
+p = oscir_xis get ox 0 4
+end
+if not p
+ret oscir_vi 82 f i
+end
+u = get isub s
+if or lt u 1 gt u 5
+ret oscir_vi1 83 f i long u
+end
+ret 0
+end
+p = false
+if oscir_vm m 1
+p = oscir_xbl get ox 0
+end
+if not p
+ret oscir_vi 84 f i
+end
+ret 0
+end
+
+note GLOAD GSTORE
+fn oscir_vgl f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+nm = long 21
+v = ulong 0
+if eq o ogst
+nm = 22
+v = 3
+end
+if not oscir_vm m 6
+ret oscir_vi1 63 f i nm
+end
+xa = get ox 1
+p = false
+if oscir_xgb xa
+if oscir_vr add get ia s 1 get fnvr f
+p = oscir_xis add xa 1 4
+end
+end
+if not p
+ret oscir_vi1 85 f i nm
+end
+if not oscir_xis get ox 2 4
+ret oscir_vi1 86 f i nm
+end
+p = false
+if oscir_vm m shl ulong 1 v
+p = oscir_xis get ox v get vtel xa
+end
+if not p
+ret oscir_vi1 87 f i nm
+end
+if eq o ogst
+if ne get vts xa 15
+ret oscir_vi 88 f i
+end
+end
+ret 0
+end
+
+note SHFL MAD
+fn oscir_vins9 f ulong i ulong to int
+s = add mul f 4096 i
+o = get iop s
+m = oscir_ld f i
+if eq o oshfl
+u = get isub s
+if ne u 1
+ret oscir_vi1 89 f i long u
+end
+if not oscir_vm m 7
+ret oscir_vi 90 f i
+end
+xa = get ox 1
+p = or oscir_xis xa 4 oscir_xis xa 13
+if not and p oscir_xeq get ox 0 xa
+ret oscir_vi 91 f i
+end
+if not oscir_xis get ox 2 4
+ret oscir_vi 92 f i
+end
+ret 0
+end
+if not oscir_vm m 15
+ret oscir_vi 93 f i
+end
+p = and oscir_xis get ox 0 13 oscir_xis get ox 1 13
+q = and oscir_xis get ox 2 13 oscir_xis get ox 3 13
+if not and p q
+ret oscir_vi 94 f i
+end
+ret 0
+end
+
+note TRAP BR CBR RET
+fn oscir_vctl f ulong i ulong to int
+s = add mul f 4096 i
+nb = int get fnbl f
+o = get iop s
+m = oscir_ld f i
+if eq o 12
+n = get iimm s
+if or lt n 1 gt n 14
+ret oscir_vi 95 f i
+end
+ret 0
+end
+t = get ibt s
+if eq o 13
+if not and ge t 0 lt t nb
+ret oscir_vi 96 f i
+end
+ret 0
+end
+if eq o 14
+p = false
+if oscir_vm m 2
+p = oscir_xis get ox 1 1
+end
+if not p
+ret oscir_vi 97 f i
+end
+e = get ibf s
+p = and ge t 0 lt t nb
+q = and ge e 0 lt e nb
+if not and p q
+ret oscir_vi 98 f i
+end
+ret 0
+end
+if eq get frs f 0
+if ne get ia s -1
+ret oscir_vi 99 f i
+end
+ret 0
+end
+if not oscir_vm m 2
+ret oscir_vi 100 f i
+end
+if not oscir_xeqr get ox 1 f
+ret oscir_vi 100 f i
+end
+ret 0
+end
+
+fn oscir_vins f ulong i ulong to int
+o = get iop add mul f 4096 i
+if or eq o 1 eq o 2
+ret oscir_vins1 f i
+end
+if eq o 3
+ret oscir_vbin f i
+end
+if eq o 4
+ret oscir_vun f i
+end
+if or eq o 5 eq o 6
+ret oscir_vins2 f i
+end
+if or eq o 7 eq o 19
+ret oscir_valloc f i
+end
+if oscir_in4 o 8 18 20 21
+ret oscir_vins3 f i
+end
+if eq o 22
+ret oscir_vins3 f i
+end
+if and ge o 23 le o 27
+ret oscir_vins4 f i
+end
+if or eq o 9 eq o 10
+ret oscir_vldst f i
+end
+if or eq o 28 eq o 29
+ret oscir_vsl f i
+end
+if or eq o 16 eq o 17
+ret oscir_vins6 f i
+end
+if eq o 11
+ret oscir_vins7 f i
+end
+if eq o osync
+ret 0
+end
+if or eq o ogpu eq o oshar
+ret oscir_vins8 f i
+end
+if or eq o ogld eq o ogst
+ret oscir_vgl f i
+end
+if or eq o oshfl eq o omad
+ret oscir_vins9 f i
+end
+if and ge o 12 le o 15
+ret oscir_vctl f i
+end
+ret oscir_vi1 101 f i long o
+end
+
+note ---- validate_func -----------------------------------------------------------
+note header: kind, threads, params, vregs, return type, vreg types, contract
+fn oscir_vfh f ulong to int
+fl = long f
+k = get fkind f
+if gt k 1
+ret oscir_vf 104 fl long k 0 0
+end
+kern = eq k 1
+t = get fthr f
+bad = ne t 0
+if kern
+bad = or or lt t 32 gt t 1024 ne rem t 32 0
+end
+if bad
+ret oscir_vf 105 fl long t 0 0
+end
+mp = uint 6
+if kern
+mp = 32
+end
+np = get fnpar f
+if gt np mp
+ret oscir_vf 106 fl long np long mp 0
+end
+nv = ulong get fnvr f
+if or gt nv 480 gt ulong np nv
+ret oscir_vf 107 fl 0 0 0
+end
+if not oscir_vfret f
+ret oscir_vf 108 fl 0 0 0
+end
+ret oscir_vfh2 f
+end
+
+note return type: void (all zero) or a valid type
+fn oscir_vfret f ulong to bool
+p = and eq get frs f 0 eq get frref f 0
+q = and eq get frel f 0 eq get frlen f 0
+if and and p q eq get frsid f 0
+ret true
+end
+s = get frs f
+r = get frref f
+e = get frel f
+n = get frlen f
+d = get frsid f
+ret oscir_tsc s r e n d
+end
+
+note vreg types against the kernel/host kind, return and contract rules
+fn oscir_vfh2 f ulong to int
+fl = long f
+kern = eq get fkind f 1
+nv = ulong get fnvr f
+bs = mul f 480
+for v ulong nv
+x = add bs v
+ok = or or oscir_xsc x oscir_xref x oscir_xsl x
+ok = or ok or oscir_xgb x oscir_xbl x
+if not ok
+ret oscir_vf 109 fl long v 0 0
+end
+end
+for v ulong nv
+x = add bs v
+kt = or or oscir_xgb x oscir_xbl x oscir_xis x 13
+if kern
+if not or or kt oscir_xis x 1 oscir_xis x 4
+ret oscir_vf 110 fl long v oscir_sname get vts x 0
+end
+end
+if not kern
+if kt
+ret oscir_vf 111 fl long v 0 0
+end
+end
+end
+if not kern
+if eq get frs f 13
+ret oscir_vf 112 fl 0 0 0
+end
+end
+if kern
+if or or ne get frs f 0 ne get oreql f 0 ne get oensl f 0
+ret oscir_vf 113 fl 0 0 0
+end
+end
+ret 0
+end
+
+note parameter pairs, counts
+fn oscir_vfp f ulong to int
+fl = long f
+nv = ulong get fnvr f
+np = ulong get fnpar f
+bs = mul f 480
+for v ulong nv
+put osl v 0
+end
+v = ulong 0
+while lt v nv bound 999
+x = add bs v
+if oscir_xsl x
+p = lt add v 1 np
+if p
+p = oscir_xis add x 1 5
+end
+if not p
+ret oscir_vf 114 fl long v 0 0
+end
+put osl v 1
+put osl add v 1 1
+v = add v 1
+end
+v = add v 1
+end
+v = 0
+while lt v nv bound 999
+x = add bs v
+if oscir_xgb x
+p = lt add v 1 np
+if p
+p = oscir_xis add x 1 4
+end
+if not p
+ret oscir_vf 115 fl long v 0 0
+end
+put osl v 1
+put osl add v 1 1
+v = add v 1
+end
+v = add v 1
+end
+for w ulong np
+if oscir_xbl add bs w
+ret oscir_vf 116 fl long w 0 0
+end
+end
+ni = get fnin f
+if or lt ni 1 gt ni 4096
+ret oscir_vf 117 fl 0 0 0
+end
+nb = get fnbl f
+if or lt nb 1 gt nb 512
+ret oscir_vf 118 fl 0 0 0
+end
+ret 0
+end
+
+note blocks partition the instruction array
+fn oscir_vfb f ulong to int
+fl = long f
+ni = ulong get fnin f
+nb = ulong get fnbl f
+for i ulong ni
+put ocov i 0
+end
+for b ulong nb
+fs = ulong get bfst add mul f 512 b
+ct = ulong get bcnt add mul f 512 b
+if or lt ct 1 gt add fs ct ni
+ret oscir_vf 119 fl long b 0 0
+end
+r = oscir_vfb1 f b fs ct
+if ne r 0
+ret r
+end
+end
+for i ulong ni
+if eq get ocov i 0
+ret oscir_vf 123 fl long i 0 0
+end
+end
+ret 0
+end
+
+note one block: coverage and terminator placement
+fn oscir_vfb1 f ulong b ulong fs ulong ct ulong to int
+for j ulong ct
+i = add fs j
+if ne get ocov i 0
+ret oscir_vf 120 long f long i 0 0
+end
+put ocov i 1
+la = eq j sub ct 1
+tm = oscir_isterm get iop add mul f 4096 i
+if ne tm la
+if la
+ret oscir_vf 121 long f long b 0 0
+end
+ret oscir_vf 122 long f long b 0 0
+end
+end
+ret 0
+end
+
+note last insn of f defining vreg b, or -1
+fn oscir_lastdef f ulong b int to long
+ni = ulong get fnin f
+r = long -1
+for j ulong ni
+if eq oscir_def add mul f 4096 j b
+r = long j
+end
+end
+ret r
+end
+
+note one kernel divisor / shuffle distance: 1 when it is a single CONST in lo..hi
+fn oscir_kconst f ulong b int lo ulong hi ulong to bool
+if lt long b long get fnpar f
+ret false
+end
+if ne get ondef add 0 ulong b 1
+ret false
+end
+j = oscir_lastdef f b
+if lt j 0
+ret false
+end
+s = add mul f 4096 ulong j
+if ne get iop s 1
+ret false
+end
+m = get iimm s
+ret and ge m lo le m hi
+end
+
+note which instructions each function kind may hold
+fn oscir_vfk f ulong to int
+fl = long f
+nv = ulong get fnvr f
+ni = ulong get fnin f
+nb = ulong get fnbl f
+kern = eq get fkind f 1
+for v ulong nv
+put ondef v 0
+end
+for i ulong ni
+d = oscir_def add mul f 4096 i
+if ge d 0
+if lt ulong d nv
+put ondef ulong d add get ondef ulong d 1
+end
+end
+end
+put osb 0 0
+for b ulong nb
+fs = ulong get bfst add mul f 512 b
+ct = ulong get bcnt add mul f 512 b
+for j ulong ct
+r = oscir_vfk1 f b add fs j kern
+if ne r 0
+ret r
+end
+end
+end
+ret 0
+end
+
+note one instruction i of block b; shared bytes accumulate in osb
+fn oscir_vfk1 f ulong b ulong i ulong kern bool to int
+fl = long f
+s = add mul f 4096 i
+o = get iop s
+u = get isub s
+go = and ge o ogpu le o omad
+gs = and eq o 3 or eq u 11 eq u 12
+gs = or gs and eq o 4 ge u 4
+if not kern
+if or go gs
+ret oscir_vf 125 fl long i 0 0
+end
+if eq o 11
+if ne get fkind ulong get icall s 0
+ret oscir_vf 126 fl long i 0 0
+end
+end
+ret 0
+end
+ret oscir_vfk2 f b i o u
+end
+
+note shared-memory declaration of a kernel: block 0, single definition, byte budget
+fn oscir_vfsh f ulong b ulong i ulong to int
+fl = long f
+if ne b 0
+ret oscir_vf 128 fl long i 0 0
+end
+d = ulong get idst add mul f 4096 i
+if ne get ondef d 1
+ret oscir_vf 129 fl long i 0 0
+end
+ln = ulong get vtlen add mul f 480 d
+sb = add get osb 0 mul ln 4
+put osb 0 sb
+if gt sb 49152
+ret oscir_vf 130 fl long i 49152 0
+end
+ret 0
+end
+
+note kernel instruction rules
+fn oscir_vfk2 f ulong b ulong i ulong o uchar u uchar to int
+fl = long f
+s = add mul f 4096 i
+p = or or eq o 7 eq o 8 eq o 11
+if or p and ge o 16 le o 29
+ret oscir_vf 127 fl long i long o 0
+end
+if eq o oshar
+r = oscir_vfsh f b i
+if ne r 0
+ret r
+end
+end
+if eq o 3
+if or eq u 4 eq u 5
+if not oscir_kconst f get ib s 1 18446744073709551615
+ret oscir_vf 131 fl long i 0 0
+end
+end
+end
+if eq o oshfl
+if not oscir_kconst f get ib s 1 31
+ret oscir_vf 132 fl long i 0 0
+end
+end
+ret 0
+end
+
+note OSC-2 arena handles
+fn oscir_vfa f ulong to int
+fl = long f
+nv = ulong get fnvr f
+ni = ulong get fnin f
+np = long get fnpar f
+for v ulong nv
+put ohk v 0
+end
+for i ulong ni
+s = add mul f 4096 i
+if eq get iop s 18
+d = get idst s
+if or ne get ohk ulong d 0 lt long d np
+ret oscir_vf 133 fl long i 0 0
+end
+put ohk ulong d 1
+end
+end
+for i ulong ni
+r = oscir_vfa1 f i
+if ne r 0
+ret r
+end
+end
+ret 0
+end
+
+note arena-handle use rules for instruction i
+fn oscir_vfa1 f ulong i ulong to int
+fl = long f
+s = add mul f 4096 i
+o = get iop s
+d = oscir_def s
+if ne o 18
+if ge d 0
+if ne get ohk ulong d 0
+ret oscir_vf 134 fl long i 0 0
+end
+end
+end
+if eq o 19
+hb = get ohk ulong get ib s
+ha = get ohk ulong get ia s
+if or eq hb 0 ne ha 0
+ret oscir_vf 135 fl long i 0 0
+end
+ret 0
+end
+if eq o 20
+if eq get ohk ulong get ia s 0
+ret oscir_vf 136 fl long i 0 0
+end
+ret 0
+end
+k = oscir_uses s
+for j ulong k
+if ne get ohk ulong get ous j 0
+ret oscir_vf 137 fl long i 0 0
+end
+end
+ret 0
+end
+
+note OSC-3 pools
+fn oscir_vfo f ulong to int
+fl = long f
+nv = ulong get fnvr f
+ni = ulong get fnin f
+np = long get fnpar f
+for v ulong nv
+put opk v 0
+end
+for i ulong ni
+s = add mul f 4096 i
+if eq get iop s 21
+d = ulong get idst s
+p = or ne get opk d 0 ne get ohk d 0
+if or p lt long d np
+ret oscir_vf 138 fl long i 0 0
+end
+put opk d get isub s
+end
+end
+for i ulong ni
+r = oscir_vfo1 f i
+if ne r 0
+ret r
+end
+end
+ret 0
+end
+
+note pool-handle use rules for instruction i
+fn oscir_vfo1 f ulong i ulong to int
+fl = long f
+s = add mul f 4096 i
+o = get iop s
+d = oscir_def s
+if ne o 21
+if ge d 0
+if ne get opk ulong d 0
+ret oscir_vf 139 fl long i 0 0
+end
+end
+end
+if eq o 22
+if eq get opk ulong get ia s 0
+ret oscir_vf 140 fl long i 0 0
+end
+ret 0
+end
+if eq o 23
+a = ulong get ia s
+b = ulong get ib s
+if or eq get opk b 0 ne get opk a 0
+ret oscir_vf 141 fl long i 0 0
+end
+if ne get vts add mul f 480 a get opk b
+ret oscir_vf 142 fl long i 0 0
+end
+ret 0
+end
+if and ge o 24 le o 27
+ret oscir_vfo2 f i o
+end
+k = oscir_uses s
+for j ulong k
+if ne get opk ulong get ous j 0
+ret oscir_vf 146 fl long i 0 0
+end
+end
+ret 0
+end
+
+note HGEN HFREE HLOAD HSTORE pool rules
+fn oscir_vfo2 f ulong i ulong o uchar to int
+fl = long f
+s = add mul f 4096 i
+bs = mul f 480
+a = ulong get ia s
+b = ulong get ib s
+p = or eq get opk a 0 ne get opk b 0
+if ne o 24
+p = or p ne get opk ulong get ic s 0
+end
+if p
+ret oscir_vf 143 fl long i 0 0
+end
+if eq o 26
+g = add bs ulong get idst s
+if ne get vts g get opk a
+ret oscir_vf 144 fl long i 0 0
+end
+end
+if eq o 27
+g = ulong get iarg mul s 6
+if ne get opk g 0
+ret oscir_vf 145 fl long i 0 0
+end
+if ne get vts add bs g get opk a
+ret oscir_vf 145 fl long i 0 0
+end
+end
+ret 0
+end
+
+note definite assignment (8 words of 64 bits per block)
+fn oscir_dbit d int to void
+if ge d 0
+w = div ulong d 64
+put ocur w or get ocur w shl ulong 1 rem ulong d 64
+end
+end
+
+fn oscir_ispred f ulong p ulong b ulong to bool
+x = add mul f 512 p
+s = add mul f 4096 sub add ulong get bfst x ulong get bcnt x 1
+o = get iop s
+bl = long b
+if eq o 13
+ret eq long get ibt s bl
+end
+if eq o 14
+ret or eq long get ibt s bl eq long get ibf s bl
+end
+ret false
+end
+
+note one dataflow pass over every block; returns 1 when anything changed
+fn oscir_dpass f ulong to bool
+nb = ulong get fnbl f
+ch = false
+for b ulong nb
+c = oscir_dblk f b
+ch = or ch c
+end
+ret ch
+end
+
+note block b of the dataflow pass: meet, then transfer; true when in/out changed
+fn oscir_dblk f ulong b ulong to bool
+nb = ulong get fnbl f
+for k ulong 8
+put ocur k 18446744073709551615
+end
+if eq b 0
+for k ulong 8
+put ocur k 0
+end
+np = ulong get fnpar f
+for v ulong np
+oscir_dbit int v
+end
+end
+for p ulong nb
+if oscir_ispred f p b
+for k ulong 8
+y = add mul p 8 k
+put ocur k and get ocur k get obout y
+end
+end
+end
+ch = false
+for k ulong 8
+y = add mul b 8 k
+if ne get ocur k get obin y
+ch = true
+end
+end
+if ch
+for k ulong 8
+put obin add mul b 8 k get ocur k
+end
+end
+fs = ulong get bfst add mul f 512 b
+ct = ulong get bcnt add mul f 512 b
+for j ulong ct
+oscir_dbit oscir_def add mul f 4096 add fs j
+end
+c2 = false
+for k ulong 8
+y = add mul b 8 k
+if ne get ocur k get obout y
+c2 = true
+end
+end
+if c2
+for k ulong 8
+put obout add mul b 8 k get ocur k
+end
+end
+ret or ch c2
+end
+
+fn oscir_vfd f ulong to int
+fl = long f
+nb = ulong get fnbl f
+for y ulong mul nb 8
+put obin y 18446744073709551615
+put obout y 18446744073709551615
+end
+while oscir_dpass f bound 999999
+end
+for b ulong nb
+r = oscir_vfd1 f b
+if ne r 0
+ret r
+end
+end
+ret 0
+end
+
+note uses of block b read only definitely-assigned vregs
+fn oscir_vfd1 f ulong b ulong to int
+for k ulong 8
+put ocur k get obin add mul b 8 k
+end
+fs = ulong get bfst add mul f 512 b
+ct = ulong get bcnt add mul f 512 b
+for j ulong ct
+r = oscir_vfu f add fs j
+if ne r 0
+ret r
+end
+end
+ret 0
+end
+
+note instruction i reads only vregs set in ocur; then its def is set
+fn oscir_vfu f ulong i ulong to int
+s = add mul f 4096 i
+n = oscir_uses s
+for q ulong n
+u = ulong get ous q
+w = get ocur div u 64
+if eq and shr w rem u 64 1 0
+ret oscir_vf 147 long f long i long u 0
+end
+end
+oscir_dbit oscir_def s
+ret 0
+end
+
+fn oscir_vfunc f ulong to int
+r = oscir_vfh f
+if ne r 0
+ret r
+end
+r = oscir_vfp f
+if ne r 0
+ret r
+end
+r = oscir_vfb f
+if ne r 0
+ret r
+end
+ni = ulong get fnin f
+for i ulong ni
+r = oscir_vins f i
+if ne r 0
+ret r
+end
+end
+nv = get fnvr f
+for i ulong ni
+d = oscir_def add mul f 4096 i
+if ge d 0
+if lt uint d nv
+if ne get osl ulong d 0
+ret oscir_vf 124 long f long i 0 0
+end
+end
+end
+end
+r = oscir_vfk f
+if ne r 0
+ret r
+end
+r = oscir_vfa f
+if ne r 0
+ret r
+end
+r = oscir_vfo f
+if ne r 0
+ret r
+end
+ret oscir_vfd f
+end
+
+note ---- validate_structs / osc_ir_validate ---------------------------------------
+fn oscir_sneq a ulong b ulong to bool
+n = get osnl a
+if ne n get osnl b
+ret false
+end
+for c ulong ulong n
+if ne get osnm add mul a 64 c get osnm add mul b 64 c
+ret false
+end
+end
+ret true
+end
+
+fn oscir_fneq a ulong b ulong to bool
+n = get osfnl a
+if ne n get osfnl b
+ret false
+end
+pa = mul a 64
+pb = mul b 64
+for c ulong ulong n
+ca = get osfnm add pa c
+if ne ca get osfnm add pb c
+ret false
+end
+end
+ret true
+end
+
+fn oscir_vst to int
+ns = ulong get unst 0
+if gt ns 16
+ret oscir_vf 149 0 0 0 0
+end
+for k ulong ns
+kl = long k
+if eq get osnl k 0
+ret oscir_vf 150 kl 0 0 0
+end
+for j ulong k
+if oscir_sneq j k
+ret oscir_vf 151 kl 0 0 0
+end
+end
+nf = ulong get osnf k
+if or lt nf 1 gt nf 16
+ret oscir_vf 152 kl 0 0 0
+end
+off = uint 0
+for g ulong nf
+x = add mul k 16 g
+if eq get osfnl x 0
+ret oscir_vf 153 kl long g 0 0
+end
+for h ulong g
+if oscir_fneq add mul k 16 h x
+ret oscir_vf 154 kl long g 0 0
+end
+end
+if or not oscir_isval get osfs x gt get osfal x 64
+ret oscir_vf 155 kl long g 0 0
+end
+if ne get osfof x off
+ret oscir_vf 156 kl long g long get osfof x long off
+end
+al = get osfal x
+if eq al 0
+al = 1
+end
+off = add off al
+end
+if or or ne off get osnc k lt off 1 gt off 64
+ret oscir_vf 157 kl 0 0 0
+end
+end
+ret 0
+end
+
+fn oscir_validate to int
+put oerrn 0 0
+if gt get unfn 0 32
+ret oscir_vf 159 0 0 0 0
+end
+r = oscir_vst
+if ne r 0
+ret r
+end
+nf = ulong get unfn 0
+for f ulong nf
+r = oscir_vfunc f
+if ne r 0
+ret r
+end
+end
+put oerrn 0 0
+ret 0
+end
diff --git a/seed/oscgpu/oscirdump.om b/seed/oscgpu/oscirdump.om
new file mode 100644
index 000000000..c95c70c21
--- /dev/null
+++ b/seed/oscgpu/oscirdump.om
@@ -0,0 +1,290 @@
+note oscirdump.om -- canonical text dump of a decoded OSC IR unit (driver for oscir.om).
+note Build: cat seed/oscgpu/oscir.om seed/oscgpu/oscirdump.om | seed/out/omc > oscirdump
+note Usage: oscirdump <ir-file>. Paired with the test oracle tests/osc_gpu/oscir_dump.c.
+global odb uchar 65536
+global odn ulong 1
+text odhx "0123456789abcdef"
+text odtag "STRUCT\nFIELD\n name=\nFUNC\n req=\n ens=\nVREG\nBLOCK\nINSN\nUNIT nfn=\n nst=\nDECODE rc=\nNVDECODE rc=\nVALIDATE rc=\nREADFAIL\n"
+
+fn oscird_flush to void
+n = get odn 0
+if gt n 0
+w = write 1 odb 0 n
+end
+put odn 0 0
+end
+
+fn oscird_c c uchar to void
+n = get odn 0
+put odb n c
+put odn 0 add n 1
+if ge add n 1 65000
+oscird_flush
+end
+end
+
+fn oscird_s t ulong to void
+if eq t 0
+oscird_c 32
+end
+if eq t 1
+oscird_c 10
+end
+end
+
+fn oscird_u v ulong to void
+d = new uchar 24 0
+n = ulong 0
+x = v
+while true bound 30
+put d n add uchar rem x 10 48
+n = add n 1
+x = div x 10
+if eq x 0
+break
+end
+end
+for k ulong n
+oscird_c get d sub sub n k 1
+end
+end
+
+fn oscird_i v long to void
+if lt v 0
+oscird_c 45
+m = ulong sub 0 add v 1
+oscird_u add m 1
+else
+oscird_u ulong v
+end
+end
+
+note tag id = line of odtag
+fn oscird_t id ulong to void
+k = ulong 0
+j = ulong 0
+while lt j id bound 4096
+if eq get odtag k 10
+j = add j 1
+end
+k = add k 1
+end
+while ne get odtag k 10 bound 64
+oscird_c get odtag k
+k = add k 1
+end
+end
+
+fn oscird_hb c uchar to void
+oscird_c get odhx ulong shr c 4
+oscird_c get odhx ulong and c 15
+end
+
+note hex of a name: src 0 fname 1 osnm 2 osfnm 3 oreq 4 oens
+fn oscird_hex src ulong base ulong n ulong to void
+for k ulong n
+x = add base k
+if eq src 0
+oscird_hb get fname x
+end
+if eq src 1
+oscird_hb get osnm x
+end
+if eq src 2
+oscird_hb get osfnm x
+end
+if eq src 3
+oscird_hb get oreq x
+end
+if eq src 4
+oscird_hb get oens x
+end
+end
+end
+
+fn oscird_si v long to void
+oscird_s 0
+oscird_i v
+end
+
+fn oscird_struct k ulong to void
+oscird_t 0
+oscird_s 0
+oscird_u k
+oscird_t 2
+oscird_hex 1 mul k 64 ulong get osnl k
+oscird_s 0
+oscird_u ulong get osnf k
+oscird_s 0
+oscird_u ulong get osnc k
+oscird_s 1
+nf = ulong get osnf k
+for g ulong nf
+x = add mul k 16 g
+oscird_t 1
+oscird_s 0
+oscird_u k
+oscird_s 0
+oscird_u g
+oscird_t 2
+oscird_hex 2 mul x 64 ulong get osfnl x
+oscird_s 0
+oscird_u ulong get osfs x
+oscird_s 0
+oscird_u ulong get osfal x
+oscird_s 0
+oscird_u ulong get osfof x
+oscird_s 1
+end
+end
+
+fn oscird_func f ulong to void
+oscird_t 3
+oscird_s 0
+oscird_u f
+oscird_s 0
+oscird_u ulong get fkind f
+oscird_s 0
+oscird_u ulong get fthr f
+oscird_s 0
+oscird_u ulong get fnpar f
+oscird_s 0
+oscird_u ulong get fnvr f
+oscird_s 0
+oscird_u ulong get fnin f
+oscird_s 0
+oscird_u ulong get fnbl f
+oscird_t 2
+oscird_hex 0 mul f 64 ulong get fnlen f
+oscird_s 0
+oscird_u ulong get frs f
+oscird_s 0
+oscird_u ulong get frref f
+oscird_s 0
+oscird_u ulong get frel f
+oscird_s 0
+oscird_u ulong get frlen f
+oscird_s 0
+oscird_u ulong get frsid f
+oscird_t 4
+oscird_hex 3 mul f 256 ulong get oreql f
+oscird_t 5
+oscird_hex 4 mul f 256 ulong get oensl f
+oscird_s 1
+nv = ulong get fnvr f
+for v ulong nv
+x = add mul f 480 v
+oscird_t 6
+oscird_s 0
+oscird_u f
+oscird_s 0
+oscird_u v
+oscird_s 0
+oscird_u ulong get vts x
+oscird_s 0
+oscird_u ulong get vtref x
+oscird_s 0
+oscird_u ulong get vtel x
+oscird_s 0
+oscird_u ulong get vtlen x
+oscird_s 0
+oscird_u ulong get vtsid x
+oscird_s 1
+end
+nb = ulong get fnbl f
+for b ulong nb
+x = add mul f 512 b
+oscird_t 7
+oscird_s 0
+oscird_u f
+oscird_s 0
+oscird_u b
+oscird_s 0
+oscird_u ulong get bfst x
+oscird_s 0
+oscird_u ulong get bcnt x
+oscird_s 1
+end
+end
+
+fn oscird_insn f ulong i ulong to void
+s = add mul f 4096 i
+oscird_t 8
+oscird_s 0
+oscird_u f
+oscird_s 0
+oscird_u i
+oscird_s 0
+oscird_u ulong get iop s
+oscird_s 0
+oscird_u ulong get isub s
+oscird_si long get idst s
+oscird_si long get ia s
+oscird_si long get ib s
+oscird_si long get ic s
+oscird_si long get ibt s
+oscird_si long get ibf s
+oscird_si long get icall s
+oscird_s 0
+oscird_u ulong get inarg s
+for k ulong 6
+oscird_si long get iarg add mul s 6 k
+end
+oscird_s 0
+oscird_u get iimm s
+oscird_s 0
+oscird_u ulong get iline s
+oscird_s 1
+end
+
+fn oscird_unit to void
+oscird_t 9
+oscird_u ulong get unfn 0
+oscird_t 10
+oscird_u ulong get unst 0
+oscird_s 1
+ns = ulong get unst 0
+for k ulong ns
+oscird_struct k
+end
+nf = ulong get unfn 0
+for f ulong nf
+oscird_func f
+ni = ulong get fnin f
+for i ulong ni
+oscird_insn f i
+end
+end
+end
+
+fn main to int
+r = oscir_read_file 1
+if ne r 0
+oscird_t 14
+oscird_s 1
+oscird_flush
+ret 2
+end
+put onoval 0 0
+rc = oscir_decode
+oscird_t 11
+oscird_i long rc
+oscird_s 1
+oscird_unit
+put onoval 0 1
+rc = oscir_decode
+oscird_t 12
+oscird_i long rc
+oscird_s 1
+rc = oscir_validate
+oscird_t 13
+oscird_i long rc
+oscird_s 0
+n = get oerrn 0
+for k ulong n
+oscird_c get oerr k
+end
+oscird_s 1
+oscird_flush
+ret 0
+end
diff --git a/spec/.crumb b/spec/.crumb
index 1d517838f..c08ac48bd 100644
--- a/spec/.crumb
+++ b/spec/.crumb
@@ -20,14 +20,14 @@
         }
       ],
       "children_root": "sha256:6834a3241647d3a098283d4eafedbdb1428dfa4d834f9ed5f22025b6d2303093",
-      "compiled_at": "2026-11-06T13:05:53Z",
+      "compiled_at": "2026-11-06T13:12:06Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:d5b7b83e378358c3c2a3b4d9d2ce548eecbe6363e12f66bdef8e63d5e18ae6f0",
+      "digest": "sha256:1d7a2adda2531165ab7dee8a7c344797b0ffbecf3a72fc1b77f2a340e46b86b9",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 87,
-      "generated_at_commit": "022d3f85c2de8ce7fdc16ef3df224988550a61d7",
-      "source_tree": "sha256:445c6c59fb0678883e8a18583babaeabb1fd9b551b219a8a3717227313c15ac9"
+      "generated_at_commit": "bb552199e8970bbdcb42c79acc8a36f9c1189e23",
+      "source_tree": "sha256:17e084a2094eae5705ad4b18a86b5b0a58eb07b864797f465d707b12052dfb33"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/spec/one-layer-format.md b/spec/one-layer-format.md
index 096894ee8..9063d7c30 100644
--- a/spec/one-layer-format.md
+++ b/spec/one-layer-format.md
@@ -239,8 +239,15 @@ milestone name “IR v2 memory” does not change the meaning of wire version 2,
 which already carries structs. Wire versions 1..5 and their identity bytes
 remain unchanged. Wire version 6 remains reserved by draft PR #525 for its
 numeric-identifier/structured-contract proposal; this profile neither closes
-nor supersedes that proposal. The memory extension uses version 7. A backend
-that has not implemented this profile must refuse it, not ignore its regions.
+nor supersedes that proposal. The memory extension uses version 7. GPU
+kernel units (docs/omegese/GPU.md section 9, draft PR #885) use version 8,
+with kernel opcodes 40..46 (GPU, SHARED, GLOAD, GSTORE, SYNC, SHFL, MAD),
+disjoint from this profile's opcodes 30..33; in a version 8 unit opcodes
+30..39 are RANGE. Version 8 keeps the version 7 meaning of tag 13 (f32) but
+gives tag 14 to the GVIEW buffer pointer (f64 in version 7) and tag 15 to
+GEDIT, so a reader must still select tag meanings by the version byte.
+Until #885 merges, version 8 is not settled on main. A backend that has not
+implemented this profile must refuse it, not ignore its regions.
 
 ### 10.1 Header and regions
 
diff --git a/src/.crumb b/src/.crumb
index 10a2e4229..9fbc6047d 100644
--- a/src/.crumb
+++ b/src/.crumb
@@ -79,8 +79,8 @@
           "purpose": "M21 OMEGA_AUTODIFF: reverse-mode tape over M20 tensor CPU ops, caller-owned nodes and scratch, p"
         },
         {
-          "digest": "806198eda65f998c287abd251928120d01ab44a1e0f1e05ad2e055212967c80c",
-          "last_commit": "f5c9bd89",
+          "digest": "305629b4a139d0ba04365a4f876fe1715760bf2da8e05712914dfe3f76c7d86e",
+          "last_commit": "1cdee5c2",
           "name": "compiler",
           "purpose": "Directory src/compiler. Purpose not yet described by a human."
         },
@@ -187,15 +187,15 @@
           "purpose": "Directory src/visor. Purpose not yet described by a human."
         }
       ],
-      "children_root": "sha256:aac4c9a66e9199868af34b6e38c22ee3600bd83b65beff787ecfe61cc89ee3e8",
-      "compiled_at": "2026-11-06T13:17:25Z",
+      "children_root": "sha256:d0d9f03df216b9afbcc3ad1d9742953d1d58ef2a2d8ebc583cb5bf8446f7310b",
+      "compiled_at": "2026-11-06T13:24:19Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:2fae6036e44241fc1dcf0b4861f5eeba18bbc8c5ddf90ce8167040235d2a2f54",
+      "digest": "sha256:389a6e17ea437fc7ff5ece40717562ddffa5459fb23ec3cdce511538138d6514",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
-      "files": 608,
-      "generated_at_commit": "98a700a2ec882239599ea0cf453692521ac77893",
-      "source_tree": "sha256:37553eb748feaaa2f79b37e9cee64294ae51602b8060f2ed58eb206fd9cb6059"
+      "files": 613,
+      "generated_at_commit": "e5d43fd34fa4696b08ec2082066f96a0c8de96d8",
+      "source_tree": "sha256:a537a83e5108181431a47380a739d094e68261791fe79a9b352782d8f3d798db"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/checker2/c2_check.c b/src/checker2/c2_check.c
index 42e0b5964..4d911939a 100644
--- a/src/checker2/c2_check.c
+++ b/src/checker2/c2_check.c
@@ -19,7 +19,11 @@
  * Written from docs/osc/OSC-{1,2,3}-DESIGN.md, OSC-EXT-BYTES-DESIGN.md and the osc_ir.h comments
  * only. Rules, in the order applied:
  *   unit tables  -> per-function types -> CFG shape -> per-instruction typing -> calls ->
- *   handle disciplines -> definite assignment -> loop bounds (termination) -> ownership flow.
+ *   GPU kernel rules -> handle disciplines -> definite assignment -> loop bounds (termination) ->
+ *   ownership flow.
+ * GPU kernels (version 8) are restated from docs/omegese/GPU.md sections 6-9: their types, the ops
+ * each function kind may hold, block-shared arrays, constant divisors, and the uniformity rule for
+ * SYNC and SHFL.
  * The ownership flow is a may-analysis that rejects only DEFINITE errors (a state that holds on
  * every path), so it cannot reject a correct program through imprecision; drop-flag guarded
  * releases (OSC-3 item 3) are therefore never refused by it. */
@@ -50,18 +54,22 @@ static int fail(C2Verdict *v, const char *rule, int func, int insn, const char *
 static int is_value(uint8_t s) { return s >= S_BOOL && s <= S_I64; }
 static int is_int(uint8_t s) { return s >= S_U8 && s <= S_I64; }
 static int is_signed(uint8_t s) { return s >= S_I8 && s <= S_I64; }
+static int is_num(uint8_t s) { return is_value(s) || s == S_F32; } /* a register value: bool, integer or f32 */
+static int is_kvalue(uint8_t s) { return s == S_U32 || s == S_F32; } /* GPU buffer and shared elements */
 static unsigned width(uint8_t s)
 {
     switch (s) {
     case S_BOOL: return 1;
     case S_U8: case S_I8: return 8;
     case S_U16: case S_I16: return 16;
-    case S_U32: case S_I32: return 32;
+    case S_U32: case S_I32: case S_F32: return 32;
     case S_U64: case S_I64: return 64;
     default: return 0;
     }
 }
-static int is_scalar_t(const C2Type *t) { return is_value(t->s); }
+static int is_scalar_t(const C2Type *t) { return is_num(t->s); }
+static int is_gbuf(const C2Type *t) { return t->s == S_GVIEW || t->s == S_GEDIT; }
+static int is_block(const C2Type *t) { return t->s == S_REF && t->kind == K_BLOCK; }
 static int is_ref(const C2Type *t) { return t->s == S_REF; }
 static int is_array_ref(const C2Type *t) { return t->s == S_REF && t->sid == 0; }
 static int is_struct_ref(const C2Type *t) { return t->s == S_REF && t->sid != 0; }
@@ -70,6 +78,7 @@ static int is_u64(const C2Type *t) { return t->s == S_U64; }
 static int same_type(const C2Type *a, const C2Type *b)
 {
     if (a->s != b->s) return 0;
+    if (is_gbuf(a)) return a->elem == b->elem;
     if (a->s != S_REF) return 1;
     return a->kind == b->kind && a->elem == b->elem && a->len == b->len && a->sid == b->sid;
 }
@@ -82,6 +91,7 @@ static int same_shape(const C2Type *a, const C2Type *b)
  * downgrade): own->own|shared|mut, mut->mut|shared, shared->shared. */
 static int bindable(uint8_t to, uint8_t from)
 {
+    if (to == K_BLOCK || from == K_BLOCK) return 0; /* a shared array is never moved or borrowed */
     if (from == K_OWN) return 1;
     if (from == K_MUT) return to == K_MUT || to == K_SHARED;
     if (from == K_SHARED) return to == K_SHARED;
@@ -130,7 +140,9 @@ static int check_structs(const C2Unit *u, C2Verdict *v)
 static int check_type(const C2Unit *u, const C2Type *t)
 {
     if (t->s >= S_LIMIT || t->s == S_VOID) return 0;
+    if (is_gbuf(t)) return is_kvalue(t->elem);
     if (t->s != S_REF) return 1;
+    if (t->kind == K_BLOCK) return is_kvalue(t->elem) && t->sid == 0 && t->len >= 1 && t->len <= C2_MAX_SHARED_LEN;
     if (t->kind < K_OWN || t->kind > K_MUT) return 0;
     if (t->elem == S_VOID) { /* struct reference */
         if (t->sid < 1 || t->sid > u->nstructs) return 0;
@@ -183,6 +195,11 @@ static int uses(const C2Insn *in, int16_t *o)
     case C2_FLOAD: o[n++] = in->a; if (in->b >= 0) o[n++] = in->b; break;
     case C2_FSTORE: o[n++] = in->a; if (in->b >= 0) o[n++] = in->b; o[n++] = in->c; break;
     case C2_CALL: for (int k = 0; k < in->nargs; k++) o[n++] = in->args[k]; break;
+    /* a buffer access also reads the buffer's length register (the next one) */
+    case C2_GLOAD: o[n++] = in->a; o[n++] = (int16_t)(in->a + 1); o[n++] = in->b; break;
+    case C2_GSTORE: o[n++] = in->a; o[n++] = (int16_t)(in->a + 1); o[n++] = in->b; o[n++] = in->c; break;
+    case C2_SHFL: o[n++] = in->a; o[n++] = in->b; break;
+    case C2_MAD: o[n++] = in->a; o[n++] = in->b; o[n++] = in->c; break;
     default: break;
     }
     return n;
@@ -193,7 +210,7 @@ static int defines(const C2Insn *in)
     switch (in->op) {
     case C2_CONST: case C2_MOV: case C2_BIN: case C2_UN: case C2_CMP: case C2_CAST: case C2_ALLOC: case C2_LOAD:
     case C2_FLOAD: case C2_AOPEN: case C2_AALLOC: case C2_POPEN: case C2_HALLOC: case C2_HGEN: case C2_HLOAD:
-    case C2_SLOAD:
+    case C2_SLOAD: case C2_GPU: case C2_SHARED: case C2_GLOAD: case C2_SHFL: case C2_MAD:
         return in->dst;
     case C2_CALL: return in->dst; /* -1 for a void call */
     default: return -1;
@@ -219,13 +236,17 @@ static int check_insn(Fx *x, uint32_t ii)
     if (in->op != C2_CALL && (in->op == C2_CONST || in->op == C2_MOV || in->op == C2_BIN || in->op == C2_UN ||
                               in->op == C2_CMP || in->op == C2_CAST || in->op == C2_ALLOC || in->op == C2_LOAD ||
                               in->op == C2_FLOAD || in->op == C2_AOPEN || in->op == C2_AALLOC || in->op == C2_POPEN ||
-                              in->op == C2_HALLOC || in->op == C2_HGEN || in->op == C2_HLOAD || in->op == C2_SLOAD) &&
+                              in->op == C2_HALLOC || in->op == C2_HGEN || in->op == C2_HLOAD || in->op == C2_SLOAD ||
+                              in->op == C2_GPU || in->op == C2_SHARED || in->op == C2_GLOAD || in->op == C2_SHFL ||
+                              in->op == C2_MAD) &&
         in->dst < 0)
         F("C2-OPERAND-RANGE", "missing destination");
     if (need_dst && (d < 0 || d >= nv)) F("C2-OPERAND-RANGE", "destination v%d out of range", d); /* GUARD:dst-range */
     if (d >= 0 && is_slice(T(x, d))) F("C2-SLICE-WRITE", "slice register v%d redefined", d);
     if (d >= 0 && d < f->nparams && d > 0 && is_slice(T(x, d - 1)))
         F("C2-SLICE-WRITE", "slice length register v%d redefined", d);
+    if (d >= 0 && is_gbuf(T(x, d))) F("C2-GPU-BUFFER", "buffer register v%d redefined", d); /* GUARD:gbuf-write */
+    if (d > 0 && d < f->nparams && is_gbuf(T(x, d - 1))) F("C2-GPU-BUFFER", "buffer length register v%d redefined", d); /* GUARD:gbuf-len-write */
 
     const C2Type *td = d >= 0 ? T(x, d) : NULL;
     const C2Type *ta = in->a >= 0 && in->a < nv ? T(x, in->a) : NULL;
@@ -247,7 +268,13 @@ static int check_insn(Fx *x, uint32_t ii)
         break;
     case C2_BIN:
         if (in->sub < B_ADD || in->sub >= B_LIMIT) F("C2-DECODE-SUBOP", "binary op %u", in->sub);
-        if (in->sub == B_SHL || in->sub == B_SHR) {
+        if (in->sub == B_MIN || in->sub == B_MAX) {
+            if (!is_kvalue(td->s) || !same_type(td, ta) || !same_type(td, tb)) F("C2-TYPE-BIN", "min/max need u32 or f32"); /* GUARD:bin-minmax */
+        } else if (td->s == S_F32 || ta->s == S_F32) {
+            /* f32: add, sub, mul only (GPU.md section 4: no float div/rem, no bit ops on floats) */
+            if (!(in->sub == B_ADD || in->sub == B_SUB || in->sub == B_MUL)) F("C2-TYPE-BIN", "f32 binary op %u", in->sub); /* GUARD:bin-f32-op */
+            if (!same_type(td, ta) || !same_type(td, tb)) F("C2-TYPE-BIN", "f32 operand types"); /* GUARD:bin-f32-type */
+        } else if (in->sub == B_SHL || in->sub == B_SHR) {
             if (!is_int(td->s) || !same_type(td, ta) || !is_int(tb->s)) F("C2-TYPE-BIN", "shift operand types"); /* GUARD:bin-shift */
         } else if (in->sub == B_AND || in->sub == B_OR || in->sub == B_XOR) {
             if (!is_scalar_t(td) || !same_type(td, ta) || !same_type(td, tb)) F("C2-TYPE-BIN", "bitwise operand types");
@@ -258,13 +285,22 @@ static int check_insn(Fx *x, uint32_t ii)
     case C2_UN:
         if (in->sub < U_NEG || in->sub >= U_LIMIT) F("C2-DECODE-SUBOP", "unary op %u", in->sub);
         if (!same_type(td, ta)) F("C2-TYPE-UN", "unary result type differs from operand");
-        if (in->sub == U_LNOT ? td->s != S_BOOL : !is_int(td->s)) F("C2-TYPE-UN", "unary operand type"); /* GUARD:un-type */
+        int unbad = in->sub == U_LNOT ? td->s != S_BOOL
+                    : in->sub == U_NEG ? !(is_int(td->s) || td->s == S_F32)
+                    : in->sub == U_BNOT ? !is_int(td->s)
+                    : td->s != S_F32; /* EXP, INV, RSQ, SQRT */
+        if (unbad) F("C2-TYPE-UN", "unary operand type"); /* GUARD:un-type */
         break;
     case C2_CMP:
         if (in->sub < CC_EQ || in->sub >= CC_LIMIT) F("C2-DECODE-SUBOP", "comparison %u", in->sub);
         if (td->s != S_BOOL || !is_scalar_t(ta) || !same_type(ta, tb)) F("C2-TYPE-CMP", "comparison operand types"); /* GUARD:cmp-type */
         break;
     case C2_CAST:
+        /* integers, or u32 <-> f32 (GPU.md section 4) */
+        if (td->s == S_F32 || ta->s == S_F32) {
+            if (!((td->s == S_F32 && ta->s == S_U32) || (td->s == S_U32 && ta->s == S_F32))) F("C2-TYPE-CAST", "f32 cast other than u32 <-> f32"); /* GUARD:cast-f32 */
+            break;
+        }
         if (!is_int(td->s) || !is_int(ta->s)) F("C2-TYPE-CAST", "cast between non-integers (bool casts are refused)"); /* GUARD:cast-type */
         break;
     case C2_ALLOC: case C2_AALLOC:
@@ -333,6 +369,7 @@ static int check_insn(Fx *x, uint32_t ii)
     case C2_CALL: {
         if (in->callee >= x->fi) F("C2-CALL-ORDER", "call to function %u from function %d (no recursion, no forward calls)", in->callee, x->fi); /* GUARD:call-order */
         const C2Func *g = &x->u->fn[in->callee];
+        if (f->kind != FN_HOST || g->kind != FN_HOST) F("C2-GPU-CALL", "call into or out of a kernel"); /* GUARD:gpu-call */
         if (in->nargs != g->nparams) F("C2-CALL-ARITY", "%u arguments for %u parameters", in->nargs, g->nparams); /* GUARD:call-arity */
         if (g->ret.s == S_VOID ? in->dst != -1 : (in->dst < 0 || in->dst >= nv || !same_type(T(x, in->dst), &g->ret)))
             F("C2-TYPE-CALL", "call result type"); /* GUARD:call-ret */
@@ -356,6 +393,30 @@ static int check_insn(Fx *x, uint32_t ii)
         }
         break;
     }
+    case C2_GPU:
+        if (in->sub < G_THREAD || in->sub >= G_LIMIT) F("C2-DECODE-SUBOP", "launch value %u", in->sub); /* GUARD:gpu-sub */
+        if (td->s != S_U32) F("C2-TYPE-GPU", "launch value into a non-u32 register"); /* GUARD:gpu-u32 */
+        break;
+    case C2_SHARED:
+        if (!is_block(td)) F("C2-TYPE-GPU", "shared array into a non-block register"); /* GUARD:shared-type */
+        break;
+    case C2_GLOAD: case C2_GSTORE:
+        if (!is_gbuf(ta)) F("C2-TYPE-GPU", "buffer access through a non-buffer register"); /* GUARD:gbuf-ptr */
+        if (T(x, (int16_t)(in->a + 1))->s != S_U32) F("C2-TYPE-GPU", "buffer v%d has no u32 length register", in->a);
+        if (tb->s != S_U32) F("C2-TYPE-GPU", "buffer index is not u32"); /* GUARD:gbuf-index */
+        if (in->op == C2_GLOAD ? td->s != ta->elem : tc->s != ta->elem) F("C2-TYPE-GPU", "buffer element type"); /* GUARD:gbuf-elem */
+        if (in->op == C2_GSTORE && ta->s != S_GEDIT) F("C2-GPU-STORE-VIEW", "store into a view buffer"); /* GUARD:gstore-view */
+        break;
+    case C2_SYNC:
+        break;
+    case C2_SHFL:
+        if (in->sub != SH_DOWN) F("C2-DECODE-SUBOP", "shuffle %u", in->sub);
+        if (!is_kvalue(ta->s) || !same_type(td, ta)) F("C2-TYPE-GPU", "shuffle value is not u32 or f32"); /* GUARD:shfl-type */
+        if (tb->s != S_U32) F("C2-TYPE-GPU", "shuffle distance is not u32");
+        break;
+    case C2_MAD:
+        if (td->s != S_F32 || ta->s != S_F32 || tb->s != S_F32 || tc->s != S_F32) F("C2-TYPE-GPU", "mad needs f32 operands"); /* GUARD:mad-type */
+        break;
     default: F("C2-DECODE-OPCODE", "opcode %u", in->op);
     }
     return 0;
@@ -529,7 +590,9 @@ static int check_defined(Fx *x)
             }
             in[b] = cur;
             for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++) {
-                if (f->in[i].op == C2_TRAP) { ball(&cur); break; } /* a trap ends the path */
+                int stop = f->in[i].op == C2_TRAP; /* a host trap ends the path */
+                if (f->kind == FN_KERNEL) stop = 0; /* GUARD:kernel-trap-flows */
+                if (stop) { ball(&cur); break; }
                 int d = defines(&f->in[i]);
                 if (d >= 0) bset(&cur, (unsigned)d);
             }
@@ -540,7 +603,7 @@ static int check_defined(Fx *x)
         if (!x->reach[b]) continue;
         Bits cur = in[b];
         for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++) {
-            if (f->in[i].op == C2_TRAP) break;
+            if (f->in[i].op == C2_TRAP && f->kind == FN_HOST) break; /* a kernel thread runs on (GPU.md section 7) */
             int16_t us[8];
             int nu = uses(&f->in[i], us);
             for (int k = 0; k < nu; k++) {
@@ -668,6 +731,596 @@ static int check_loops(Fx *x)
     return 0;
 }
 
+/* ------------------------------------------------------------------ GPU kernels */
+
+/* Which ops each function kind may hold, block-shared arrays and constant divisors
+ * (GPU.md sections 8 and 9). */
+static int kernel_forbidden(uint8_t op)
+{
+    switch (op) {
+    case C2_ALLOC: case C2_RELEASE: case C2_AOPEN: case C2_AALLOC: case C2_ADESTROY: case C2_POPEN:
+    case C2_PCLOSE: case C2_HALLOC: case C2_HGEN: case C2_HFREE: case C2_HLOAD: case C2_HSTORE:
+    case C2_SLOAD: case C2_SSTORE: case C2_FLOAD: case C2_FSTORE: case C2_CALL:
+        return 1;
+    default: return 0;
+    }
+}
+
+static int kernel_ops(Fx *x)
+{
+    const C2Func *f = x->f;
+    int kern = f->kind == FN_KERNEL;
+    unsigned shared_bytes = 0;
+    int syncs = 0;
+    for (uint32_t i = 0; i < f->ninsns; i++) {
+        const C2Insn *in = &f->in[i];
+        int gpu_op = in->op >= C2_GPU && in->op <= C2_MAD;
+        int gpu_sub = (in->op == C2_BIN && (in->sub == B_MIN || in->sub == B_MAX)) ||
+                      (in->op == C2_UN && in->sub >= U_EXP);
+        if (!kern) {
+            if (gpu_op || gpu_sub) /* GUARD:host-gpu-op */
+                return fail(x->v, "C2-GPU-OP", x->fi, (int)i, "kernel instruction %u in a host function", in->op);
+            continue;
+        }
+        /* unreachable today: the kernel type rules already refuse every operand these ops need (untagged) */
+        if (kernel_forbidden(in->op))
+            return fail(x->v, "C2-GPU-OP", x->fi, (int)i, "op %u is not allowed in a kernel", in->op);
+        switch (in->op) {
+        case C2_SHARED:
+            if (x->blk_of[i] != 0) /* GUARD:shared-entry */
+                return fail(x->v, "C2-GPU-SHARED", x->fi, (int)i, "shared array outside the entry block");
+            if (x->ndefs[in->dst] != 1) /* GUARD:shared-once */
+                return fail(x->v, "C2-GPU-SHARED", x->fi, (int)i, "shared array v%d defined more than once", in->dst);
+            shared_bytes += 4u * f->vt[in->dst].len;
+            if (shared_bytes > C2_MAX_SHARED_BYTES) /* GUARD:shared-bytes */
+                return fail(x->v, "C2-GPU-SHARED", x->fi, (int)i, "shared arrays over %u bytes", C2_MAX_SHARED_BYTES);
+            break;
+        case C2_LOAD: case C2_STORE: {
+            uint64_t index;
+            if (is_block(&f->vt[in->a]) && single_const(x, in->b, &index) && index >= f->vt[in->a].len) /* GUARD:gpu-bounds */
+                return fail(x->v, "C2-GPU-BOUNDS", x->fi, (int)i, "constant shared index outside declared length");
+            break;
+        }
+        case C2_BIN:
+            if (in->sub == B_DIV || in->sub == B_REM) {
+                uint64_t k;
+                if (in->b < f->nparams || !single_const(x, in->b, &k) || k == 0) /* GUARD:gpu-div */
+                    return fail(x->v, "C2-GPU-DIV", x->fi, (int)i, "kernel div/rem needs a nonzero constant divisor");
+            }
+            break;
+        case C2_SHFL: {
+            uint64_t k;
+            if (!single_const(x, in->b, &k) || k < 1 || k >= C2_WARP) /* GUARD:shfl-const */
+                return fail(x->v, "C2-GPU-SHFL", x->fi, (int)i, "shuffle distance is not one constant 1..31");
+            break;
+        }
+        case C2_SYNC:
+            if (++syncs > C2_MAX_SYNCS) /* GUARD:sync-limit */
+                return fail(x->v, "C2-GPU-SYNC-LIMIT", x->fi, (int)i, "more than %d sync lines", C2_MAX_SYNCS);
+            break;
+        default: break;
+        }
+    }
+    return 0;
+}
+
+/* C2-GPU-SYNC-DIVERGENT and C2-GPU-NEST (GPU.md section 6). A register is varying when it is
+ * defined from `thread`, a global or shared load or a shuffle, from any varying operand, or anywhere
+ * in a divergent block. A CBR on a varying register makes divergent every block reachable from its
+ * successors before a block that post-dominates it (its region); a RET goes to one virtual exit, so
+ * a region holding a RET runs to the end of the kernel. A kernel TRAP does not end the thread
+ * (GPU.md section 7), so it is an ordinary instruction here. SYNC and SHFL must not sit in a
+ * divergent block, and no block may sit inside more than C2_MAX_NEST regions. The analysis only
+ * grows its sets, so it terminates. */
+static int kernel_uniform(Fx *x)
+{
+    const C2Func *f = x->f;
+    static Bits pdom[C2_MAX_BLOCKS], region[C2_MAX_BLOCKS];
+    static uint8_t divb[C2_MAX_BLOCKS], done[C2_MAX_BLOCKS], vary[C2_MAX_VREGS];
+    static int st[2 * C2_MAX_BLOCKS + 2];
+    for (int b = 0; b < f->nblocks; b++) {
+        divb[b] = done[b] = 0;
+        memset(&region[b], 0, sizeof region[b]);
+        ball(&pdom[b]);
+        if (x->nsucc[b] == 0) { /* RET */
+            memset(&pdom[b], 0, sizeof pdom[b]);
+            bset(&pdom[b], (unsigned)b);
+        }
+    }
+    memset(vary, 0, sizeof vary);
+    int changed = 1;
+    while (changed) {
+        changed = 0;
+        for (int b = f->nblocks - 1; b >= 0; b--) {
+            if (x->nsucc[b] == 0) continue;
+            Bits n;
+            ball(&n);
+            for (int k = 0; k < x->nsucc[b]; k++) band(&n, &pdom[x->succ[b][k]]);
+            bset(&n, (unsigned)b);
+            if (!beq(&n, &pdom[b])) { pdom[b] = n; changed = 1; }
+        }
+    }
+    changed = 1;
+    while (changed) {
+        changed = 0;
+        for (int b = 0; b < f->nblocks; b++) {
+            if (!x->reach[b]) continue;
+            for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++) {
+                const C2Insn *in = &f->in[i];
+                int d = defines(in);
+                if (d < 0 || vary[d]) continue;
+                int v = 0;
+                if (divb[b]) v = 1; /* GUARD:vary-divergent-def */
+                if ((in->op == C2_GPU && in->sub == G_THREAD) || in->op == C2_GLOAD || in->op == C2_SHFL || in->op == C2_LOAD) v = 1; /* GUARD:vary-source */
+                int16_t us[8];
+                int nu = uses(in, us);
+                for (int k = 0; k < nu && !v; k++) v = vary[us[k]]; /* GUARD:vary-operand */
+                if (v) { vary[d] = 1; changed = 1; }
+            }
+            const C2Insn *t = &f->in[f->blk[b].first + f->blk[b].count - 1];
+            if (t->op != C2_CBR || !vary[t->a] || done[b]) continue;
+            done[b] = 1;
+            changed = 1;
+            int sp = 0;
+            for (int k = 0; k < x->nsucc[b]; k++) st[sp++] = x->succ[b][k];
+            while (sp) {
+                int c = st[--sp];
+                if (btest(&region[b], (unsigned)c)) continue;
+                if (c != b && btest(&pdom[b], (unsigned)c)) continue; /* GUARD:region-stop */
+                bset(&region[b], (unsigned)c);
+                divb[c] = 1;
+                for (int k = 0; k < x->nsucc[c]; k++) st[sp++] = x->succ[c][k];
+            }
+        }
+    }
+    for (int b = 0; b < f->nblocks; b++) {
+        if (!x->reach[b]) continue;
+        int nest = 0;
+        for (int c = 0; c < f->nblocks; c++)
+            if (done[c] && btest(&region[c], (unsigned)b)) nest++;
+        if (done[b] && !btest(&region[b], (unsigned)b)) nest++; /* the branch opens one more level, unless it loops into its own region */
+        if (nest > C2_MAX_NEST) /* GUARD:nest */
+            return fail(x->v, "C2-GPU-NEST", x->fi, (int)f->blk[b].first, "block %d sits %d varying regions deep (at most %d)", b, nest, C2_MAX_NEST);
+        if (!divb[b]) continue;
+        for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++)
+            if (f->in[i].op == C2_SYNC || f->in[i].op == C2_SHFL) /* GUARD:sync-divergent */
+                return fail(x->v, "C2-GPU-SYNC-DIVERGENT", x->fi, (int)i, "sync or down in block %d, which not every thread reaches", b);
+    }
+    return 0;
+}
+
+/* ------------------------------------------------------------------ races */
+
+/* C2-GPU-GLOBAL-RACE and C2-GPU-SHARED-RACE (GPU.md section 8). An index is read as a tree through
+ * registers with one definition. Leaves: numbers, uniform inputs (u32 parameters, `blocks`,
+ * `batches`), and digits: `thread`, `block`, `batch`, `rem thread K` (LO), `div thread K` (HI) and
+ * loop counters. Inner nodes: u32 add, mul, div, rem. Anything else is opaque and proves nothing.
+ * Nodes are hash-consed, so two accesses use "the same tree" when their node ids are equal. */
+enum { N_OPAQUE = 0, N_CONST, N_INV, N_THREAD, N_BLOCK, N_BATCH, N_LO, N_HI, N_LOOP, N_ADD, N_MUL, N_DIV, N_REM };
+#define RX_NODES 4096
+#define RX_FACTS 32
+#define RX_DIGITS 16
+typedef struct { uint8_t k; int a, b, h; uint64_t v; } Nd; /* LOOP: a counter, b guarded block or -1, h header, v bound */
+typedef struct { int n; int lt[RX_FACTS][2]; int nfix; int fix[RX_FACTS]; uint64_t fixv[RX_FACTS]; } Facts;
+typedef struct {
+    Fx *x;
+    unsigned T;
+    Nd nd[RX_NODES];
+    int nn;
+    int memo[C2_MAX_VREGS]; /* -1 not built, -2 being built, else a node */
+    int npred[C2_MAX_BLOCKS];
+    Bits loop[C2_MAX_BLOCKS]; /* natural loop of each header */
+} Rx;
+
+static int mk4(Rx *r, uint8_t k, int a, int b, int h, uint64_t v)
+{
+    for (int i = 1; i < r->nn; i++)
+        if (r->nd[i].k == k && r->nd[i].a == a && r->nd[i].b == b && r->nd[i].h == h && r->nd[i].v == v) return i;
+    if (r->nn >= RX_NODES) return 0;
+    r->nd[r->nn] = (Nd){ k, a, b, h, v };
+    return r->nn++;
+}
+
+static int mk(Rx *r, uint8_t k, int a, int b, uint64_t v) { return mk4(r, k, a, b, 0, v); }
+
+static int is_digit(uint8_t k) { return k >= N_THREAD && k <= N_LOOP; }
+static int thread_digit(uint8_t k) { return k == N_THREAD || k == N_LO || k == N_HI; }
+
+/* A loop counter: a u32 register with two definitions, a number before its loop and `add c c 1` as
+ * the last step of the loop's one latch, which jumps straight back to the header. */
+static int loop_digit(Rx *r, int c)
+{
+    const Fx *x = r->x;
+    const C2Func *f = x->f;
+    int init = -1, inc = -1;
+    uint64_t one;
+    for (uint32_t i = 0; i < f->ninsns; i++) {
+        if (defines(&f->in[i]) != c) continue;
+        const C2Insn *d = &f->in[i];
+        if (d->op == C2_BIN && d->sub == B_ADD && d->a == c && single_const(x, d->b, &one) && one == 1) inc = (int)i;
+        else if (d->op == C2_CONST || (d->op == C2_MOV && single_const(x, d->a, &one))) init = (int)i;
+    }
+    if (init < 0 || inc < 0) return 0;
+    int lb = x->blk_of[inc];
+    const C2Block *bk = &f->blk[lb];
+    const C2Insn *t = &f->in[bk->first + bk->count - 1];
+    if ((uint32_t)inc + 2 != bk->first + bk->count || t->op != C2_BR) return 0; /* GUARD:loop-digit-last */
+    int h = t->t, nlatch = 0;
+    if (!dominates(x, h, lb)) return 0;
+    for (int p = 0; p < f->nblocks; p++)
+        for (int k = 0; k < x->nsucc[p]; k++)
+            if (x->reach[p] && x->succ[p][k] == h && dominates(x, h, p)) nlatch++;
+    if (nlatch != 1 || btest(&r->loop[h], (unsigned)x->blk_of[init])) return 0; /* also implied by check_loops (untagged) */
+    /* the bound: a guard `lt c K` (or `ge c K`) in the loop whose exit side leaves it */
+    int gin = -1;
+    uint64_t K = 0;
+    for (int g = 0; g < f->nblocks && gin < 0; g++) {
+        if (!x->reach[g] || !btest(&r->loop[h], (unsigned)g)) continue;
+        const C2Insn *gt = &f->in[f->blk[g].first + f->blk[g].count - 1];
+        if (gt->op != C2_CBR || gt->t == gt->f) continue;
+        int ci = x->def_insn[gt->a];
+        if (ci < 0 || x->blk_of[ci] != g || f->in[ci].op != C2_CMP || f->in[ci].a != c || !single_const(x, f->in[ci].b, &K)) continue;
+        int in_t = btest(&r->loop[h], gt->t), in_f = btest(&r->loop[h], gt->f);
+        if (f->in[ci].sub == CC_LT && in_t && !in_f) gin = gt->t;
+        if (f->in[ci].sub == CC_GE && in_f && !in_t) gin = gt->f;
+    }
+    return mk4(r, N_LOOP, c, gin, h, gin < 0 ? 0 : K);
+}
+
+static int tree(Rx *r, int reg);
+
+static int combine(Rx *r, uint8_t sub, int A, int B)
+{
+    if (!A || !B) return 0;
+    const Nd *b = &r->nd[B];
+    switch (sub) {
+    case B_ADD: case B_MUL:
+        return mk(r, sub == B_ADD ? N_ADD : N_MUL, A < B ? A : B, A < B ? B : A, 0);
+    case B_DIV: case B_REM:
+        if (b->k != N_CONST || b->v == 0) return 0;
+        if (r->nd[A].k == N_THREAD) {
+            uint64_t K = b->v;
+            if (sub == B_DIV) return K == 1 ? A : K >= r->T ? mk(r, N_CONST, 0, 0, 0) : mk(r, N_HI, 0, 0, K);
+            return K == 1 ? mk(r, N_CONST, 0, 0, 0) : K >= r->T ? A : mk(r, N_LO, 0, 0, K);
+        }
+        return mk(r, sub == B_DIV ? N_DIV : N_REM, A, B, 0);
+    default: return 0;
+    }
+}
+
+static int build_tree(Rx *r, int reg)
+{
+    const Fx *x = r->x;
+    const C2Func *f = x->f;
+    if (f->vt[reg].s != S_U32) return 0;
+    if (reg < f->nparams) return x->ndefs[reg] == 1 ? mk(r, N_INV, reg, 0, 0) : 0;
+    if (x->ndefs[reg] == 2) return loop_digit(r, reg);
+    if (x->ndefs[reg] != 1 || x->def_insn[reg] < 0) return 0;
+    const C2Insn *d = &f->in[x->def_insn[reg]];
+    switch (d->op) {
+    case C2_CONST: return mk(r, N_CONST, 0, 0, d->imm);
+    case C2_MOV: return tree(r, d->a);
+    case C2_GPU:
+        switch (d->sub) {
+        case G_THREAD: return mk(r, N_THREAD, 0, 0, 0);
+        case G_BLOCK: return mk(r, N_BLOCK, 0, 0, 0);
+        case G_BATCH: return mk(r, N_BATCH, 0, 0, 0);
+        default: return mk(r, N_INV, -(int)d->sub, 0, 0); /* blocks, batches */
+        }
+    case C2_BIN: return combine(r, d->sub, tree(r, d->a), tree(r, d->b));
+    default: return 0;
+    }
+}
+
+static int tree(Rx *r, int reg)
+{
+    if (reg < 0 || reg >= r->x->f->nvregs || r->memo[reg] == -2) return 0;
+    if (r->memo[reg] >= 0) return r->memo[reg];
+    r->memo[reg] = -2;
+    int n = build_tree(r, reg);
+    r->memo[reg] = n;
+    return n;
+}
+
+/* The digits of a tree, or -1 when it holds an opaque node. */
+static int digits(const Rx *r, int n, int *ds, int *nd)
+{
+    const Nd *p = &r->nd[n];
+    if (p->k == N_OPAQUE) return -1;
+    if (is_digit(p->k)) {
+        for (int i = 0; i < *nd; i++)
+            if (ds[i] == n) return 0;
+        if (*nd >= RX_DIGITS) return -1;
+        ds[(*nd)++] = n;
+        return 0;
+    }
+    if (p->k >= N_ADD) return digits(r, p->a, ds, nd) || digits(r, p->b, ds, nd) ? -1 : 0;
+    return 0;
+}
+
+static int digit_free(const Rx *r, int n)
+{
+    int ds[RX_DIGITS], nd = 0;
+    return digits(r, n, ds, &nd) == 0 && nd == 0;
+}
+
+/* Two trees share no digit. `rem thread K` and `div thread K` with the same K are the only thread
+ * digits that are independent of each other. */
+static int disjoint(const Rx *r, int a, int b)
+{
+    int da[RX_DIGITS], db[RX_DIGITS], na = 0, nb = 0;
+    if (digits(r, a, da, &na) || digits(r, b, db, &nb)) return 0;
+    for (int i = 0; i < na; i++)
+        for (int j = 0; j < nb; j++) {
+            const Nd *p = &r->nd[da[i]], *q = &r->nd[db[j]];
+            if (da[i] == db[j]) return 0; /* GUARD:disjoint-same */
+            if (thread_digit(p->k) && thread_digit(q->k) &&
+                !(p->v == q->v && ((p->k == N_LO && q->k == N_HI) || (p->k == N_HI && q->k == N_LO)))) /* GUARD:disjoint-thread */
+                return 0;
+        }
+    return 1;
+}
+
+static uint64_t sat_add(uint64_t a, uint64_t b) { return a + b < a ? UINT64_MAX : a + b; }
+static uint64_t sat_mul(uint64_t a, uint64_t b) { return a && b > UINT64_MAX / a ? UINT64_MAX : a * b; }
+
+/* The largest value a tree can hold at block sb, or UINT64_MAX when unknown. */
+static uint64_t maxval(const Rx *r, int n, int sb)
+{
+    const Nd *p = &r->nd[n];
+    switch (p->k) {
+    case N_CONST: return p->v;
+    case N_THREAD: return r->T - 1;
+    case N_LO: return (p->v < r->T ? p->v : r->T) - 1;
+    case N_HI: return (r->T - 1) / p->v;
+    case N_LOOP: /* the counter is below K wherever the guard's loop side dominates */
+        if (p->b >= 0 && dominates(r->x, p->b, sb)) return p->v ? p->v - 1 : 0; /* GUARD:race-loop-bound */
+        return UINT64_MAX;
+    case N_ADD: return sat_add(maxval(r, p->a, sb), maxval(r, p->b, sb));
+    case N_MUL: return sat_mul(maxval(r, p->a, sb), maxval(r, p->b, sb));
+    case N_DIV: return maxval(r, p->a, sb) / r->nd[p->b].v;
+    case N_REM: { uint64_t m = maxval(r, p->a, sb), k = r->nd[p->b].v - 1; return m < k ? m : k; }
+    default: return UINT64_MAX;
+    }
+}
+
+static int less(const Rx *r, int y, int M, int sb, const Facts *fc)
+{
+    if (r->nd[M].k == N_CONST && maxval(r, y, sb) < r->nd[M].v) return 1;
+    for (int i = 0; i < fc->n; i++)
+        if (fc->lt[i][0] == y && fc->lt[i][1] == M) return 1; /* GUARD:fact-lt */
+    return 0;
+}
+
+/* Different digit values give different indexes. */
+static int injective(const Rx *r, int n, int sb, const Facts *fc)
+{
+    const Nd *p = &r->nd[n];
+    if (is_digit(p->k) || digit_free(r, n)) return 1;
+    if (p->k == N_MUL) {
+        if (r->nd[p->a].k == N_CONST && r->nd[p->a].v) return injective(r, p->b, sb, fc);
+        if (r->nd[p->b].k == N_CONST && r->nd[p->b].v) return injective(r, p->a, sb, fc);
+        return 0;
+    }
+    if (p->k != N_ADD) return 0;
+    for (int o = 0; o < 2; o++) {
+        int m = o ? p->b : p->a, y = o ? p->a : p->b;
+        if (digit_free(r, y)) return injective(r, m, sb, fc);
+        if (r->nd[m].k != N_MUL) continue;
+        for (int q = 0; q < 2; q++) {
+            int a = q ? r->nd[m].b : r->nd[m].a, M = q ? r->nd[m].a : r->nd[m].b;
+            if (!digit_free(r, M)) continue;
+            if (!less(r, y, M, sb, fc)) continue; /* GUARD:inj-less */
+            if (injective(r, a, sb, fc) && injective(r, y, sb, fc) && disjoint(r, a, y)) return 1;
+        }
+    }
+    return 0;
+}
+
+/* A loop digit means "this iteration" only inside its loop. */
+static int loops_hold(const Rx *r, int n, int sb)
+{
+    int ds[RX_DIGITS], nd = 0;
+    if (digits(r, n, ds, &nd)) return 0;
+    for (int i = 0; i < nd; i++) {
+        const Nd *p = &r->nd[ds[i]];
+        if (p->k == N_LOOP && !btest(&r->loop[p->h], (unsigned)sb)) return 0; /* GUARD:loop-digit-site */
+    }
+    return 1;
+}
+
+static void add_cond(Rx *r, int reg, int pol, int sb, Facts *fc, int depth)
+{
+    const Fx *x = r->x;
+    const C2Func *f = x->f;
+    if (depth > 32 || reg < 0 || x->ndefs[reg] != 1 || x->def_insn[reg] < 0) return;
+    const C2Insn *d = &f->in[x->def_insn[reg]];
+    if (d->op == C2_MOV) { add_cond(r, d->a, pol, sb, fc, depth + 1); return; }
+    if (d->op == C2_UN && d->sub == U_LNOT) { add_cond(r, d->a, !pol, sb, fc, depth + 1); return; }
+    if (d->op == C2_BIN && d->sub == (pol ? B_AND : B_OR)) {
+        add_cond(r, d->a, pol, sb, fc, depth + 1);
+        add_cond(r, d->b, pol, sb, fc, depth + 1);
+        return;
+    }
+    if (d->op != C2_CMP || f->vt[d->a].s != S_U32) return; /* trees are u32 only, so also implied (untagged) */
+    int A = tree(r, d->a), B = tree(r, d->b);
+    if (!A || !B) return;
+    /* a fact about a loop digit holds only when the compare runs in that loop's same iteration */
+    if (!loops_hold(r, A, x->blk_of[x->def_insn[reg]]) || !loops_hold(r, B, x->blk_of[x->def_insn[reg]])) return;
+    uint8_t cc = d->sub;
+    if (!pol) cc = cc == CC_GE ? CC_LT : cc == CC_LE ? CC_GT : cc == CC_NE ? CC_EQ : 0;
+    if ((cc == CC_LT || cc == CC_GT) && fc->n < RX_FACTS) {
+        fc->lt[fc->n][0] = cc == CC_LT ? A : B;
+        fc->lt[fc->n][1] = cc == CC_LT ? B : A;
+        fc->n++;
+    }
+    if (cc == CC_EQ && fc->nfix < RX_FACTS) {
+        if (r->nd[A].k == N_CONST) { int t = A; A = B; B = t; }
+        if (r->nd[B].k == N_CONST && is_digit(r->nd[A].k) && r->nd[A].k != N_LOOP) {
+            fc->fix[fc->nfix] = A;
+            fc->fixv[fc->nfix++] = r->nd[B].v;
+        }
+    }
+}
+
+/* Facts at block sb: the condition of every branch side that has the branch as its only
+ * predecessor and dominates sb. */
+static void facts_at(Rx *r, int sb, Facts *fc)
+{
+    const Fx *x = r->x;
+    const C2Func *f = x->f;
+    memset(fc, 0, sizeof *fc);
+    for (int g = 0; g < f->nblocks; g++) {
+        if (!x->reach[g]) continue;
+        const C2Insn *t = &f->in[f->blk[g].first + f->blk[g].count - 1];
+        if (t->op != C2_CBR || t->t == t->f) continue;
+        for (int side = 0; side < 2; side++) {
+            int s = side ? t->f : t->t;
+            if (r->npred[s] != 1) continue; /* GUARD:fact-single-pred */
+            if (!dominates(x, s, sb)) continue; /* GUARD:fact-dom */
+            add_cond(r, t->a, !side, sb, fc, 0);
+        }
+    }
+}
+
+/* digits(E) plus the digits both accesses fix to the same number cover `thread`, and `block` /
+ * `batch` when asked. */
+static int covers(const Rx *r, int E, const Facts *a, const Facts *b, int want_block, int want_batch)
+{
+    int ds[RX_DIGITS + 2 * RX_FACTS], nd = 0;
+    if (digits(r, E, ds, &nd)) return 0;
+    for (int i = 0; i < a->nfix; i++)
+        for (int j = 0; j < b->nfix; j++)
+            if (a->fix[i] == b->fix[j] && a->fixv[i] == b->fixv[j]) ds[nd++] = a->fix[i]; /* GUARD:cover-fixed */
+    int th = 0, bl = !want_block, ba = !want_batch;
+    for (int i = 0; i < nd; i++) {
+        const Nd *p = &r->nd[ds[i]];
+        if (p->k == N_THREAD) th = 1;
+        if (p->k == N_BLOCK) bl = 1;
+        if (p->k == N_BATCH) ba = 1;
+        if (p->k == N_LO)
+            for (int j = 0; j < nd; j++)
+                if (r->nd[ds[j]].k == N_HI && r->nd[ds[j]].v == p->v) th = 1; /* GUARD:cover-lohi */
+    }
+    return th && bl && ba;
+}
+
+typedef struct { uint32_t i; int ref, E, sb, store; uint64_t mask; Facts fc; } Acc;
+
+static int race_pair(Rx *r, const Acc *p, const Acc *q, const char *rule, int wb, int wa)
+{
+    const Fx *x = r->x;
+    if (!p->E || p->E != q->E) /* GUARD:race-same */
+        return fail(x->v, rule, x->fi, (int)q->i, "v%d is accessed at two different indexes (insns %u and %u)", p->ref, p->i, q->i);
+    if (!injective(r, q->E, q->sb, &q->fc)) /* GUARD:race-inj */
+        return fail(x->v, rule, x->fi, (int)q->i, "the index of v%d is not one-to-one", q->ref);
+    if (!loops_hold(r, q->E, q->sb)) /* GUARD:race-loop */
+        return fail(x->v, rule, x->fi, (int)q->i, "a loop counter is used as an index outside its loop");
+    if (!covers(r, q->E, &p->fc, &q->fc, wb, wa)) /* GUARD:race-cover */
+        return fail(x->v, rule, x->fi, (int)q->i, "two threads can reach the same element of v%d", q->ref);
+    return 0;
+}
+
+static int kernel_races(Fx *x)
+{
+    const C2Func *f = x->f;
+    Rx *r = calloc(1, sizeof *r);
+    Acc *acc = calloc(f->ninsns, sizeof *acc);
+    int rc = -1, na = 0;
+    if (!r || !acc) { fail(x->v, "C2-RESOURCE", x->fi, -1, "out of memory"); goto out; }
+    r->x = x;
+    r->T = f->threads;
+    r->nn = 1; /* node 0 is the opaque tree */
+    for (int i = 0; i < f->nvregs; i++) r->memo[i] = -1;
+    for (int p = 0; p < f->nblocks; p++)
+        for (int k = 0; k < x->nsucc[p]; k++)
+            if (x->reach[p]) r->npred[x->succ[p][k]]++;
+    for (int h = 0; h < f->nblocks; h++) { /* natural loops, as check_loops builds them */
+        int st[C2_MAX_BLOCKS], n = 0;
+        for (int p = 0; p < f->nblocks; p++)
+            for (int k = 0; k < x->nsucc[p]; k++)
+                if (x->reach[p] && x->succ[p][k] == h && dominates(x, h, p) && !btest(&r->loop[h], (unsigned)p)) {
+                    bset(&r->loop[h], (unsigned)p);
+                    st[n++] = p;
+                }
+        if (!n) continue;
+        bset(&r->loop[h], (unsigned)h);
+        while (n) {
+            int b = st[--n];
+            for (int p = 0; p < f->nblocks; p++) {
+                if (!x->reach[p] || btest(&r->loop[h], (unsigned)p)) continue;
+                for (int k = 0; k < x->nsucc[p]; k++)
+                    if (x->succ[p][k] == b) { bset(&r->loop[h], (unsigned)p); st[n++] = p; break; }
+            }
+        }
+    }
+    /* phases: bit 0 is the kernel start, bit k the k-th sync line */
+    static uint64_t pin[C2_MAX_BLOCKS], pout[C2_MAX_BLOCKS];
+    uint32_t syncno[C2_MAX_SYNCS + 1];
+    int nsync = 0;
+    for (uint32_t i = 0; i < f->ninsns; i++)
+        if (f->in[i].op == C2_SYNC && nsync < C2_MAX_SYNCS) syncno[++nsync] = i;
+    memset(pout, 0, sizeof pout);
+    for (int changed = 1; changed;) {
+        changed = 0;
+        for (int b = 0; b < f->nblocks; b++) {
+            if (!x->reach[b]) continue;
+            uint64_t m = b == 0 ? 1 : 0;
+            for (int p = 0; p < f->nblocks; p++)
+                for (int k = 0; k < x->nsucc[p]; k++)
+                    if (x->reach[p] && x->succ[p][k] == b) m |= pout[p];
+            pin[b] = m;
+            for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++)
+                if (f->in[i].op == C2_SYNC)
+                    for (int s = 1; s <= nsync; s++)
+                        if (syncno[s] == i) m = 1ull << s; /* GUARD:phase-sync */
+            if (m != pout[b]) { pout[b] = m; changed = 1; }
+        }
+    }
+    int want_block = 0, want_batch = 0;
+    for (uint32_t i = 0; i < f->ninsns; i++) {
+        const C2Insn *in = &f->in[i];
+        if (in->op == C2_GPU && in->sub == G_BLOCK) want_block = 1;
+        if (in->op == C2_GPU && in->sub == G_BATCH) want_batch = 1;
+    }
+    for (int b = 0; b < f->nblocks; b++) {
+        if (!x->reach[b]) continue;
+        uint64_t m = pin[b];
+        for (uint32_t i = f->blk[b].first; i < f->blk[b].first + f->blk[b].count; i++) {
+            const C2Insn *in = &f->in[i];
+            if (in->op == C2_SYNC)
+                for (int s = 1; s <= nsync; s++)
+                    if (syncno[s] == i) m = 1ull << s;
+            if (in->op != C2_LOAD && in->op != C2_STORE && in->op != C2_GLOAD && in->op != C2_GSTORE) continue;
+            /* a shared array register is defined once and never copied (C2-GPU-SHARED, bindable), and a
+             * buffer register is a parameter never written, so the register names the array */
+            int ref = in->a;
+            Acc *a = &acc[na++];
+            a->i = i; a->ref = ref; a->sb = b; a->mask = m;
+            a->store = in->op == C2_STORE || in->op == C2_GSTORE;
+            a->E = tree(r, in->b);
+            facts_at(r, b, &a->fc);
+        }
+    }
+    for (int p = 0; p < na; p++)
+        for (int q = p; q < na; q++) {
+            const Acc *A = &acc[p], *B = &acc[q];
+            if (A->ref != B->ref || !(A->store || B->store)) continue;
+            int shared = f->in[A->i].op == C2_LOAD || f->in[A->i].op == C2_STORE;
+            if (shared) {
+                if (!(A->mask & B->mask)) continue; /* GUARD:phase-apart */
+                if (race_pair(r, A, B, "C2-GPU-SHARED-RACE", 0, 0) || race_pair(r, B, A, "C2-GPU-SHARED-RACE", 0, 0)) goto out;
+            } else if (race_pair(r, A, B, "C2-GPU-GLOBAL-RACE", want_block, want_batch) ||
+                       race_pair(r, B, A, "C2-GPU-GLOBAL-RACE", want_block, want_batch))
+                goto out;
+        }
+    rc = 0;
+out:
+    free(acc);
+    free(r);
+    return rc;
+}
+
 /* ------------------------------------------------------------------ ownership flow */
 
 /* May-states of a reference-owner register: bit 0 not yet holding, bit 1 live, bit 2 dead
@@ -873,13 +1526,29 @@ static int check_func(const C2Unit *u, int fi, C2Verdict *v)
     const C2Func *f = &u->fn[fi];
     for (int g = 0; g < fi; g++)
         if (strcmp(u->fn[g].name, f->name) == 0) return fail(v, "C2-FUNC-NAME", fi, -1, "function %s defined twice", f->name); /* GUARD:func-name */
-    if (f->nparams > C2_MAX_PARAMS || f->nparams > f->nvregs) /* GUARD:params */
+    int kern = f->kind == FN_KERNEL;
+    if (f->nparams > (kern ? C2_MAX_KPARAMS : C2_MAX_PARAMS) || f->nparams > f->nvregs) /* GUARD:params */
         return fail(v, "C2-FUNC-PARAMS", fi, -1, "%u parameters, %u registers", f->nparams, f->nvregs);
+    if (kern && (f->ret.s != S_VOID || f->req_len || f->ens_len)) /* GUARD:kernel-void */
+        return fail(v, "C2-GPU-KERNEL", fi, -1, "a kernel returns nothing and carries no requires/ensures");
+    if (kern && (f->threads < C2_MIN_THREADS || f->threads > C2_MAX_THREADS || f->threads % C2_WARP)) /* GUARD:kernel-threads */
+        return fail(v, "C2-GPU-KERNEL", fi, -1, "%u threads per block (32..1024, a multiple of 32)", f->threads);
     if (!(f->ret.s == S_VOID || is_value(f->ret.s))) /* GUARD:ret-scalar */
         return fail(v, "C2-FUNC-RETURN", fi, -1, "function returns a non-scalar");
     for (int r = 0; r < f->nvregs; r++) {
         const C2Type *t = &f->vt[r];
         if (!check_type(u, t)) return fail(v, "C2-TYPE-INVALID", fi, -1, "register v%d has an invalid type", r); /* GUARD:vreg-type */
+        int ktype = is_gbuf(t) || is_block(t) || t->s == S_F32;
+        if (kern ? !(ktype || t->s == S_BOOL || t->s == S_U32) : ktype) /* GUARD:gpu-type */
+            return fail(v, "C2-GPU-TYPE", fi, -1, "register v%d: type %u is not allowed in a %s", r, t->s, kern ? "kernel" : "host function");
+        if (is_block(t) && r < f->nparams) /* GUARD:block-param */
+            return fail(v, "C2-GPU-SHARED", fi, -1, "shared array v%d is a parameter", r);
+        if (is_gbuf(t)) {
+            if (r + 1 >= f->nparams || f->vt[r + 1].s != S_U32) /* GUARD:gbuf-param */
+                return fail(v, "C2-GPU-BUFFER", fi, -1, "buffer register v%d is not a parameter followed by its u32 length", r);
+            if (r > 0 && is_gbuf(&f->vt[r - 1]))
+                return fail(v, "C2-GPU-BUFFER", fi, -1, "buffer v%d sits in the length register of v%d", r, r - 1);
+        }
         if (is_slice(t)) {
             if (r + 1 >= f->nparams || f->vt[r + 1].s != S_U64) /* GUARD:slice-param */
                 return fail(v, "C2-SLICE-PARAM", fi, -1, "slice register v%d is not a parameter followed by its u64 length", r);
@@ -898,10 +1567,13 @@ static int check_func(const C2Unit *u, int fi, C2Verdict *v)
         if (check_insn(x, i)) goto out;
     link_cfg(x);
     count_defs(x);
+    if (kernel_ops(x)) goto out;
+    if (kern && kernel_uniform(x)) goto out;
     if (check_handles(x)) goto out;
     if (check_defined(x)) goto out;
     if (check_loops(x)) goto out;
     if (check_ownership(x)) goto out;
+    if (kern && kernel_races(x)) goto out;
     rc = 0;
 out:
     free(x->blk_of);
diff --git a/src/checker2/c2_ir.c b/src/checker2/c2_ir.c
index 765b831b0..c76d1cd86 100644
--- a/src/checker2/c2_ir.c
+++ b/src/checker2/c2_ir.c
@@ -115,6 +115,7 @@ static int rdtype(Rd *r, C2Type *t)
 {
     memset(t, 0, sizeof *t);
     if (rd8(r, &t->s)) return -1;
+    if (t->s == S_GVIEW || t->s == S_GEDIT) return rd8(r, &t->elem) ? -1 : 0; /* version 8 buffer: elem */
     if (t->s == S_REF) {
         if (rd8(r, &t->kind) || rd8(r, &t->elem) || rd16(r, &t->len)) return -1;
         /* a struct reference has elem VOID and carries its struct index + 1 */
@@ -178,6 +179,13 @@ static int dec_insn(Rd *r, C2Insn *in, C2Verdict *v, int fi, int ii)
     }
     case C2_BR: bad = rd16(r, &in->t); break;
     case C2_CBR: bad = rdvr(r, &in->a) || rd16(r, &in->t) || rd16(r, &in->f); break;
+    case C2_GPU: bad = rd8(r, &in->sub) || rdvr(r, &in->dst); break;
+    case C2_SHARED: bad = rdvr(r, &in->dst); break;
+    case C2_GLOAD: bad = rdvr(r, &in->dst) || rdvr(r, &in->a) || rdvr(r, &in->b); break;
+    case C2_GSTORE: bad = rdvr(r, &in->a) || rdvr(r, &in->b) || rdvr(r, &in->c); break;
+    case C2_SYNC: break;
+    case C2_SHFL: bad = rd8(r, &in->sub) || rdvr(r, &in->dst) || rdvr(r, &in->a) || rdvr(r, &in->b); break;
+    case C2_MAD: bad = rdvr(r, &in->dst) || rdvr(r, &in->a) || rdvr(r, &in->b) || rdvr(r, &in->c); break;
     default: return fail(v, "C2-DECODE-OPCODE", fi, ii, "unknown opcode %u", in->op);
     }
     if (bad) TRUNC("instruction operands");
@@ -200,8 +208,16 @@ static int has_slice(const C2Unit *u)
     return 0;
 }
 
+static int has_kernel(const C2Unit *u)
+{
+    for (int fi = 0; fi < u->nfuncs; fi++)
+        if (u->fn[fi].kind != FN_HOST) return 1;
+    return 0;
+}
+
 static int canonical_version(const C2Unit *u)
 {
+    if (has_kernel(u)) return C2_V_KERNEL; /* GUARD:kernel-version */
     if (has_slice(u)) return 5;
     if (has_op(u, C2_POPEN, C2_HSTORE)) return 4;
     if (has_op(u, C2_AOPEN, C2_ADESTROY)) return 3;
@@ -244,7 +260,7 @@ int c2_decode(const uint8_t *buf, size_t len, C2Unit *u, C2Verdict *v)
     Rd rr = {buf, len, 0}, *r = &rr;
     if (!buf || len < 8 || memcmp(buf, MAGIC7, 7) != 0) return fail(v, "C2-DECODE-MAGIC", -1, -1, "bad magic");
     u->version = buf[7];
-    if (u->version < 1 || u->version > 5) /* GUARD:version-range */
+    if (!((u->version >= 1 && u->version <= 5) || u->version == C2_V_KERNEL)) /* GUARD:version-range */
         return fail(v, "C2-DECODE-VERSION", -1, -1, "unknown version %u", u->version);
     r->i = 8;
     if (u->version >= 2) {
@@ -274,6 +290,11 @@ int c2_decode(const uint8_t *buf, size_t len, C2Unit *u, C2Verdict *v)
         int e = rdname(r, f->name);
         if (e == -1) TRUNC("function name");
         if (e) return fail(v, "C2-DECODE-NAME", fi, -1, "function name");
+        if (u->version == C2_V_KERNEL) {
+            if (rd8(r, &f->kind)) TRUNC("function kind");
+            if (f->kind > FN_KERNEL) return fail(v, "C2-DECODE-KIND", fi, -1, "function kind %u", f->kind); /* GUARD:kind-range */
+            if (f->kind == FN_KERNEL && rd16(r, &f->threads)) TRUNC("thread count");
+        }
         if (rd8(r, &f->nparams)) TRUNC("nparams");
         if (rdtype(r, &f->ret)) TRUNC("return type");
         if (rd16(r, &f->nvregs)) TRUNC("nvregs");
@@ -333,6 +354,7 @@ static void wname(Wr *w, const char *s) { size_t n = strlen(s); w8(w, (unsigned)
 static void wtype(Wr *w, const C2Type *t)
 {
     w8(w, t->s);
+    if (t->s == S_GVIEW || t->s == S_GEDIT) w8(w, t->elem);
     if (t->s == S_REF) {
         w8(w, t->kind); w8(w, t->elem); w16(w, t->len);
         if (t->elem == S_VOID) w8(w, t->sid);
@@ -357,7 +379,10 @@ size_t c2_encode(const C2Unit *u, uint8_t *buf, size_t cap)
     w16(&w, u->nfuncs);
     for (int fi = 0; fi < u->nfuncs; fi++) {
         const C2Func *f = &u->fn[fi];
-        wname(&w, f->name); w8(&w, f->nparams); wtype(&w, &f->ret);
+        wname(&w, f->name);
+        if (u->version == C2_V_KERNEL) w8(&w, f->kind);
+        if (u->version == C2_V_KERNEL && f->kind == FN_KERNEL) w16(&w, f->threads);
+        w8(&w, f->nparams); wtype(&w, &f->ret);
         w16(&w, f->nvregs);
         for (int k = 0; k < f->nvregs; k++) wtype(&w, &f->vt[k]);
         w16(&w, f->nblocks);
@@ -388,6 +413,13 @@ size_t c2_encode(const C2Unit *u, uint8_t *buf, size_t cap)
             case C2_TRAP: w8(&w, (unsigned)in->imm); break;
             case C2_BR: w16(&w, in->t); break;
             case C2_CBR: wvr(&w, in->a); w16(&w, in->t); w16(&w, in->f); break;
+            case C2_GPU: w8(&w, in->sub); wvr(&w, in->dst); break;
+            case C2_SHARED: wvr(&w, in->dst); break;
+            case C2_GLOAD: wvr(&w, in->dst); wvr(&w, in->a); wvr(&w, in->b); break;
+            case C2_GSTORE: wvr(&w, in->a); wvr(&w, in->b); wvr(&w, in->c); break;
+            case C2_SYNC: break;
+            case C2_SHFL: w8(&w, in->sub); wvr(&w, in->dst); wvr(&w, in->a); wvr(&w, in->b); break;
+            case C2_MAD: wvr(&w, in->dst); wvr(&w, in->a); wvr(&w, in->b); wvr(&w, in->c); break;
             default: break;
             }
         }
diff --git a/src/checker2/c2_ir.h b/src/checker2/c2_ir.h
index 5bd542969..b59c48567 100644
--- a/src/checker2/c2_ir.h
+++ b/src/checker2/c2_ir.h
@@ -21,7 +21,8 @@
  * docs/osc/OSC-1-DESIGN.md, OSC-2-DESIGN.md, OSC-3-DESIGN.md, OSC-EXT-BYTES-DESIGN.md and the
  * comments of src/compiler/osc_ir.h. It includes no compiler header, links no compiler object and
  * never read osc_check.* or osc_ir_validate. Every constant below is restated here, not imported.
- * The rule list is in spec/one-layer-receipts.md section 9.
+ * The rule list is in spec/one-layer-receipts.md section 9. GPU kernels (encoding version 8) are
+ * restated from docs/omegese/GPU.md sections 6-9 and the version-6 byte layout stated there.
  *
  * Fails closed: anything not understood is a rejection with a stable rule name. */
 #ifndef C2_IR_H
@@ -43,21 +44,38 @@
 #define C2_MAX_FIELDS 16
 #define C2_POOL_SLOTS 16
 #define C2_TRAP_MAX 14
+#define C2_MAX_KPARAMS 32          /* GPU kernel parameter registers (GPU.md section 2) */
+#define C2_MIN_THREADS 32          /* threads per block of a kernel: 32..1024, a multiple of the warp */
+#define C2_MAX_THREADS 1024
+#define C2_WARP 32
+#define C2_MAX_SYNCS 63            /* sync lines per kernel (GPU.md section 8) */
+#define C2_MAX_NEST 16             /* nesting of varying regions (GPU.md section 6) */
+#define C2_MAX_SHARED_LEN 12288    /* elements of one block-shared array */
+#define C2_MAX_SHARED_BYTES 49152  /* block-shared bytes of one kernel, 4 per element */
 
 /* scalar codes on the wire */
 enum { S_VOID = 0, S_BOOL, S_U8, S_U16, S_U32, S_U64, S_I8, S_I16, S_I32, S_I64, S_REF, S_BYTES, S_CELLS,
+       S_F32, S_GVIEW, S_GEDIT, /* version 8: binary32; global buffer pointers (one elem byte follows) */
        S_LIMIT };
-enum { K_NONE = 0, K_OWN, K_SHARED, K_MUT };
+enum { K_NONE = 0, K_OWN, K_SHARED, K_MUT, K_BLOCK /* version 8: block-shared array */ };
+enum { FN_HOST = 0, FN_KERNEL = 1 }; /* function kind byte, version 8 */
+/* GPU kernels use wire version 8 (version 6 is reserved by draft #525, version 7 is the memory
+ * profile of spec/one-layer-format.md section 10; neither is accepted here). */
+#define C2_V_KERNEL 8
 
 /* opcodes on the wire */
 enum {
     C2_CONST = 1, C2_MOV, C2_BIN, C2_UN, C2_CMP, C2_CAST, C2_ALLOC, C2_RELEASE, C2_LOAD, C2_STORE,
     C2_CALL, C2_TRAP, C2_BR, C2_CBR, C2_RET, C2_FLOAD, C2_FSTORE, C2_AOPEN, C2_AALLOC, C2_ADESTROY,
     C2_POPEN, C2_PCLOSE, C2_HALLOC, C2_HGEN, C2_HFREE, C2_HLOAD, C2_HSTORE, C2_SLOAD, C2_SSTORE,
+    /* version 8, kernels only; numbered from 40, disjoint from version 7's opcodes 30..33 */
+    C2_GPU = 40, C2_SHARED, C2_GLOAD, C2_GSTORE, C2_SYNC, C2_SHFL, C2_MAD,
     C2_OP_LIMIT
 };
-enum { B_ADD = 1, B_SUB, B_MUL, B_DIV, B_REM, B_AND, B_OR, B_XOR, B_SHL, B_SHR, B_LIMIT };
-enum { U_NEG = 1, U_BNOT, U_LNOT, U_LIMIT };
+enum { B_ADD = 1, B_SUB, B_MUL, B_DIV, B_REM, B_AND, B_OR, B_XOR, B_SHL, B_SHR, B_MIN, B_MAX, B_LIMIT };
+enum { U_NEG = 1, U_BNOT, U_LNOT, U_EXP, U_INV, U_RSQ, U_SQRT, U_LIMIT };
+enum { G_THREAD = 1, G_BLOCK, G_BLOCKS, G_BATCH, G_BATCHES, G_LIMIT }; /* C2_GPU sub */
+enum { SH_DOWN = 1 };                                                              /* C2_SHFL sub */
 enum { CC_EQ = 1, CC_NE, CC_LT, CC_LE, CC_GT, CC_GE, CC_LIMIT };
 
 typedef struct {
@@ -77,6 +95,8 @@ typedef struct { uint32_t first, count; } C2Block;
 
 typedef struct {
     char name[C2_NAME_MAX + 1];
+    uint8_t kind;     /* FN_HOST, FN_KERNEL; on the wire only in version 8 */
+    uint16_t threads; /* kernel: threads per block (u16 after the kind byte); host: 0 */
     uint8_t nparams;
     C2Type ret;
     uint16_t nvregs, nblocks;
diff --git a/src/compiler/.crumb b/src/compiler/.crumb
index eccef6041..af83b001c 100644
--- a/src/compiler/.crumb
+++ b/src/compiler/.crumb
@@ -20,14 +20,14 @@
         }
       ],
       "children_root": "sha256:12b3e294aa48e971b1b571459a53b38b380352a98dbb3769e783d5fdf0fcb09b",
-      "compiled_at": "2026-10-30T14:42:32Z",
+      "compiled_at": "2026-11-06T02:49:40Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:806198eda65f998c287abd251928120d01ab44a1e0f1e05ad2e055212967c80c",
+      "digest": "sha256:305629b4a139d0ba04365a4f876fe1715760bf2da8e05712914dfe3f76c7d86e",
       "evidence_files": 0,
       "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
       "files": 31,
-      "generated_at_commit": "62d1d0d668f897386a0e311374f8dbcc5c32dde8",
-      "source_tree": "sha256:8c7ef8874c5b69a5f26780433a314c09cbfbc5369221701d60d7c510ec3a2629"
+      "generated_at_commit": "1cdee5c2580733475eb9d66a14b3da7b8a322219",
+      "source_tree": "sha256:2e0ea083fb283246c043c211eb9d0a2a0a4bf38c8d4bacda77e50f8d0797c04e"
     },
     "owner_lane": "",
     "provenance": {
diff --git a/src/compiler/osc_cg.c b/src/compiler/osc_cg.c
index 34a20f345..992e72d65 100644
--- a/src/compiler/osc_cg.c
+++ b/src/compiler/osc_cg.c
@@ -577,6 +577,10 @@ int osc_cg_compile_a(const OscAlloc *a, const OscUnit *u, OscCode *out, char *er
     out->a = a;
     if (!u) return -1;
     if (osc_ir_validate_a(a, u, err, n)) return -1;
+    if (osc_ir_has_kernel(u)) { /* GPU kernels go to src/omega_osc_gpu.c; this back end is AArch64 host code */
+        if (err && n) snprintf(err, n, "the unit has a GPU kernel; the host code generator takes host-only units");
+        return -1;
+    }
     Cg g;
     memset(&g, 0, sizeof g);
     g.a = a;
diff --git a/src/compiler/osc_interp.c b/src/compiler/osc_interp.c
index 000a2fde4..23a78a29f 100644
--- a/src/compiler/osc_interp.c
+++ b/src/compiler/osc_interp.c
@@ -244,6 +244,7 @@ static int check_args(const OscUnit *u, int func, const uint64_t *args, unsigned
 int osc_interp_run_prevalidated(const OscUnit *u, int func, const uint64_t *args, unsigned nargs, OscRt *rt,
                                 uint64_t *ret) {
     if (!u || !ret || check_args(u, func, args, nargs, rt)) return -1;
+    if (osc_ir_has_kernel(u)) return -1; /* kernels run on the GPU (src/omega_osc_gpu.c); the interpreter is host only */
     Ctx c = {u, rt, 0};
     uint64_t a[OSC_MAX_PARAMS] = {0};
     for (unsigned i = 0; i < nargs; i++) a[i] = args[i];
diff --git a/src/compiler/osc_ir.c b/src/compiler/osc_ir.c
index f645bd7b0..a084ba46b 100644
--- a/src/compiler/osc_ir.c
+++ b/src/compiler/osc_ir.c
@@ -40,9 +40,15 @@ unsigned osc_scalar_width(OscScalar s) {
 }
 bool osc_scalar_signed(OscScalar s) { return s >= OSC_T_I8 && s <= OSC_T_I64; }
 bool osc_scalar_is_int(OscScalar s) { return s >= OSC_T_U8 && s <= OSC_T_I64; }
+bool osc_ir_has_kernel(const OscUnit *u) {
+    for (int fi = 0; u && fi < u->nfuncs; fi++)
+        if (u->funcs[fi].kind != OSC_FN_HOST) return true;
+    return false;
+}
 const char *osc_scalar_name(OscScalar s) {
-    static const char *n[] = {"void", "bool", "u8", "u16", "u32", "u64", "i8", "i16", "i32", "i64", "ref", "bytes", "cells"};
-    return ((unsigned)s <= OSC_T_CELLS) ? n[s] : "?";
+    static const char *n[] = {"void", "bool", "u8", "u16", "u32", "u64", "i8", "i16", "i32", "i64", "ref", "bytes", "cells",
+                              "f32", "gview", "gedit"};
+    return ((unsigned)s <= OSC_T_LAST) ? n[s] : "?";
 }
 
 /* ---- validation ------------------------------------------------------- */
@@ -59,7 +65,7 @@ static int vfail(char *err, size_t n, const char *fmt, ...) {
 static bool is_value_scalar(OscScalar s) { return s >= OSC_T_BOOL && s <= OSC_T_I64; }
 
 static bool type_is_scalar(const OscType *t) {
-    return is_value_scalar(t->s) && t->ref == OSC_REF_NONE && t->elem == OSC_T_VOID && t->len == 0 && t->sid == 0;
+    return (is_value_scalar(t->s) || t->s == OSC_T_F32) && t->ref == OSC_REF_NONE && t->elem == OSC_T_VOID && t->len == 0 && t->sid == 0;
 }
 /* The unit whose struct table type_is_ref consults (set by osc_ir_validate;
  * validation is single-threaded per call). */
@@ -75,6 +81,18 @@ static bool type_is_slice(const OscType *t) {
     return (t->s == OSC_T_BYTES || t->s == OSC_T_CELLS) && t->ref == OSC_REF_NONE && t->elem == OSC_T_VOID &&
            t->len == 0 && t->sid == 0;
 }
+/* GPU kernels: pointer register of a global buffer parameter (length = next vreg, u32) */
+static bool gpu_elem(OscScalar e) { return e == OSC_T_U32 || e == OSC_T_F32; }
+static bool type_is_gbuf(const OscType *t) {
+    return (t->s == OSC_T_GVIEW || t->s == OSC_T_GEDIT) && t->ref == OSC_REF_NONE && gpu_elem(t->elem) && t->len == 0 &&
+           t->sid == 0;
+}
+/* GPU kernels: a block-shared array */
+static bool type_is_block(const OscType *t) {
+    return t->s == OSC_T_REF && t->ref == OSC_REF_BLOCK && gpu_elem(t->elem) && t->len >= 1 &&
+           t->len <= OSC_MAX_SHARED_LEN && t->sid == 0;
+}
+static bool type_is_s(const OscType *t, OscScalar s) { return type_is_scalar(t) && t->s == s; }
 static bool type_is_struct_ref(const OscType *t) { return type_is_ref(t) && t->sid != 0; }
 static bool type_is_array_ref(const OscType *t) { return type_is_ref(t) && t->sid == 0; }
 static bool type_eq(const OscType *a, const OscType *b) {
@@ -94,6 +112,7 @@ static bool ref_bindable(const OscType *dst, const OscType *src) {
 static bool canonical_for(OscScalar s, uint64_t v) {
     unsigned w = osc_scalar_width(s);
     if (s == OSC_T_BOOL) return v <= 1;
+    if (s == OSC_T_F32) return v <= 0xFFFFFFFFu;  /* any binary32 bit pattern */
     if (w == 64) return true;
     if (osc_scalar_signed(s)) {
         int64_t x = (int64_t)v, lo = -(1LL << (w - 1)), hi = (1LL << (w - 1)) - 1;
@@ -120,6 +139,10 @@ static int insn_uses(const OscInsn *in, int16_t *u) {
     case OSC_I_STORE: u[k++] = in->a; u[k++] = in->b; u[k++] = in->c; break;
     case OSC_I_SLOAD: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; break;
     case OSC_I_SSTORE: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; u[k++] = in->c; break;
+    case OSC_I_GLOAD: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; break;
+    case OSC_I_GSTORE: u[k++] = in->a; u[k++] = in->a + 1; u[k++] = in->b; u[k++] = in->c; break;
+    case OSC_I_SHFL: u[k++] = in->a; u[k++] = in->b; break;
+    case OSC_I_MAD: u[k++] = in->a; u[k++] = in->b; u[k++] = in->c; break;
     case OSC_I_FLOAD: u[k++] = in->a; if (in->b >= 0) u[k++] = in->b; break;
     case OSC_I_FSTORE: u[k++] = in->a; if (in->b >= 0) u[k++] = in->b; u[k++] = in->c; break;
     case OSC_I_CALL: for (int i = 0; i < in->nargs && i < OSC_MAX_PARAMS; i++) u[k++] = in->args[i]; break;
@@ -134,6 +157,7 @@ static int insn_def(const OscInsn *in) {
     case OSC_I_CAST: case OSC_I_ALLOC: case OSC_I_LOAD: case OSC_I_FLOAD: case OSC_I_SLOAD: return in->dst;
     case OSC_I_AOPEN: case OSC_I_AALLOC: return in->dst;
     case OSC_I_POPEN: case OSC_I_HALLOC: case OSC_I_HGEN: case OSC_I_HLOAD: return in->dst;
+    case OSC_I_GPU: case OSC_I_SHARED: case OSC_I_GLOAD: case OSC_I_SHFL: case OSC_I_MAD: return in->dst;
     case OSC_I_CALL: return in->dst;  /* may be -1 */
     default: return -1;
     }
@@ -162,10 +186,16 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
         break;
     case OSC_I_BIN: {
         NEED(VR(in->dst) && VR(in->a) && VR(in->b), "BIN bad vreg", fi, ii);
-        NEED(in->sub >= OSC_B_ADD && in->sub <= OSC_B_SHR, "BIN bad sub-op %u", fi, ii, in->sub);
+        NEED(in->sub >= OSC_B_ADD && in->sub <= OSC_B_MAX, "BIN bad sub-op %u", fi, ii, in->sub);
         const OscType *d = &T[in->dst], *a = &T[in->a], *b = &T[in->b];
         NEED(type_is_scalar(d) && type_eq(d, a), "BIN dst/a type mismatch", fi, ii);
-        if (in->sub == OSC_B_SHL || in->sub == OSC_B_SHR) {
+        if (a->s == OSC_T_F32) {
+            NEED(type_eq(a, b), "BIN operand type mismatch", fi, ii);
+            NEED(in->sub == OSC_B_ADD || in->sub == OSC_B_SUB || in->sub == OSC_B_MUL || in->sub == OSC_B_MIN ||
+                 in->sub == OSC_B_MAX, "f32 BIN sub-op %u not allowed", fi, ii, in->sub);
+        } else if (in->sub == OSC_B_MIN || in->sub == OSC_B_MAX) {
+            NEED(a->s == OSC_T_U32 && type_eq(a, b), "MIN/MAX need u32 or f32", fi, ii);
+        } else if (in->sub == OSC_B_SHL || in->sub == OSC_B_SHR) {
             NEED(osc_scalar_is_int(a->s), "shift of non-integer", fi, ii);
             NEED(type_is_scalar(b) && osc_scalar_is_int(b->s), "shift amount not integer", fi, ii);
         } else if (in->sub == OSC_B_AND || in->sub == OSC_B_OR || in->sub == OSC_B_XOR) {
@@ -180,7 +210,9 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
         const OscType *d = &T[in->dst], *a = &T[in->a];
         NEED(type_is_scalar(d) && type_eq(d, a), "UN type mismatch", fi, ii);
         if (in->sub == OSC_U_LNOT) NEED(a->s == OSC_T_BOOL, "LNOT needs bool", fi, ii);
-        else if (in->sub == OSC_U_NEG || in->sub == OSC_U_BNOT) NEED(osc_scalar_is_int(a->s), "NEG/BNOT need integer", fi, ii);
+        else if (in->sub == OSC_U_NEG) NEED(osc_scalar_is_int(a->s) || a->s == OSC_T_F32, "NEG needs a number", fi, ii);
+        else if (in->sub == OSC_U_BNOT) NEED(osc_scalar_is_int(a->s), "BNOT needs integer", fi, ii);
+        else if (in->sub >= OSC_U_EXP && in->sub <= OSC_U_SQRT) NEED(a->s == OSC_T_F32, "EXP/INV/RSQ/SQRT need f32", fi, ii);
         else return vfail(err, n, "func %d insn %u: UN bad sub-op %u", fi, ii, in->sub);
         break;
     }
@@ -192,8 +224,12 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
         break;
     case OSC_I_CAST:
         NEED(VR(in->dst) && VR(in->a), "CAST bad vreg", fi, ii);
-        NEED(type_is_scalar(&T[in->dst]) && osc_scalar_is_int(T[in->dst].s) &&
-             type_is_scalar(&T[in->a]) && osc_scalar_is_int(T[in->a].s), "CAST needs integer types", fi, ii);
+        if (T[in->dst].s == OSC_T_F32 || T[in->a].s == OSC_T_F32)  /* GPU kernels: u32 <-> f32 only */
+            NEED((type_is_s(&T[in->dst], OSC_T_F32) && type_is_s(&T[in->a], OSC_T_U32)) ||
+                 (type_is_s(&T[in->dst], OSC_T_U32) && type_is_s(&T[in->a], OSC_T_F32)), "f32 CAST needs u32 <-> f32", fi, ii);
+        else
+            NEED(type_is_scalar(&T[in->dst]) && osc_scalar_is_int(T[in->dst].s) &&
+                 type_is_scalar(&T[in->a]) && osc_scalar_is_int(T[in->a].s), "CAST needs integer types", fi, ii);
         break;
     case OSC_I_ALLOC:
         NEED(VR(in->dst) && VR(in->a), "ALLOC bad vreg", fi, ii);
@@ -254,14 +290,14 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
     }
     case OSC_I_LOAD:
         NEED(VR(in->dst) && VR(in->a) && VR(in->b), "LOAD bad vreg", fi, ii);
-        NEED(type_is_array_ref(&T[in->a]), "LOAD base not an array ref", fi, ii);
+        NEED(type_is_array_ref(&T[in->a]) || type_is_block(&T[in->a]), "LOAD base not an array ref", fi, ii);
         NEED(type_is_scalar(&T[in->b]) && osc_scalar_is_int(T[in->b].s), "LOAD index not integer", fi, ii);
         NEED(type_is_scalar(&T[in->dst]) && T[in->dst].s == T[in->a].elem, "LOAD dst type != elem", fi, ii);
         break;
     case OSC_I_STORE:
         NEED(VR(in->a) && VR(in->b) && VR(in->c), "STORE bad vreg", fi, ii);
-        NEED(type_is_array_ref(&T[in->a]) && (T[in->a].ref == OSC_REF_OWN || T[in->a].ref == OSC_REF_MUT),
-             "STORE through a shared borrow or non-ref", fi, ii);
+        NEED((type_is_array_ref(&T[in->a]) && (T[in->a].ref == OSC_REF_OWN || T[in->a].ref == OSC_REF_MUT)) ||
+             type_is_block(&T[in->a]), "STORE through a shared borrow or non-ref", fi, ii);
         NEED(type_is_scalar(&T[in->b]) && osc_scalar_is_int(T[in->b].s), "STORE index not integer", fi, ii);
         NEED(type_is_scalar(&T[in->c]) && T[in->c].s == T[in->a].elem, "STORE value type != elem", fi, ii);
         break;
@@ -297,6 +333,8 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
     case OSC_I_CALL: {
         NEED(in->callee >= 0 && in->callee < fi, "CALL to function %d not defined earlier", fi, ii, in->callee);
         const OscFunc *g = &u->funcs[in->callee];
+        NEED(g->kind == OSC_FN_HOST && f->kind == OSC_FN_HOST, "CALL-KERNEL: call into or out of a kernel", fi, ii);
+        NEED(in->nargs <= sizeof in->args / sizeof in->args[0], "CALL-ARITY: arguments exceed host call capacity", fi, ii);
         NEED(in->nargs == g->nparams, "CALL arity %u != %u", fi, ii, in->nargs, g->nparams);
         for (int k = 0; k < in->nargs; k++) {
             int a = in->args[k];
@@ -313,6 +351,40 @@ static int validate_insn(const OscUnit *u, int fi, const OscFunc *f, uint32_t ii
         else NEED(VR(in->dst) && type_eq(&T[in->dst], &g->ret), "CALL dst type != callee return", fi, ii);
         break;
     }
+    case OSC_I_GPU:
+        NEED(VR(in->dst) && type_is_s(&T[in->dst], OSC_T_U32), "GPU dst not u32", fi, ii);
+        NEED(in->sub >= OSC_G_THREAD && in->sub <= OSC_G_BATCHES, "GPU bad value %u", fi, ii, in->sub);
+        break;
+    case OSC_I_SHARED:
+        NEED(VR(in->dst) && type_is_block(&T[in->dst]), "SHARED dst not a block array", fi, ii);
+        break;
+    case OSC_I_GLOAD:
+    case OSC_I_GSTORE: {
+        bool ld = in->op == OSC_I_GLOAD;
+        const char *nm = ld ? "GLOAD" : "GSTORE";
+        NEED(VR(in->a) && VR(in->b), "%s bad vreg", fi, ii, nm);
+        NEED(type_is_gbuf(&T[in->a]) && VR(in->a + 1) && type_is_s(&T[in->a + 1], OSC_T_U32),
+             "%s base not a global buffer", fi, ii, nm);
+        NEED(type_is_s(&T[in->b], OSC_T_U32), "%s index not u32", fi, ii, nm);
+        int v = ld ? in->dst : in->c;
+        NEED(VR(v) && type_is_s(&T[v], T[in->a].elem), "%s value type != elem", fi, ii, nm);
+        if (!ld) NEED(T[in->a].s == OSC_T_GEDIT, "GSTORE into a view buffer", fi, ii);
+        break;
+    }
+    case OSC_I_SYNC:
+        break;
+    case OSC_I_SHFL:
+        NEED(in->sub == OSC_SH_DOWN, "SHFL bad sub-op %u", fi, ii, in->sub);
+        NEED(VR(in->dst) && VR(in->a) && VR(in->b), "SHFL bad vreg", fi, ii);
+        NEED((type_is_s(&T[in->a], OSC_T_U32) || type_is_s(&T[in->a], OSC_T_F32)) && type_eq(&T[in->dst], &T[in->a]),
+             "SHFL value not u32/f32", fi, ii);
+        NEED(type_is_s(&T[in->b], OSC_T_U32), "SHFL distance not u32", fi, ii);
+        break;
+    case OSC_I_MAD:
+        NEED(VR(in->dst) && VR(in->a) && VR(in->b) && VR(in->c), "MAD bad vreg", fi, ii);
+        NEED(type_is_s(&T[in->dst], OSC_T_F32) && type_is_s(&T[in->a], OSC_T_F32) && type_is_s(&T[in->b], OSC_T_F32) &&
+             type_is_s(&T[in->c], OSC_T_F32), "MAD needs f32", fi, ii);
+        break;
     case OSC_I_TRAP:
         NEED(in->imm >= OSC_TRAP_OVERFLOW && in->imm <= OSC_TRAP_MAX, "TRAP bad code", fi, ii);
         break;
@@ -342,14 +414,32 @@ static int validate_func(const OscAlloc *a, const OscUnit *u, int fi, char *err,
     if (!str_ok(f->name, sizeof f->name)) return vfail(err, n, "func %d: name not terminated", fi);
     if (!str_ok(f->requires_text, sizeof f->requires_text) || !str_ok(f->ensures_text, sizeof f->ensures_text))
         return vfail(err, n, "func %d: contract text not terminated", fi);

The diff is longer than this page shows; the raw diff has all of it.