Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/2833cae24470c9eb # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/omega-mv#817 (code only) closed derived `2833cae24470c9eb` #817 Imported from GitHub aien-dev/omega-mv#817 (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 `07c78e3f7efc9ac9c63bc3ba65c1a74cbb563ab4` · Head `d0d794d0fe1fb281accba62c3f14cf31066fa427` ### Apply it ``` git checkout -b patch-2833cae24470c9eb 07c78e3f7efc9ac9c63bc3ba65c1a74cbb563ab4 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/2833cae24470c9eb.patch | git am ``` Raw patch (mbox) · 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 817 d0d794d0fe1fb281accba62c3f14cf31066fa427 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":817,"url":"https://github.com/aien-dev/omega-mv/pull/817","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:41Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index ffda09b20..3c1a148ec 100644 --- a/.crumb +++ b/.crumb @@ -42,68 +42,68 @@ "children": [ { "digest": "9f19f11674ca5dfc3c9c3ae35fe6106557aee9583210da13d257e1b9d88e052c", - "last_commit": "d863780eb", + "last_commit": "d863780e", "name": "calibration", "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "fb9721a8137db8b8d89869dc512f77bb656d3e6567c2fda241e21b77870b33d9", - "last_commit": "80e409a1f", + "digest": "0cb19d1e6dd7182ae03fcf264f279054d76ea56322437122e5b90d00706d1311", + "last_commit": "80e409a1", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { "digest": "536f7b8db9a92a1f586bad4379d47544a30d1b8e83c2d799c18e66cf8660c9ae", - "last_commit": "30bb116cc", + "last_commit": "30bb116c", "name": "doctrine", "purpose": "Directory doctrine. Purpose not yet described by a human." }, { "digest": "4947c0eb38550826cdfaba5d08384f3ebd284b82ab456ecf276617ce2ef998fd", - "last_commit": "43f25831b", + "last_commit": "43f25831", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, { "digest": "62b92244c52fa8af6f511012dee2967e98dff162cc1d8bf45d0b2f15cb0adc5f", - "last_commit": "450bbefd4", + "last_commit": "450bbefd", "name": "research", "purpose": "Directory research. Purpose not yet described by a human." }, { "digest": "8bbd5f74b01446007499a9a9be4e9f50f4364af0f578d9cdf26a2afd84e3bb63", - "last_commit": "faebae8c1", + "last_commit": "faebae8c", "name": "spec", "purpose": "Directory spec. Purpose not yet described by a human." }, { "digest": "c36621bc697f454b2d9eeb0258c7d3f356612cae45891905efa3ceb001d007fd", - "last_commit": "d41d61687", + "last_commit": "d41d6168", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { "digest": "d75dd95349e3cd5e180a91ec848d3e25ac9c3b693f96d4397c9646e37823cba9", - "last_commit": "45f7d7691", + "last_commit": "45f7d769", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, { "digest": "4e83dea21da137c30076c2dc0ca4f3a488f576f30a94e334558ad5ea523f3a6b", - "last_commit": "a50c3bd41", + "last_commit": "a50c3bd4", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:6e0949f91ab0352c63f7da31d9a95bc178cfc188bb15062a7efd1330d996e34b", - "compiled_at": "2026-10-26T17:46:27Z", + "children_root": "sha256:3905e729d45665b5bffac7cd92dbea15e1acd71325623418d26c8db3dad86615", + "compiled_at": "2026-10-26T18:10:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:e88d7fc9340129db2fbc4afc959f6a9cef879fa1143f8906b65878b119a05f25", + "digest": "sha256:d1f755e3387563065f7d55acddaa60340a7aa437a1d53eed39b51a065d0c05ce", "evidence_files": 12448, "evidence_root": "sha256:6a7f22f217cc5cfd8bf239c891f08fa4d4286883a3a43299addeb7bcf8dc3125", "files": 16990, - "generated_at_commit": "80e409a1fefede818e620f746120095e9a9bcf34", - "source_tree": "sha256:0b10f0a53b24f6c94a07266738d39939a02d5f191ceb1ab5ff5e20903980351a" + "generated_at_commit": "07c78e3f7efc9ac9c63bc3ba65c1a74cbb563ab4", + "source_tree": "sha256:07b9bbf2c0e468832a2af3d68a2d2907ab8874a15a4664c924d62be37c1a8983" }, "owner_lane": "", "provenance": { diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 658c5a99c..a6b742ca7 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -24,6 +24,7 @@ Every model below did real work. A model is listed only for work it did. The orc | Claude Opus 5.5 | Ionic-droplet reservoir (#440): pinned reference, CPU simulator and readout, `.mat` reader, Gate 2 comparison, benchmarks, timing and receipt | | Claude Fable 5.1 | CodeQL high-severity fixes in the OM-2 oracles: 0600 image creation in offsetof.c, fixture-name allowlist and truncation check in sha_qual.c | | Claude Opus 5.5 | Omega 1.0 roadmap: source-pinned readiness audit of the seeded compiler, IR, WebAssembly and bridge paths, milestone acceptance gates, tracking issues #790-#800, OM-2 contract files brought to main byte-identical, and stale status text corrected | +| Claude Opus 5.5 | omc OSC IR v7 producer: `global`/`text`/`new` regions, `get`/`put`/`len`, f32/f64 values, `bitcast`, conversion-at-operand-type, and `gate-ir-v7.sh` with hand-derived bytes, oracle check/run, refusals and mutants | This table starts with the numeric work on this branch. Earlier work in this repository is not yet attributed here; add rows only for work that can be traced to a model. diff --git a/docs/.crumb b/docs/.crumb index 1fdf3c65a..b45f59351 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -46,92 +46,92 @@ "children": [ { "digest": "640f6b7b818c769ab0dcd91437d58dd3251044084d2ae3785f000d30d2bb768a", - "last_commit": "a927bd6c2", + "last_commit": "a927bd6c", "name": "adr", "purpose": "Directory docs/adr. Purpose not yet described by a human." }, { "digest": "e7ac2460455a35b96b01dab649dcdc2cdf5bb4657bf230b91272c64fe1bf82cf", - "last_commit": "d48ab89e5", + "last_commit": "d48ab89e", "name": "autodiff", "purpose": "M21 OMEGA_AUTODIFF scope, op and error-contract table, status (not qualified)" }, { "digest": "7506b1a8659e6de84e1be31a281c8d046e4946de6ed29451155bb56cda5cb365", - "last_commit": "6637b32b6", + "last_commit": "6637b32b", "name": "brownian", "purpose": "Directory docs/brownian. Purpose not yet described by a human." }, { "digest": "1b01542d91e3b1c7c5263d6b393338a3d9d40e138a12ec833ce7852d83887ce2", - "last_commit": "5901baa51", + "last_commit": "5901baa5", "name": "crumbs", "purpose": "Directory docs/crumbs. Purpose not yet described by a human." }, { "digest": "e9baaaeec04be41a57c4a2d6a540b01a682c70d4db96cb4af4e1a9912a133aa9", - "last_commit": "55d05d6a5", + "last_commit": "55d05d6a", "name": "dual", "purpose": "DUAL (ARCH-0031) documents in omega: applicability experiment method and findings (APPLICABILITY" }, { "digest": "56a5a999ce726e90d89c1c88b9e20c81857c8e6ee82af8d651ac80ea70e2c46d", - "last_commit": "38a6a569b", + "last_commit": "38a6a569", "name": "estimation", "purpose": "Directory docs/estimation. Purpose not yet described by a human." }, { "digest": "8b926a045985692f116d9469af5aaa06d778bca78cf5d7e891e68c2486ed789e", - "last_commit": "8ec82485d", + "last_commit": "8ec82485", "name": "numeric", "purpose": "Directory docs/numeric. Purpose not yet described by a human." }, { "digest": "1a26b15f795aa3581a03400a21d5635e85c71f3f544fcc3676fa58064402c7ad", - "last_commit": "968734c7e", + "last_commit": "968734c7", "name": "osc", "purpose": "Directory docs/osc. Purpose not yet described by a human." }, { "digest": "645b6abb9d46a13dff6c9091d79acf0318fcfdc447a2dc50a3b70cd0dcfaa548", - "last_commit": "968734c7e", + "last_commit": "968734c7", "name": "polyglot", "purpose": "Directory docs/polyglot. Purpose not yet described by a human." }, { "digest": "46d3e2d59a468271e044ccd2398eb32345df6436c15eb6d8c703953c838023a9", - "last_commit": "dd67f6bd7", + "last_commit": "dd67f6bd", "name": "reservoir", "purpose": "Reservoir reference and contracts (omega#440): RESERVOIR_REFERENCE.md pins the authors' paper an" }, { "digest": "2ab37838f8694e5060a3789f08a16146996050af949fba329ed805429d85f695", - "last_commit": "f633e3430", + "last_commit": "f633e343", "name": "tensor", "purpose": "M20 OMEGA_TENSOR spec and qualification checklist" }, { "digest": "41ab5cf8617e9583dcda75292e1e851e1ec4187b69d5d00b5eb354f1ee55c9d5", - "last_commit": "54826a37f", + "last_commit": "54826a37", "name": "train", "purpose": "Directory docs/train. Purpose not yet described by a human." }, { "digest": "5db2869ff0b78866ad0ce38f77b262e81fdbc89408e94968491c4e6548177278", - "last_commit": "968734c7e", + "last_commit": "968734c7", "name": "turing", "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], "children_root": "sha256:c81d43c0c392dfec2b6ed5b38ba95ea7c592782b283950e32b777e7b9cfd9d61", - "compiled_at": "2026-10-26T17:46:27Z", + "compiled_at": "2026-10-26T18:10:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:fb9721a8137db8b8d89869dc512f77bb656d3e6567c2fda241e21b77870b33d9", + "digest": "sha256:0cb19d1e6dd7182ae03fcf264f279054d76ea56322437122e5b90d00706d1311", "evidence_files": 34, "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", "files": 135, - "generated_at_commit": "80e409a1fefede818e620f746120095e9a9bcf34", - "source_tree": "sha256:394853c505bc667018b51ac8e5ae0ac3c07572ea32a55ea635e7f0e7f3f8431e" + "generated_at_commit": "07c78e3f7efc9ac9c63bc3ba65c1a74cbb563ab4", + "source_tree": "sha256:030ef3aa8b59eaa2357bc39b838ab6e953ff063c64c5e559ac73f2fd7f1ccdad" }, "owner_lane": "", "provenance": { diff --git a/docs/one_layer/OMEGESE.md b/docs/one_layer/OMEGESE.md index 64c68c225..cf8c2c59d 100644 --- a/docs/one_layer/OMEGESE.md +++ b/docs/one_layer/OMEGESE.md @@ -891,9 +891,12 @@ fixed pools. GPU launch and model execution are separate, still-unqualified gate ## 11. OSC IR output (omc only, experimental checkpoint) -A leading line `ir`, before any other line, puts omc in IR mode: it writes OSC IR version 1 +A leading line `ir`, before any other line, puts omc in IR mode: it writes OSC IR (`spec/one-layer-format.md`) for a unit of up to 32 functions instead of AArch64 machine words, and -the AArch64 path is not taken. Every function is encoded in source order. A function may call an +the AArch64 path is not taken. A unit that uses no region and no float is written as version 1, +byte-identical to the scalar checkpoint; a unit with a `global`, `text` or `new` region, or an +`f32`/`f64` value, is written as version 7 (section 11.2). +Every function is encoded in source order. A function may call an **earlier** function (self and forward calls are error 3) with at most six arguments; a value-returning call composes as a value, a void call is a statement, and using one where the other is needed is error 7. Argument types are checked at compile time (error 7). `break` lowers to a @@ -906,8 +909,8 @@ the `else` boundary; redeclaring an in-scope name is error 10, and reading an out-of-scope name is error 3. Locals and parameters retain the native eight-byte name limit (13), while function names retain full matching up to 63 bytes. A reachable non-void function end is error 18; a void end -emits an implicit return. Missing function `end` is error 15. Unsupported -float parameter/result types are refused with error 9 before serialization. +emits an implicit return. Missing function `end` is error 15. A conversion +between `bool` and a float is error 9. Typed literals are range-checked (8). Parentheses remain unsupported in this scalar IR checkpoint, rather than being silently discarded. @@ -924,9 +927,9 @@ native path. `gate-ir.sh` checks all three against the C encoder and checker2. Arithmetic (`add` through `rem`) and shifts of booleans remain error 7. Limits, said plainly: scalar values, calls to earlier functions, at most 32 functions and 6 -parameters. IR mode refuses a `struct`, `global` or `text` declaration with error 9 and refuses a -float word, a host word, `continue`, `sizeof` or `offsetof` with error 3; it never skips a -declaration it cannot lower. `note` lines are skipped. Struct IR remains open. The gate needs the +parameters. IR mode refuses a `struct` declaration with error 9 and refuses a float intrinsic +(`fsqrt`, `fabs`, `fmin`, `fmax`), a host word, `continue`, `sizeof` or `offsetof` with error 3; +it never skips a declaration it cannot lower. `note` lines are skipped. Struct IR remains open. The gate needs the C-built oracles, so `seed/host/check.sh` runs it only when `build/omegese/omegese`, `build/omega_emit/omega_emit` and `build/checker2/checker2` exist, and says `SKIP` otherwise. @@ -1020,10 +1023,26 @@ with `512*480+1 -> 245761` (a monotone bit-removal fixed point). ### 11.2 Memory profile contract (IR v2 milestone) -This is a specification for the next seeded producer/backend extension, not -an assertion that the binaries above implement it. The authoritative wire -allocation and validation rules are in `spec/one-layer-format.md` section 10. -The milestone name does not repurpose OSC wire version 2. +omc's IR mode implements the producer half of this contract (OSC IR wire +version 7): `global`, `text`, `new` at a function's top level, `get`, `put`, +`len`, `f32`/`f64` values with `add`/`sub`/`mul`/`div`, comparisons and +conversions, and `bitcast` between equal-width integer and float types. +`seed/omc/gate-ir-v7.sh` checks hand-derived bytes, an independent oracle's +`check` and `run`, refusal codes and producer mutants. The wasm backend half +is separate work. The authoritative wire allocation and validation rules are +in `spec/one-layer-format.md` section 10. The milestone name does not +repurpose OSC wire version 2. + +Producer rules beyond the wire contract: `new` inside an `if`, `while` or +`for` body is error 9, so its `RINIT` dominates every access; a `bool` +region element is error 9; a `bool` conversion in a version 7 unit is error +9; a region name reused or shadowed is error 10 (a new local named like a +module region is error 7, as for any constant name); an array used as a +scalar, an integer literal mixed with a float, `rem`/shifts/`not` on floats +and a width-changing `bitcast` are error 7; more than 1024 regions is error +14. A conversion word converts its operand at the operand's own type, as on +the native path: `uint div x 2` with a `long` x divides in `long`, then +casts. The source spelling reuses native arrays: diff --git a/seed/omc/gate-ir-v7.sh b/seed/omc/gate-ir-v7.sh new file mode 100755 index 000000000..2afc5764d --- /dev/null +++ b/seed/omc/gate-ir-v7.sh @@ -0,0 +1,350 @@ +#!/bin/sh +# OSC IR v7 producer gate (spec/one-layer-format.md section 10, OMEGESE 11.2): omc in `ir` mode. +# Expected bytes below are derived field by field from spec 3.1/3.3/3.5/10.1/10.2/10.3, not copied from +# omc output; the float and little-endian encodings were computed with Wolfram (see the PR body). +# The independent referee is seed/wasm/v7/oracle.js (override with V7_ORACLE); node is required. +set -eu +cd "$(dirname "$0")/../.." +B=build/seed/irv7 +ORACLE=${V7_ORACLE:-seed/wasm/v7/oracle.js} +mkdir -p "$B" +fail() { printf 'FAIL %s\n' "$*"; echo RC=1; exit 1; } +[ -f "$ORACLE" ] || fail "oracle $ORACLE missing (set V7_ORACLE)" +command -v node > /dev/null || fail 'node missing' +seed/rung4/om4.bin < seed/omc/omc.om > "$B/stage1" +chmod +x "$B/stage1" +"$B/stage1" < seed/omc/omc.om > "$B/stage2" +chmod +x "$B/stage2" +cmp "$B/stage1" "$B/stage2" || fail 'stage1/stage2 differ' +echo "PASS fixpoint $(sha256sum "$B/stage2")" + +# Units: name, source, expected hex (comments after #), oracle script, expected oracle output. +unit() { printf '%s\n' "$2" > "$B/$1.om"; printf '%s' "$3" | sed 's/#.*//' | tr -d ' \n' > "$B/$1.hex"; printf '%s\n' "$4" > "$B/$1.run"; printf '%s\n' "$5" > "$B/$1.want"; echo "$1" >> "$B/units"; } +: > "$B/units" +M='4f53433149520007 00' # magic "OSC1IR\0", version 7, nstructs 0 +unit glob 'ir +global g uint 4 +fn f to uint +put g 1 7 +ret get g 1 +end' "$M +0100 01 67 04 00 ffff 04000000 00000000 # 1 region: g, u32, class 0, module owner, count 4, no data +0100 01 66 00 04 # 1 function f, 0 params, returns u32 +0300 05 04 04 # regs: r0 u64 index, r1 u32 value, r2 u32 load +0100 00000000 05000000 05000000 # 1 block: first 0, count 5; 5 insns +01 0000 0100000000000000 # CONST r0 = 1 +01 0100 0700000000000000 # CONST r1 = 7 +1f 0000 0000 0100 # RSTORE g, r0, r1 +1e 0200 0000 0000 # RLOAD r2, g, r0 +0f 0200 # RET r2 +0000 0000 # requires, ensures empty" 'call f +region g' 'f = 7 +region g 00000000070000000000000000000000' +unit text 'ir +text t "hi\n" +fn f to ulong +ret len t +end' "$M +0100 01 74 02 02 ffff 03000000 03000000 68690a # t: u8 text, count 3, data 'h' 'i' LF +0100 01 66 00 05 0100 05 +0100 00000000 02000000 02000000 +01 0000 0300000000000000 # len t: CONST r0 = 3 (u64) +0f 0000 +0000 0000" 'call f +region t' 'f = 3 +region t 68690a' +unit tget 'ir +text t "hi" +fn f to uchar +ret get t 1 +end' "$M +0100 01 74 02 02 ffff 02000000 02000000 6869 +0100 01 66 00 02 0200 05 02 +0100 00000000 03000000 03000000 +01 0000 0100000000000000 +1e 0100 0000 0000 # RLOAD r1, t, r0 +0f 0100 +0000 0000" 'call f' 'f = 105' +unit local 'ir +fn f to int +a = new int 3 int 5 +put a 2 int 9 +ret get a 2 +end' "$M +0100 01 61 08 01 0000 03000000 00000000 # a: i32, class 1 local, owner function 0, count 3 +0100 01 66 00 08 0400 08 05 08 08 +0100 00000000 07000000 07000000 +01 0000 0500000000000000 # CONST r0 = 5 (i32 init); constants lead the entry block (v1 rule) +01 0100 0200000000000000 +01 0200 0900000000000000 +21 0000 0000 # RINIT a, r0 +1f 0000 0100 0200 # RSTORE a, r1, r2 +1e 0300 0000 0100 # RLOAD r3, a, r1 +0f 0300 +0000 0000" 'call f' 'f = 9' +unit fadd 'ir +fn f x f32 to f32 +ret add x 1.5 +end' "$M +0000 # no regions; v7 because of f32 (tag 13) +0100 01 66 01 0d 0300 0d 0d 0d +0100 00000000 03000000 03000000 +01 0100 0000c03f00000000 # CONST r1 = f32 1.5 (0x3fc00000), upper half zero +03 01 0200 0000 0100 # BIN add r2 = r0 + r1 +0f 0200 +0000 0000" 'call f 0x3fc00000' 'f = 0x40400000' +unit fmul 'ir +fn f to f64 +ret mul 2.0f64 0.5f64 +end' "$M +0000 +0100 01 66 00 0e 0300 0e 0e 0e +0100 00000000 04000000 04000000 +01 0000 0000000000000040 # f64 2.0 = 0x4000000000000000 +01 0100 000000000000e03f # f64 0.5 = 0x3fe0000000000000 +03 03 0200 0000 0100 # BIN mul +0f 0200 +0000 0000" 'call f' 'f = 0x3ff0000000000000' +unit bitc 'ir +fn f to uint +ret bitcast uint 1.0f32 +end' "$M +0000 +0100 01 66 00 04 0200 0d 04 +0100 00000000 03000000 03000000 +01 0000 0000803f00000000 # f32 1.0 = 0x3f800000 +20 0100 0000 # BITCAST r1 (u32), r0 (f32) +0f 0100 +0000 0000" 'call f' 'f = 1065353216' +unit v1 'ir +fn f to uint +ret 3 +end' '4f53433149520001 0100 01 66 00 04 0100 04 0100 00000000 02000000 02000000 +01 0000 0300000000000000 0f 0000 0000 0000 # old-only unit stays version 1' 'call f' 'f = 3' + +# A conversion word converts an operation at its own type (as native): long division, then CAST to u32. +unit conv 'ir +fn f x long to uint +ret uint div x 2 +end' '4f53433149520001 0100 01 66 01 04 0400 09 09 09 04 +0100 00000000 04000000 04000000 +01 0100 0200000000000000 # CONST r1 = 2 (i64) +03 04 0200 0000 0100 # BIN div (36 - 32) r2 = r0 / r1 +06 0300 0200 # CAST r3 (u32) = r2 +0f 0300 0000 0000' 'call f 4294967298' 'f = 2147483649' + +refusals() { # compiler: prints one line per refusal case, PASS or BAD + while IFS='|' read -r name code; do + set +e + timeout 10 "$1" < "$B/r_$name.om" > "$B/r_$name.out" 2> /dev/null + crc=$? + set -e + if [ "$crc" = "$code" ]; then echo "PASS $name refused $code"; else echo "BAD $name exit $crc wanted $code"; fi + done < "$B/refusals" +} +: > "$B/refusals" +refuse() { printf '%s\n' "$3" > "$B/r_$1.om"; echo "$1|$2" >> "$B/refusals"; } +refuse text_put 20 'ir +text t "x" +fn f to void +put t 0 uchar 1 +end' +refuse get_oob 21 'ir +global g uint 4 +fn f to uint +ret get g 4 +end' +refuse put_oob 21 'ir +fn f to int +a = new int 2 int 0 +put a 2 int 1 +ret 0 +end' +refuse new_nested 9 'ir +fn f to int +if true +a = new int 3 int 5 +end +ret 0 +end' +refuse global_bool 9 'ir +global g bool 4 +fn f to int +ret 0 +end' +refuse new_bool 9 'ir +fn f to int +a = new bool 2 false +ret 0 +end' +refuse glob_dup 10 'ir +global g uint 4 +global g int 4 +fn f to int +ret 0 +end' +# a new local named like a module name is refused by ir_assign's existing rule (7), before ir_new +refuse local_shadow 7 'ir +global a uint 4 +fn f to int +a = new int 3 int 5 +ret 0 +end' +refuse glob_after_local 10 'ir +fn f to int +a = new int 3 int 5 +ret 0 +end +global a uint 4' +refuse glob_long 13 'ir +global abcdefghi uint 4 +fn f to int +ret 0 +end' +refuse glob_count 23 'ir +global g uchar 16777217 +fn f to int +ret 0 +end' +{ printf 'ir\n'; for i in 1 2 3 4 5 6 7 8 9; do printf 'global g%s ulong 16777216\n' "$i"; done; printf 'fn f to int\nret 0\nend\n'; } > "$B/r_glob_pool.om" +echo 'glob_pool|23' >> "$B/refusals" +refuse local_pool 23 'ir +fn f to int +a = new ulong 524288 ulong 0 +b = new uchar 1 uchar 0 +ret 0 +end' +{ printf 'ir\n'; i=0; while [ $i -lt 1025 ]; do printf 'global g%s uchar 1\n' $i; i=$((i+1)); done; printf 'fn f to int\nret 0\nend\n'; } > "$B/r_regions.om" +echo 'regions|14' >> "$B/refusals" +refuse glob_scalar 7 'ir +global g uint 4 +fn f to uint +ret g +end' +refuse local_scalar 7 'ir +fn f to int +a = new int 3 int 5 +a = int 1 +ret 0 +end' +refuse idx_float 7 'ir +global g uint 4 +fn f to uint +ret get g 1.0f32 +end' +refuse put_type 7 'ir +global g uint 4 +fn f to void +put g 0 int 1 +end' +refuse new_type 7 'ir +fn f to int +a = new int 3 uint 5 +ret 0 +end' +refuse bare_int_float 7 'ir +fn f x f32 to f32 +ret add x 1 +end' +refuse float_rem 7 'ir +fn f x f64 to f64 +ret rem x x +end' +refuse float_not 7 'ir +fn f x f32 to f32 +ret not x +end' +refuse float_bool 9 'ir +fn f x f32 to bool +ret bool x +end' +refuse v7_bool_cast 9 'ir +global g uint 1 +fn f b bool to uint +ret uint b +end' +refuse bitc_width 7 'ir +fn f to ulong +ret bitcast ulong 1.0f32 +end' +refuse bitc_bare 11 'ir +fn f to uint +ret bitcast uint 1 +end' +refuse bitc_bool 7 'ir +fn f b bool to uchar +ret bitcast uchar b +end' +refuse fsqrt 3 'ir +fn f x f64 to f64 +ret fsqrt x +end' +refuse no_array 3 'ir +fn f to uint +ret get zz 0 +end' +refuse text_escape 22 'ir +text t "a\q" +fn f to int +ret 0 +end' +refuse conv_bool 7 'ir +fn f x uint to uint +ret uint eq x 1 +end' +refuse struct 9 'ir +struct S a uchar end +fn f to int +ret 0 +end' + +suite() { # compiler: golden bytes, oracle check and run; prints PASS/BAD lines + while read -r u; do + set +e + timeout 10 "$1" < "$B/$u.om" > "$B/$u.ir" 2> /dev/null + crc=$? + set -e + if [ "$crc" != 0 ]; then echo "BAD $u omc exit $crc"; continue; fi + got=$(od -An -v -tx1 "$B/$u.ir" | tr -d ' \n') + if [ "$got" = "$(cat "$B/$u.hex")" ]; then echo "PASS $u bytes"; else echo "BAD $u bytes"; fi + want=$(cut -c16 "$B/$u.hex") + chk=$(node "$ORACLE" check "$B/$u.ir" || true) + if [ "$chk" = "ACCEPT v$want" ]; then echo "PASS $u oracle $chk"; else echo "BAD $u oracle $chk"; fi + node "$ORACLE" run "$B/$u.ir" "$B/$u.run" > "$B/$u.got" 2>&1 || true + if cmp -s "$B/$u.got" "$B/$u.want"; then echo "PASS $u run"; else echo "BAD $u run $(tr '\n' ' ' < "$B/$u.got")"; fi + done < "$B/units" +} + +suite "$B/stage2" > "$B/suite.log" +refusals "$B/stage2" >> "$B/suite.log" +cat "$B/suite.log" +nbad=$(grep -c '^BAD' "$B/suite.log" || true) +npass=$(grep -c '^PASS' "$B/suite.log" || true) +[ "$nbad" = 0 ] || fail "$nbad checks failed" +nu=$(wc -l < "$B/units"); nr=$(wc -l < "$B/refusals") + +# Mutants of the producer, each compiled by om4: the suite above must catch every one. +mutant() { # name pattern replacement + [ "$(grep -c "$2" seed/omc/omc.om)" = 1 ] || fail "mutant $1 pattern not unique" + sed "s/$2/$3/" seed/omc/omc.om > "$B/m_$1.om" + seed/rung4/om4.bin < "$B/m_$1.om" > "$B/m_$1" || fail "mutant $1 did not compile" + chmod +x "$B/m_$1" + { suite "$B/m_$1"; refusals "$B/m_$1"; } > "$B/m_$1.log" + k=$(grep -c '^BAD' "$B/m_$1.log" || true) + [ "$k" != 0 ] || fail "mutant $1 survived" + echo "CAUGHT $1: $k failing checks; first: $(grep -m1 '^BAD' "$B/m_$1.log")" +} +mutant no_rinit '^ir_op 33 g v 0 0$' 'note mutant' +mutant owner '^ow = sub get irf_n 0 1$' 'ow = get irf_n 0' +mutant wire_tag '^emitb uchar ir_wt ulong get ir_rty i$' 'emitb get ir_rty i' +mutant version '^emitb 7$' 'emitb 1' +mutant bound '^if ge get ir_cm i get rg_n g$' 'if gt get ir_cm i get rg_n g' +mutant convert '^put ir_cx 0 1$' 'put ir_cx 0 0' +# The oracle on its own must refuse the RINIT-less and wrong-owner units (not only the byte goldens). +for m in no_rinit owner; do + "$B/m_$m" < "$B/local.om" > "$B/m_$m.ir" + r=$(node "$ORACLE" check "$B/m_$m.ir" || true) + case "$r" in REFUSE*) echo "PASS oracle refuses $m unit: $r" ;; *) fail "oracle accepted $m unit: $r" ;; esac +done +echo "IR_V7_PRODUCER $nu units ($((nu * 3)) byte/oracle/run checks) + $nr refusals; $npass PASS; 6 mutants caught" +echo RC=0 diff --git a/seed/omc/gate-ir.sh b/seed/omc/gate-ir.sh index d372f77e3..9a9655667 100644 --- a/seed/omc/gate-ir.sh +++ b/seed/omc/gate-ir.sh @@ -49,19 +49,21 @@ struct S a uchar end fn main to int ret 0 end' -ir_refuse global_decl 9 'ir -global g uchar 4 +# global, text and floats lower to v7 since gate-ir-v7.sh; these keep the refusals v7 still owes. +ir_refuse global_bool 9 'ir +global g bool 4 fn main to int ret 0 end' -ir_refuse text_decl 9 'ir +ir_refuse text_put 20 'ir text t "x" fn main to int +put t 0 uchar 1 ret 0 end' -ir_refuse float_use 3 'ir +ir_refuse float_intrinsic 3 'ir fn main to int -x = f64 1.0 +x = fsqrt 1.0f64 ret 0 end' ir_refuse continue_use 3 'ir @@ -318,11 +320,11 @@ if eq a 0 ret 1 end end' -ir_refuse float_param 9 'ir -fn f a f64 to f64 -ret a +ir_refuse float_bool 9 'ir +fn f a f64 to bool +ret bool a end' -ir_refuse float_ret 9 'ir +ir_refuse float_ret 7 'ir fn f a uint to f64 ret a end' diff --git a/seed/omc/omc.om b/seed/omc/omc.om index 4e7174b41..efaa92fa3 100644 --- a/seed/omc/omc.om +++ b/seed/omc/omc.om @@ -10064,7 +10064,8 @@ put fr q 5 put fr add q 1 ulong get nm_reg sub e 1 put fr add q 2 e end -note ---- R6 IR. A leading line `ir` writes OSC IR version 1. The AArch64 path is not taken. +note ---- R6 IR. A leading line `ir` writes OSC IR: version 1, or version 7 (spec section 10) exactly when the +note unit has a region, a float type or an opcode 30..33. The AArch64 path is not taken. note Worksheet ir_match.py matched omega_emit on the 10 dev programs; this is that algorithm. global ir_rty uchar 64 @@ -10124,6 +10125,28 @@ note per open block frame, the local count when it opened (names bound inside go global ir_fnn ulong 8 note ir_bbig: tbig of the bare number in ir_bare, for the range check once its type is known (error 8). global ir_bbig ulong 1 +note v7 regions in source order (spec 10.1): name (input start, length, packed word), element (internal +note type 2..11), class (0 global, 1 local array, 2 text), owner, count, and a text's raw source span. +global rg_ns ulong 1024 +global rg_nl ulong 1024 +global rg_w ulong 1024 +global rg_ty uchar 1024 +global rg_cl uchar 1024 +global rg_ow ulong 1024 +global rg_n ulong 1024 +global rg_tp ulong 1024 +global rg_tl ulong 1024 +global ir_nrg ulong 1 +note ir_v7: the unit needs version 7. ir_bcst: a CAST from or to bool was written (excluded from v7 CAST). +global ir_v7 ulong 1 +global ir_bcst ulong 1 +note pool bytes so far: module globals (1 GiB) and the current function's local arrays (4 MiB) +global ir_gby ulong 1 +global ir_lby ulong 1 +note per local: its region when the local is an array (its ir_nrr is then 255, never a register) +global ir_nar ulong 32 +note ir_cx: the next ir_val reads the operand of a conversion word (see ir_vchk); ir_val clears it. +global ir_cx ulong 1 fn ir_lead to ulong p = ulong 0 @@ -10179,6 +10202,9 @@ fail 14 end put ir_rty r uchar ty put ir_nreg 0 add r 1 +if and ge ty 10 le ty 11 +put ir_v7 0 1 +end ret r end @@ -10213,6 +10239,9 @@ put ir_ob n b put ir_oc n c put ir_od n d put ir_obl n get ir_cur 0 +if ge k 30 +put ir_v7 0 1 +end put ir_no 0 add n 1 end @@ -10306,8 +10335,8 @@ end ir_newname w s l end -note ir_type: a type word IR v1 lowers: 1 .. 9, or void (76) when isret is 1. A float, a view / edit array or -note void elsewhere is error 9 (as typeword in IR mode); no word is 4; another word 16. +note ir_type: a scalar type word: 1 .. 9, f32 / f64 as internal 10 / 11 (v7), or void (76) when isret is 1. +note A view / edit array or void elsewhere is error 9 (as typeword in IR mode); no word is 4; another word 16. fn ir_type isret ulong to ulong tok if or eq get tk 0 0 eq get tk 0 3 @@ -10323,7 +10352,10 @@ end if and eq c 76 eq isret 1 ret c end -if or or eq c 76 eq c 88 eq c 89 +if or eq c 88 eq c 89 +ret sub c 78 +end +if eq c 76 fail 9 end if or eq c 57 eq c 58 @@ -10467,9 +10499,92 @@ end if eq op 15 ir_w16 get ir_oa i end +if or eq op 30 eq op 31 +ir_w16 get ir_oa i +ir_w16 get ir_ob i +ir_w16 get ir_oc i +end +if or eq op 32 eq op 33 +ir_w16 get ir_oa i +ir_w16 get ir_ob i +end +end +i = add i 1 +end +end + +note ir_wt: an internal type as its wire tag: f32 10 -> 13, f64 11 -> 14 (spec 10.3); 1 .. 9 unchanged. +fn ir_wt t ulong to ulong +if eq t 10 +ret 13 +end +if eq t 11 +ret 14 +end +ret t +end + +note ir_tdec: decode the text literal bytes p .. e (escapes \n \t \\ \", any other is error 22, as s_text) +note -> the byte count; em 1 also writes the bytes. +fn ir_tdec p ulong e ulong em ulong to ulong +q = p +n = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge q e +go = false +else +b = get inp q +q = add q 1 +if eq b 92 +b = get inp q +q = add q 1 +if eq b 110 +b = uchar 10 +else +if eq b 116 +b = uchar 9 +else +if and ne b 92 ne b 34 +fail 22 +end +end +end +end +if eq em 1 +emitb b +end +n = add n 1 +end +m = add m 1 +end +end +ret n end + +note ir_wreg: region g's record: name, element tag, class, owner, count, initial length and data (spec 10.1). +fn ir_wreg g ulong to void +l = get rg_nl g +emitb uchar l +p = get rg_ns g +i = ulong 0 +while lt i l +emitb get inp add p i i = add i 1 end +emitb uchar ir_wt ulong get rg_ty g +emitb get rg_cl g +ir_w16 get rg_ow g +ir_w32 get rg_n g +if eq get rg_cl g 2 +ir_w32 get rg_n g +q = get rg_tp g +n = ir_tdec q add q get rg_tl g 1 +else +ir_w32 0 +end end fn ir_record to void @@ -10484,12 +10599,12 @@ emitb uchar get ir_npar 0 if eq get ir_ret 0 76 emitb 0 else -emitb uchar get ir_ret 0 +emitb uchar ir_wt get ir_ret 0 end ir_w16 get ir_nreg 0 i = ulong 0 while lt i get ir_nreg 0 -emitb get ir_rty i +emitb uchar ir_wt ulong get ir_rty i i = add i 1 end ir_layout @@ -10535,7 +10650,8 @@ put irrlen 0 add base n put irnf 0 add get irnf 0 1 end -note ir_encode: header (magic, version 1, nfuncs) followed by every collected function record. +note ir_encode: header (magic, version, [v7: nstructs 0, the region table], nfuncs) followed by every +note collected function record. A v7 unit with a bool CAST is refused (error 9, spec 10.3). fn ir_encode to void put oc 0 0 emitb 79 @@ -10545,7 +10661,24 @@ emitb 49 emitb 73 emitb 82 emitb 0 +if ne get ir_nrg 0 0 +put ir_v7 0 1 +end +if eq get ir_v7 0 0 emitb 1 +else +if ne get ir_bcst 0 0 +fail 9 +end +emitb 7 +emitb 0 +ir_w16 get ir_nrg 0 +g = ulong 0 +while lt g get ir_nrg 0 +ir_wreg g +g = add g 1 +end +end ir_w16 get irnf 0 i = ulong 0 while lt i get irrlen 0 @@ -10636,11 +10769,15 @@ r = ir_lit get nm_addr sub e 1 t ir_set 65534 r t ret end +fail 7 end put ir_miss 0 1 ret end r = ulong get ir_nrr sub e 1 +if eq r 255 +fail 7 +end ir_set 65534 r ulong get ir_rty r end @@ -10653,6 +10790,9 @@ ty = get ir_vt 0 if and eq c 49 eq ty 1 fail 7 end +if and eq c 50 ge ty 10 +fail 7 +end d = dst if or eq dst 65534 eq dst 65535 d = ir_newreg ty @@ -10692,7 +10832,7 @@ fail 7 end end else -if ge lty 10 +if and ge lty 10 and ge c 37 le c 40 fail 7 end if and eq isb2 0 ne ty2 lty @@ -10704,8 +10844,7 @@ end end right = get ir_rr 0 if ne isb2 0 -range get ir_bare 0 lty get ir_bbig 0 -right = ir_lit get ir_bare 0 lty +right = ir_bres lty end if ge c 43 d = dst @@ -10727,18 +10866,38 @@ put ir_vt 0 lty put ir_isb 0 0 end +note ir_bres: the deferred bare number as a constant of type ty: an integer (range, error 8) or a float +note literal (float types only); an integer in a float context or a float in an integer one is error 7. +fn ir_bres ty ulong to ulong +if eq get ir_isb 0 2 +if lt ty 10 +fail 7 +end +ret ir_lit fspan ty get ir_bare 0 ty +end +if ge ty 10 +fail 7 +end +range get ir_bare 0 ty get ir_bbig 0 +ret ir_lit get ir_bare 0 ty +end + fn ir_bin c ulong dst ulong to void ir_val 65534 0 if ne get ir_isb 0 0 mag = get ir_bare 0 bg = get ir_bbig 0 +kb = get ir_isb 0 ir_val 65534 0 if ne get ir_isb 0 0 fail 11 end ty = get ir_vt 0 -range mag ty bg -left = ir_lit mag ty +put ir_bare 0 mag +put ir_bbig 0 bg +put ir_isb 0 kb +left = ir_bres ty +put ir_isb 0 0 ir_bin_done left ty c dst ret end @@ -10747,15 +10906,40 @@ lty = get ir_vt 0 ir_bin_r left lty c dst end +note ir_cast: a type word as a typed literal or a conversion (MOV for the same type, else CAST). An operation +note operand keeps its own type and is converted (as native; bool still needs its exact type). A float word +note reads its operand untyped: a bare float literal becomes that float constant, a bare integer a long +note constant converted (as native). A conversion between bool and a float is error 9. fn ir_cast c ulong dst ulong to void -ir_val 65534 c -if ne get ir_isb 0 0 -r = ir_lit get ir_bare 0 c +e = c +if ge c 10 +e = ulong 0 +end +put ir_cx 0 1 +ir_val 65534 e +if eq get ir_isb 0 2 +r = ir_lit fspan c get ir_bare 0 c ir_set dst r c ret end src = get ir_rr 0 sty = get ir_vt 0 +if ne get ir_isb 0 0 +k = c +if ge c 10 +k = ulong 9 +range get ir_bare 0 9 get ir_bbig 0 +end +src = ir_lit get ir_bare 0 k +sty = k +if lt c 10 +ir_set dst src c +ret +end +end +if or and eq sty 1 ge c 10 and ge sty 10 eq c 1 +fail 9 +end if and eq sty c eq dst 65534 put ir_rr 0 src put ir_vt 0 c @@ -10770,22 +10954,350 @@ if eq sty c ir_op 2 d src 0 0 else ir_op 6 d src 0 0 +if or eq sty 1 eq c 1 +put ir_bcst 0 1 +end end put ir_rr 0 d put ir_vt 0 c put ir_isb 0 0 end +note ---- v7 memory (spec 10, OMEGESE 11.2): regions, RLOAD / RSTORE / RINIT / BITCAST ---- +note ir_rname: a region name is ASCII without a dot (spec 10.1), else error 16. +fn ir_rname p ulong l ulong to void +i = ulong 0 +while lt i l +b = get inp add p i +if or eq b 46 ge b 127 +fail 16 +end +i = add i 1 +end +end + +note ir_addrg: append region (packed name w, input p / l, element ty, class cl, count n) -> its ID. The +note owner is the current function for a local array, else 65535. At most 1024 regions (error 14). +fn ir_addrg w ulong p ulong l ulong ty ulong cl ulong n ulong to ulong +g = get ir_nrg 0 +if ge g 1024 +fail 14 +end +ir_rname p l +put rg_w g w +put rg_ns g p +put rg_nl g l +put rg_ty g uchar ty +put rg_cl g uchar cl +ow = ulong 65535 +if eq cl 1 +ow = sub get irf_n 0 1 +end +put rg_ow g ow +put rg_n g n +put rg_tp g 0 +put rg_tl g 0 +put ir_nrg 0 add g 1 +ret g +end + +note ir_topnm: the name of a global or a text (16 not a word or a keyword, 13 over 8 bytes, 10 in use). A +note module region may not take the name of an earlier function's local array either (spec 10.1, 10). +fn ir_topnm to ulong +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +put ir_nn 0 0 +ir_newname w get ts 0 get tl 0 +g = ulong 0 +while lt g get ir_nrg 0 +if and eq get rg_cl g 1 eq get rg_w g w +fail 10 +end +g = add g 1 +end +ret w +end + +note ir_glob: global NAME T N, a module region (class 0) of N zeroed elements; T is not bool (9); pools +note total at most 1 GiB (23, as s_global). +fn ir_glob to void +w = ir_topnm +p = get ts 0 +l = get tl 0 +ty = ir_type 0 +if eq ty 1 +fail 9 +end +n = lenval 16 +arrlen n +by = shl shr add shl n tlog ty 15 4 4 +s = add get ir_gby 0 by +if gt s 1073741824 +fail 23 +end +put ir_gby 0 s +g = ir_addrg w p l ty 0 n +addname w 0 ty n 4 g +put nglob 0 get nn 0 +eol +end + +note ir_text: text NAME "...", a read-only u8 region (class 2) holding the decoded bytes, no NUL. +fn ir_text to void +w = ir_topnm +p = get ts 0 +l = get tl 0 +tok +if ne get tk 0 4 +fail 16 +end +q = get tw 0 +ql = get tl 0 +n = ir_tdec q add q ql 0 +g = ir_addrg w p l 2 2 n +put rg_tp g q +put rg_tl g ql +addname w 0 2 n 5 g +put nglob 0 get nn 0 +eol +end + +note ir_arr: an array name (as arrname: 4 missing, 16 not a word, 13 over 8 bytes, 3 unknown, 7 a scalar +note or constant) -> its region: a local array, a global or a text. +fn ir_arr to ulong +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if eq kw w 193 +fail 9 +end +e = ir_find w get tl 0 +if ne e 0 +if ne get ir_nrr sub e 1 255 +fail 7 +end +ret get ir_nar sub e 1 +end +e = findname w +if eq e 0 +fail 3 +end +k = ulong get nm_kind sub e 1 +if or eq k 4 eq k 5 +ret get nm_addr sub e 1 +end +fail 7 +ret 0 +end + +note ir_idx: an index (a bare number is a ulong) -> its register; bool or float is error 7 (spec 10.2). +fn ir_idx to ulong +ir_val 65534 5 +t = get ir_vt 0 +if or eq t 1 ge t 10 +fail 7 +end +ret get ir_rr 0 +end + +note ir_ixk: a constant index (register r is a constant) must be below region g's count (error 21). +fn ir_ixk r ulong g ulong to void +i = ulong 0 +while lt i get ir_nc 0 +if eq ulong get ir_cr i r +if ge get ir_cm i get rg_n g +fail 21 +end +end +i = add i 1 +end +end + +note ir_get: get A i -> RLOAD into a register of A's element type. +fn ir_get dst ulong to void +g = ir_arr +x = ir_idx +ir_ixk x g +ty = ulong get rg_ty g +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg ty +end +ir_op 30 d g x 0 +put ir_rr 0 d +put ir_vt 0 ty +put ir_isb 0 0 +end + +note ir_put: put A i v -> RSTORE; a text is error 20, v must have A's element type (7). +fn ir_put to void +g = ir_arr +if eq get rg_cl g 2 +fail 20 +end +x = ir_idx +ty = ulong get rg_ty g +ir_val 65534 ty +if ne get ir_vt 0 ty +fail 7 +end +v = get ir_rr 0 +ir_ixk x g +eol +ir_op 31 g x v 0 +end + +note ir_bitc: bitcast T v -> BITCAST: v typed (a bare number is 11), neither bool nor of another width (7). +fn ir_bitc dst ulong to void +tt = ir_type 0 +ir_val 65534 0 +if ne get ir_isb 0 0 +fail 11 +end +ft = get ir_vt 0 +if or eq ft 1 ne twid ft twid tt +fail 7 +end +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg tt +end +ir_op 32 d get ir_rr 0 0 0 +put ir_rr 0 d +put ir_vt 0 tt +put ir_isb 0 0 +end + +note ir_isnew: the next word is new (then consumed), else the position is restored. +fn ir_isnew to ulong +c0 = get cur 0 +tok +if and eq get tk 0 1 eq ir_kwt 84 +ret 1 +end +put cur 0 c0 +if eq get tk 0 0 +put line 0 sub get line 0 1 +end +ret 0 +end + +note ir_new: x = new T N v, a local array (class 1) in the function's outermost block only (9); T not bool +note (9); local arrays total at most 4 MiB per function (23, as sa_arr); v has type T (7). RINIT fills it. +fn ir_new w ulong p ulong l ulong to void +if gt get ir_nf 0 1 +fail 9 +end +ty = ir_type 0 +if eq ty 1 +fail 9 +end +n = lenval 16 +arrlen n +by = shl shr add shl n tlog ty 15 4 4 +s = add get ir_lby 0 by +if gt s 4194304 +fail 23 +end +put ir_lby 0 s +ir_val 65534 ty +if ne get ir_vt 0 ty +fail 7 +end +v = get ir_rr 0 +eol +g = ir_addrg w p l ty 1 n +ir_op 33 g v 0 0 +ir_bind w 255 +put ir_nar sub get ir_nn 0 1 g +end + +note ir_flt: a float literal (native rules): no suffix and no context is deferred as a bare float (ir_isb 2, +note its packed span in ir_bare); a non-float context or a suffix other than the context is error 7. +fn ir_flt dst ulong exp ulong to void +fparse get ts 0 get tl 0 +t = ulong 0 +if eq get fsuf 0 0 +if eq exp 0 +put ir_bare 0 add mul get ts 0 64 get tl 0 +put ir_isb 0 2 +ret +end +if lt exp 10 +fail 7 +end +t = exp +else +t = ulong 10 +if eq get fsuf 0 2 +t = ulong 11 +end +if and ne exp 0 ne exp t +fail 7 +end +end +r = ir_lit fbits t t +ir_set dst r t +end + +note ir_mem: get A i (RLOAD), len A (its count as a ulong constant) or bitcast T v (BITCAST). +fn ir_mem c ulong dst ulong to void +if eq c 51 +ir_get dst +end +if eq c 52 +g = ir_arr +r = ir_lit get rg_n g 5 +ir_set dst r 5 +end +if eq c 90 +ir_bitc dst +end +end + +note ir_vchk: an operation's result type must be the context type exp (7), unless cx: the operation is the +note operand of a conversion word, which converts it (native) between non-bool types. +fn ir_vchk exp ulong cx ulong to void +t = get ir_vt 0 +if or eq exp 0 eq t exp +ret +end +if and eq cx 1 and ne t 1 ne exp 1 +ret +end +fail 7 +end + fn ir_val dst ulong exp ulong to void +cx = get ir_cx 0 +put ir_cx 0 0 put ir_isb 0 0 put ir_miss 0 0 tok if or eq get tk 0 0 eq get tk 0 3 fail 4 end -if or eq get tk 0 4 eq get tk 0 5 +if eq get tk 0 4 fail 9 end +if eq get tk 0 5 +ir_flt dst exp +ret +end if eq get tk 0 2 if eq exp 0 put ir_bare 0 get tw 0 @@ -10793,6 +11305,9 @@ put ir_bbig 0 get tbig 0 put ir_isb 0 1 ret end +if ge exp 10 +fail 7 +end range get tw 0 exp get tbig 0 r = ir_lit get tw 0 exp ir_set dst r exp @@ -10803,18 +11318,23 @@ if and ge c 1 le c 9 ir_cast c dst ret end +if or eq c 88 eq c 89 +ir_cast sub c 78 dst +ret +end +if or or eq c 51 eq c 52 eq c 90 +ir_mem c dst +ir_vchk exp cx +ret +end if and ge c 33 le c 48 ir_bin c dst -if and ne exp 0 ne get ir_vt 0 exp -fail 7 -end +ir_vchk exp cx ret end if or eq c 49 eq c 50 ir_un c dst -if and ne exp 0 ne get ir_vt 0 exp -fail 7 -end +ir_vchk exp cx ret end if eq c 55 @@ -11019,7 +11539,7 @@ end w = get tw 0 ir_newloc w get ts 0 get tl 0 ty = ir_type 0 -if eq ty 1 +if or eq ty 1 ge ty 10 fail 7 end z = ir_lit 0 ty @@ -11097,8 +11617,9 @@ ir_callop 65535 j np eol end -note ir_assign: name [=] value for a local in scope, a void call, or a new typed local (a new name that is -note a keyword, constant, local or function is refused; a bare number has no type, error 11). +note ir_assign: name [=] value for a local in scope, a void call, a new typed local, or name = new T N v (a +note new name that is a keyword, constant, local or function is refused; a bare number has no type, error +note 11; an array name is not a scalar, error 7). fn ir_assign w ulong to void p = get ts 0 l = get tl 0 @@ -11116,6 +11637,9 @@ end e = ir_find w l if ne e 0 r = ulong get ir_nrr sub e 1 +if eq r 255 +fail 7 +end ir_val r ulong get ir_rty r if ne get ir_vt 0 ulong get ir_rty r fail 7 @@ -11139,6 +11663,10 @@ fail 7 end end ir_newloc w p l +if ne ir_isnew 0 +ir_new w p l +ret +end ir_val 65535 0 if ne get ir_isb 0 0 fail 11 @@ -11194,7 +11722,7 @@ put ir_dead 0 1 end note ir_stmt: one line. The end of the input inside a function is error 15; a line starting with a number -note is 16; a note is skipped even after the path ended; a statement IR v1 does not lower is 9. +note is 16; a note is skipped even after the path ended; a statement the IR does not lower is 9. fn ir_stmt to ulong tok if eq get tk 0 0 @@ -11259,7 +11787,11 @@ if eq c 97 note continue keeps its documented IR refusal, error 3 (gate-ir.sh continue_use) fail 3 end -if or eq c 80 eq c 82 +if eq c 80 +ir_put +ret 0 +end +if eq c 82 fail 9 end if or or or eq c 78 eq c 79 eq c 81 eq c 85 @@ -11315,6 +11847,7 @@ put irf_n 0 add fcur 1 put ir_ns 0 get ts 0 put ir_nl 0 get tl 0 put ir_nreg 0 0 +put ir_lby 0 0 put ir_nc 0 0 put ir_nb 0 0 put ir_nord 0 0 @@ -11339,6 +11872,9 @@ end put ir_ret 0 ir_type 1 eol put irf_ret fcur uchar get ir_ret 0 +if and ge get ir_ret 0 10 le get ir_ret 0 11 +put ir_v7 0 1 +end put ir_npar 0 get ir_nreg 0 b = ir_block ir_start b @@ -11373,7 +11909,13 @@ else if eq c 152 s_const else -if or or eq c 85 eq c 78 eq c 79 +if eq c 78 +ir_glob +else +if eq c 79 +ir_text +else +if eq c 85 fail 9 end fail 16 @@ -11383,6 +11925,8 @@ end end end end +end +end ir_encode if ne get fmtm 0 0 fmtout ```