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
omega-mv / gpu / driver / tests / q38_sass_emit.om
| 1 | note tests/q38_sass_emit.om: Stage 1 pure-Omega IR emitter for Qwen3.8-27B decode glue kernels. |
| 2 | note Composes after: gpu/nvidia/om/codegen/cg_dec_emit.om, gpu/nvidia/om/codegen/cg_dec.om. |
| 3 | note Emits binary IR records to stdout for Stage 2 (q38_sass_encode.om: bw_alloc + bw_enc_sm121): |
| 4 | note [u64 n_insns][288 x u64 vreg+uvreg widths][n_insns * 8 x u64 IR words] (all little-endian). |
| 5 | |
| 6 | fn put_u64 b edit uchar 8192 off ulong v ulong to void |
| 7 | for k ulong 8 |
| 8 | put b add off k uchar and shr v mul k 8 255 |
| 9 | end |
| 10 | end |
| 11 | |
| 12 | fn wr_all b view uchar 8192 n ulong to void |
| 13 | off = ulong 0 |
| 14 | while lt off n bound 1024 |
| 15 | r = write 1 b off sub n off |
| 16 | if le r 0 |
| 17 | trap 4 |
| 18 | end |
| 19 | off = add off ulong r |
| 20 | end |
| 21 | end |
| 22 | |
| 23 | fn wr_ir x view ulong 8192 m view ulong 512 n ulong to void |
| 24 | buf = new uchar 8192 0 |
| 25 | put_u64 buf 0 n |
| 26 | for i ulong 256 |
| 27 | put_u64 buf mul add i 1 8 get m add 64 i |
| 28 | end |
| 29 | for j ulong 32 |
| 30 | put_u64 buf mul add 257 j 8 get m add 320 j |
| 31 | end |
| 32 | wr_all buf 2312 |
| 33 | for i ulong n |
| 34 | for f ulong 8 |
| 35 | put_u64 buf mul f 8 get x add mul i 8 f |
| 36 | end |
| 37 | wr_all buf 64 |
| 38 | end |
| 39 | end |
| 40 | |
| 41 | fn emit_ir kind ulong mode ulong width ulong stride ulong to void |
| 42 | x = new ulong 8192 0 |
| 43 | m = new ulong 512 0 |
| 44 | a = or mode shl width 32 |
| 45 | rc = cg_dec kind a stride 0 x m |
| 46 | if ne rc 0 |
| 47 | trap 1 |
| 48 | end |
| 49 | n = get m 0 |
| 50 | if or eq n 0 gt n 1024 |
| 51 | trap 2 |
| 52 | end |
| 53 | wr_ir x m n |
| 54 | end |
| 55 | |
| 56 | fn main to int |
| 57 | emit_ir 2 4 5120 0 |
| 58 | emit_ir 2 5 5120 0 |
| 59 | emit_ir 3 0 17408 0 |
| 60 | emit_ir 5 0 14336 14336 |
| 61 | emit_ir 6 0 0 0 |
| 62 | emit_ir 4 0 0 0 |
| 63 | emit_ir 4 1 0 0 |
| 64 | ret 0 |
| 65 | end |