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

branch main Branches Tags History

omega-mv / seed / ng / a64 / rgate.om

1790 lines · 50364 bytes Raw Blame History
1note rgate.om: the ng-a64 back-end gate (allocator and full pipeline). Run from the omega-mv root:
2note seed/out/omc < seed/ng/a64/rgate.om > rgate && ./rgate, with stdin one line naming an existing scratch directory.
3note 1. Build mkir (seed/ng/src/ir.om + seed/ng/a64/tests/mkir.om), ngcheck (seed/ng/sha256.om + seed/ng/ngcheck.om,
4note ng-ir's witness), ng (the units of seed/ng/ng.units, in order; their sha256s are ngbuild's check), ngas
5note (seed/ng/ngtxt.om + seed/ng/ngas.om) and ngrun (seed/ng/src/ir.om + seed/ng/ngrun.om) with seed/out/omc; ngrand
6note (seed/ng/src/ir.om + seed/ng/ngrand.om) is built at step 7, frand (seed/ng/a64/tests/frand.om) at step 8.
7note 2. For each fixture N of mkir: mkir writes its ΩIR, which ngcheck must accept (exit 0); ng compiles it with
8note `@ng a64` (save pairs) and with `@ng a64 split` (separate saves); each ELF runs. The omc build of
9note seed/ng/a64/tests/ref/N.om runs. Both ng statuses must equal the fixture's expected status (fixed below:
10note computed independently with Wolfram, or the trap code of the fixture's check) and omc's status its omc
11note expectation: the same, except tsum, where omc traps 6 (106) a million calls deep and ng's E loop shape has no
12note recursion (BEYOND_OMC, IR.md s7.9 and D9: trap 6 is compared only when both trap). tsum's 32 is the Omega
13note value of `int and ts 1000000 255` (Wolfram: ts(1000000) = 500000500000, low byte 32); without the & 255,
14note `int` would trap 5. The stdout of the split
15note run and of omc's run must equal the pairs run's byte for byte (bcopy writes 65536 bytes, sort four lines).
16note 3. For each ngrun fixture (text tdx: ng-ir's integer run pairs seed/ng/tests/ir/x-*.oir and the float ones
17note x-float, x-convlo and x-minnan, and
18note seed/ng/a64/tests/oir/*.oir: every check op with its trap code on narrow and 64-bit types, calls past eight
19note arguments, globals, loads and stores, block-parameter loops, the E loop shape, the bench kernels, SLICE values
20note and their checks; r-rot: u8 and u16 rotl/rotr, amounts past the width; r-s12: ngrand seed 12 shrunk to its
21note `rotr u8`, the first random refusal; ng-ir's n-s7821 and n-s10623: ngrand seeds 7821 and 10623 shrunk to a
22note u64 chk.conv i32 that traps 5, where ngrun before 26f67fbb read the u64 as signed): ngas
23note assembles it, ngcheck accepts it, ngrun (the reference interpreter, D9) runs it; its status must be a
24note program's (not 125, an op outside ngrun) and both ng forms must exit with it and write its stdout and stderr
25note byte for byte.
26note Refusal fixtures (text tdu: seed/ng/a64/tests/oir/u-*.oir, a select of SLICE values fused into its compare in
27note eq, ne-zero, signed lt and single-bit forms, true and false, passed to a call, and once not fused): ngas
28note assembles, ngcheck accepts and ngrun runs each (a program's status, not 125); both ng forms must refuse it with
29note exit 5 and stderr exactly `a64: unsupported 2` (bay 11 F1 on 3ad3ef7b: the fused select ran with a wrong value).
30note 4. Every BL target in each `@ng a64` ELF must be a multiple of 64 (function entries aligned, D13).
31note 5. Mutants of seed/ng/src/a64.om, each one equal-length text change that must occur exactly once; ng is rebuilt
32note with it and every fixture runs with `@ng a64`. A mutant is caught when some fixture's status differs from
33note its expected (mkir) or ngrun's (ngrun fixtures) status (or ng refuses, or the program is killed after 30 s)
34note or a BL target is misaligned; ngrun fixtures also compare stdout/stderr byte for byte. Every mutant must be caught:
35note 1 spill reload reads the next slot 2 values crossing a call may take caller-saved registers
36note 3 live-out values end at the block start 4 parallel moves ignore pending reads (block-argument cycles)
37note 5 callee-saved registers are never saved 6 frame of 4 bytes per slot (slots overlap the saves)
38note 7 function entries aligned to 16 bytes, not 64
39note 8 the E loop shape never matches (tsum recurses and traps 6) 9 the E tail site adds acc to itself, not a
40note 10 chk.bounds compares i with len, not len - e (oob stores past g) 11 alloca zero-fills half its area (zf)
41note 12 write passes off as the count (mem) 13 u64 loads read one byte (mem) 14 a frame above 4095 bytes drops
42note its LSL 12 part (the zero fill runs over the globals: mem) 15 i8 loads zero-extend (wid)
43note 16 a wrong trap code: chk.divovf exits 102, not 101 17 stack parameters all read the first incoming slot
44note 18 stack arguments are stored one slot low 19 a slice's length wire takes its offset, not n
45note 20 block arguments of slice type keep the target's own length (a shrinking loop slice never shrinks)
46note 21 slice offsets are not scaled by the element size (u32 and u64 slices start at the wrong element)
47note 22 monons (host 109) selects on GE, not LT: a successful clock read returns 0 (h-mono exits 1, ngrun 7)
48note 23 the fill byte count is not scaled by the element size (f-fill and f-fills: u32/u16/u64 elements; since the
49note block fill of ham/ng-a64-fill the count, not each store's index, carries the scale)
50note 24 realns reads CLOCK_MONOTONIC (h-real: the reading must lie between 2023-11-14 and 2100 and exceed monons)
51note 25 a u8 rotate's second copy shifts by 24, not 16 (bits 16..23 stay zero: r-rot)
52note 26 a u16 rotate's copy shifts by 8, not 16 (it overlaps itself: r-rot; u8 stays right)
53note 27 the allocator hands out x15, the scratch of the checked ops (lv: v_14 sits in x15 across chk.add)
54note 28 fused B.cond condition, 29 CBNZ, 30 CBZ, 31 TBNZ, 32 TBZ, 33 bit packing, 34 CSEL operands,
55note 35 the select-of-SLICE refusal never fires (caught when a refusal fixture compiles or its stderr differs).
56note 6. Front phase (needs ng-front's front.om in ng.units: `@ng front-ir`). For each source of text tfr (ng-ir's
57note x-*.om run pairs without x-float, and ng-front's integer bench kernels seed/ng/front/kernels/*.om at full size):
58note ng reads `@ng front-ir` and the source and must exit 0; ngcheck must accept its ΩIR; ng compiles that ΩIR with
59note `@ng a64` and `@ng a64 split` and both ELFs run; omc builds the same source and it runs. Both ng statuses must
60note equal omc's, both stdouts omc's byte for byte, and both stderrs omc's byte for byte, except that when omc's
61note stderr is exactly one line of decimal digits (OMC-EFF-2: the kernel's elapsed nanoseconds, different on every
62note run) ng's must be one such line too. Every BL target of the `@ng a64` ELF must be a multiple of 64.
63note x-float (f64 arithmetic, fsqrt and conversions) and the linear kernel (f32 arrays filled by `fill`) are among
64note these sources. For each source of text tfz (none since the fill head: no front case is outside the slice)
65note front-ir and ngcheck must accept and both a64 forms must refuse (exit 5); counted as refused, never compared.
66note Negative control (text tfd): fib40's front-ir and a64 build against omc's build of
67note seed/ng/a64/tests/front/fib39.om must be sound (same statuses, ngcheck accepts, BL aligned) and must differ
68note in stdout (Wolfram: Fibonacci[39] = 63245986, Fibonacci[40] = 102334155); a comparison that cannot tell
69note those apart fails the gate.
70note 7. Random phase (D9): for each seed k in 1..nrd, ngrand (ng-ir's generator: a ΩIR unit valid by construction from
71note seed k) writes the unit, which then goes through step 3's checks with ngrand's status in place of ngas's:
72note ngcheck accepts, ngrun's status is a program's, both ng forms exit with it and write its stdout and stderr byte
73note for byte, BL targets aligned. A refusal by ng fails the seed. Mutants do not run this phase. Negative control:
74note ngrun's run of seed 1 against the `@ng a64` ELF of seed 2 must be sound and differ in status or stdout.
75note 8. Float phase (scalar f32/f64, DESIGN.md section 9): frand writes the canonical ΩIR text of its edge programs
76note 1..nfe (`frand edge K`: every binary op, compare and fma over every pair of the f32 and f64 edge tables, unary
77note ops, conversions in every mode and to every integer type, bitcasts, integer edges to floats, every chk.conv
78note boundary of every integer type from both float widths with the trap past each end, and a register-pressure
79note program with stack arguments of both banks and recursion, and the fill programs of every element type:
80note lengths 0..257 for u8 and i8, block and tail boundary lengths for the wider types, offsets 0..31, nested
81note slices, sentinels, NaN and -0 patterns) and of the random seeds 1..nfl (`frand K`), ngas
82note assembles it, and each goes through step 3's checks with frand's (or ngas's) status in place of ngas's:
83note ngcheck accepts, ngrun's status is a program's, both ng forms exit with it and write its stdout and stderr byte
84note for byte (arithmetic NaNs are printed with sign and payload masked, quiet bit kept), BL targets aligned.
85note Negative control: ngrun's run of float seed 1 against the `@ng a64` ELF of float seed 2 must be sound and
86note differ in status or stdout. Packed 16B float vector mutants (80..85, DESIGN.md s12) and v-*/u-selvec fixtures run in
87note dxrun/durun. Float and fill mutants (36..79; 70..79 are the fill ones) also run the edge programs
88note and float seeds 1..nfm.
89note Output: one line per fixture and per mutant, then PASS or FAIL. Exit 0 PASS, 1 FAIL, 2 a step could not run
90note (`cannot run step K`; steps 1 and 2, opening a file, add its path; step 9, an omc build, adds spawn's status,
91note the source path and the first line of build.err: see fail9; step 18, a float program frand or ngas did not
92note give during a mutant).
93om2
94
95global mem uchar 16777216
96global pb uchar 4096
97global pn ulong 1
98global sd uchar 1024
99global sn ulong 1
100global av uchar 4096
101global ap ulong 2
102global stb uchar 4
103global ob uchar 65536
104global on ulong 1
105global ex ulong 16
106global eo ulong 16
107global rg ulong 4
108global dq ulong 128
109global fv ulong 24
110global du ulong 1
111
112note regions of mem: sources [0, 8 MiB), ΩIR [8, 12), ELF [12, 14), units [14, 15), stdin [15, 16)
113const rir ulong 8388608
114const relf ulong 12582912
115const runit ulong 14680064
116const rin ulong 15728640
117note ngrun's stderr is kept at mem[rerr, rerr + 65536), after its stdout (savout keeps at most 983040 bytes)
118const rerr ulong 15663104
119
120text tx "seed/out/omc\nseed/ng/ng.units\nseed/ng/src/ir.om\nseed/ng/a64/tests/mkir.om\nseed/ng/a64/tests/ref/\n.om\n/ng.om\n/ng.bin\n/mkir.om\n/mkir.bin\n/fx.name\n/fx.ir\n/fx.in\n/fx.elf\n/ref.bin\n/run.out\n/run.err\nseed/ng/src/a64.om\n@ng a64\n@ng a64 split\n/build.err\nseed/ng/sha256.om\nseed/ng/ngcheck.om\n/ngcheck.om\n/ngcheck.bin\nseed/ng/ngtxt.om\nseed/ng/ngas.om\nseed/ng/ngrun.om\n/ngas.om\n/ngas.bin\n/ngrun.om\n/ngrun.bin\n.oir\n@ng front-ir\nseed/ng/ngrand.om\n/ngrand.om\n/ngrand.bin\nseed/ng/a64/tests/frand.om\n/frand.om\n/frand.bin\n/fr.oir\nedge\n"
121text tdx "seed/ng/tests/ir/x-bits\nseed/ng/tests/ir/x-conv\nseed/ng/tests/ir/x-divmin\nseed/ng/tests/ir/x-fib\nseed/ng/tests/ir/x-fuel\nseed/ng/tests/ir/x-fuelok\nseed/ng/tests/ir/x-hello\nseed/ng/tests/ir/x-i8\nseed/ng/tests/ir/x-index\nseed/ng/tests/ir/x-indexok\nseed/ng/tests/ir/x-ovf64\nseed/ng/tests/ir/x-ovf64ok\nseed/ng/tests/ir/x-remmin\nseed/ng/tests/ir/x-shift\nseed/ng/a64/tests/oir/c-add-u8\nseed/ng/a64/tests/oir/c-add-i16\nseed/ng/a64/tests/oir/c-add-i32\nseed/ng/a64/tests/oir/c-add-u64\nseed/ng/a64/tests/oir/c-sub-u8\nseed/ng/a64/tests/oir/c-sub-i8\nseed/ng/a64/tests/oir/c-sub-u32\nseed/ng/a64/tests/oir/c-sub-i64\nseed/ng/a64/tests/oir/c-mul-i8\nseed/ng/a64/tests/oir/c-mul-u32\nseed/ng/a64/tests/oir/c-mul-i64\nseed/ng/a64/tests/oir/c-mul-u64\nseed/ng/a64/tests/oir/c-neg-i8\nseed/ng/a64/tests/oir/c-neg-u16\nseed/ng/a64/tests/oir/c-neg-i64\nseed/ng/a64/tests/oir/c-divz-u8\nseed/ng/a64/tests/oir/c-divz-u32\nseed/ng/a64/tests/oir/c-divz-i64\nseed/ng/a64/tests/oir/c-divovf-i8\nseed/ng/a64/tests/oir/c-divovf-i32\nseed/ng/a64/tests/oir/c-divovf-i64\nseed/ng/a64/tests/oir/c-shl-i8\nseed/ng/a64/tests/oir/c-shl-i16\nseed/ng/a64/tests/oir/c-shl-i32\nseed/ng/a64/tests/oir/c-shl-i64\nseed/ng/a64/tests/oir/c-shift-u8\nseed/ng/a64/tests/oir/c-shift-i32\nseed/ng/a64/tests/oir/c-shift-u32\nseed/ng/a64/tests/oir/c-shift-u64\nseed/ng/a64/tests/oir/c-conv-i64-u8\nseed/ng/a64/tests/oir/c-conv-i32-u16\nseed/ng/a64/tests/oir/c-conv-u64-i64\nseed/ng/a64/tests/oir/c-conv-i64-i8\nseed/ng/a64/tests/oir/c-conv-u8-i8\nseed/ng/a64/tests/oir/c-conv-i64-u32\nseed/ng/a64/tests/oir/c-bounds-n\nseed/ng/a64/tests/oir/c-bounds-e0\nseed/ng/a64/tests/oir/c-bounds-ld\nseed/ng/a64/tests/oir/c-slice-n\nseed/ng/a64/tests/oir/c-slice-off\nseed/ng/a64/tests/oir/c-fuel\nseed/ng/a64/tests/oir/c-true-1\nseed/ng/a64/tests/oir/c-true-9\nseed/ng/a64/tests/oir/c-true-10\nseed/ng/a64/tests/oir/c-true-13\nseed/ng/a64/tests/oir/wide\nseed/ng/a64/tests/oir/mem2\nseed/ng/a64/tests/oir/eloop\nseed/ng/a64/tests/oir/b-fib\nseed/ng/a64/tests/oir/b-bcopy\nseed/ng/a64/tests/oir/b-sort\nseed/ng/a64/tests/oir/s-slice\nseed/ng/a64/tests/oir/s-tb\nseed/ng/a64/tests/oir/s-te\nseed/ng/a64/tests/oir/s-ts\nseed/ng/a64/tests/oir/s-ts2\nseed/ng/a64/tests/oir/b-chacha\nseed/ng/a64/tests/oir/h-mono\nseed/ng/a64/tests/oir/f-fill\nseed/ng/a64/tests/oir/f-fills\nseed/ng/a64/tests/oir/h-real\nseed/ng/a64/tests/oir/r-rot\nseed/ng/a64/tests/oir/r-s12\nseed/ng/a64/tests/oir/f-fusion\nseed/ng/tests/ir/n-s7821\nseed/ng/tests/ir/n-s10623\nseed/ng/tests/ir/x-float\nseed/ng/tests/ir/x-convlo\nseed/ng/tests/ir/x-minnan\nseed/ng/a64/tests/oir/v-f32-ops\nseed/ng/a64/tests/oir/v-f64-ops\nseed/ng/a64/tests/oir/v-fma-alias\nseed/ng/a64/tests/oir/v-call-clobber\nseed/ng/a64/tests/oir/v-spill-loop\nseed/ng/a64/tests/oir/v-spill-swap\nseed/ng/a64/tests/oir/v-swap-nocall\nseed/ng/tests/ir/x-pool\nseed/ng/tests/ir/x-pool-widths\nseed/ng/tests/ir/x-pool-bound\n"
122text tfx "fib\ndeep\npress\nrot\nck\nar\ntsum\nmem\noob\nzf\nwid\nbcopy\nsort\nlv\n"
123text tmp "a6_ew a_ldrx s 31 sub get ar_m add get ar_rb 96 w 1 0 0\nx = ne uchar get ar_m add get ar_rb 94 w 0\nget ar_m add get ar_rb 102 add mul x lw i get a_ben x\nif not a6_isrc d\nif ge r 19\nf = mul 8 add get a_fs 4 n\nwhile ne and get a_cn 0 63 0 bound 16\nif ne get i_oop m 10\na6_tsum l a\na6_cmpk i sub l e\na6_movi 17 shr get a_asz k 4\na6_mvadd 2 a6_loc a6_arg o 4\nret a_ldrxr\na6_ew a_subxi 31 31 h 1 0\nconst a_lsbx ulong 82\na6_fx a_cbzx 15 add a_tlab c\na6_ew a_ldrx d 17 j 0 0\na6_ew a_strx l 31 sub k 8 0 0\na6_mov 15 n\na6_mvadd a6_wloc a6_lw d a6_wloc a6_lw s\na6_ew a_addx 16 b f 0 a6_lsz e\na6_ew a_cselx 0 0 2 11 0\nsz = a6_lsz t\nck = ulong 0\na6_ew a_orrx 16 16 16 0 16\na6_ew a_orrx 16 a a 0 w\nwhile lt r 15 bound 15\na6_fx a_bcond cc l\nf = a_cbnzx\nf = a_cbzx\nf = 111\nf = 110\na6_fx f add r shl bit 5 l\na6_ew a_cselx d u v cc 0\nif and ne op 54 a6_issl r\nret and shr ulong 0xac9410 mul 4 sub op 30 15\nret and shr ulong 0xac9410 mul 4 sub op 30 15\nret and shr ulong 0xac9410 mul 4 sub op 30 15\nret and shr ulong 0xac9410 mul 4 sub op 30 15\nconst a_faddd ulong 117\nconst a_fadds ulong 125\na6_ew a6_ff t a_fcseld a_fcsels d a b 1 0\nfm = a6_ff t a_fnegd a_fnegs\na6_ew a_movzx 15 0xc0 1 0 0\na6_ew a_msrfpcr 31 0 0 0 0\nfz = ulong 31\na6_ew a_cselx d 17 d 12 0\na6_ew a_cselx d 17 d 8 0\na6_ew a6_ff s a_fcvtzsxd a_fcvtzsxs d a 0 0 0\na6_fx a_bcond 6 add a_tlab 5\nhi = shl add ulong 1022 w 52\nif eq a6_vty v 13\na6_ew a6_ff t a_ldrdr a_ldrsr d b i 1 0\na6_ew a6_ff t a_strdr a_strsr x b i 1 0\na6_mvadd get a_mal k p\na6_mvfrom r a6_rloc r\nif or lt r 28 and ge r 40 lt r 48\na6_ew a_ldrd s 31 sub get ar_m add get ar_rb 96 w 1 0 0\nconst a_fminnmd ulong 124\nconst a_fmaxnms ulong 131\nfm = a6_ff t a_scvtfdx a_scvtfsx\na6_ew a_subx 16 16 15 0 0\na6_ew a6_ff t a_fmovdx a_fmovsw d 16 0 0 0\na6_ew a_fmovd sub d 32 sub s 32 0 0 0\na6_ew a_strd sub l 32 31 sub k 8 0 0\na6_ew a_ldrd sub d 32 17 j 0 0\na6_ew a6_ff t a_fmaddd a_fmadds d a b c 0\na6_ew a_fcvtds d a 0 0 0\na6_ew a_strd r 31 sub get ar_m add get ar_rb 96 w 1 0 0\na6_ew a_subsxi 31 15 16 0 0\na6_ew a_tbz 15 3 3 0 0\na6_ew a_tbz 15 2 3 0 0\na6_ew a_tbz 15 1 3 0 0\na6_ew a_tbz 15 0 3 0 0\na6_ew a_bcond 3 4 0 0 0\na6_ew a_strqr 31 b 15 0 0\na6_ew a_orrx 17 17 17 0 8\na6_ew a_andxi 17 x sub shl ulong 1 shl ulong 8 sz 1 0 0\na6_ew a6_ff t a_fmovxd a_fmovws 17 x 0 0 0\nif and x eq uchar get ar_m add get ar_rb 99 w 2\nfm = a6_vf t a_fadd2d a_fadd4s\nif or eq d a eq d b\na6_ew a6_vf vt a_dupd a_dups d a m 0 0\na6_ew a_strq r 31 shr sub get ar_m add get ar_rb 96 w 1 1 0 0\na6_ew a_ldrq 30 31 sub s 700 0 0\na6_fx a_bcond 2 add a_tlab 3\na6_emitw 4177528106\na6_ew a6_ff t a_ldrdr a_ldrsr d 16 i 1 0\na6_envbr small a_bcond 8\na6_ew a_addx 3 18 3 0 3\na6_ew a_strbr 6 1 0 0 0\n"
124text tmr "a6_ew a_ldrx s 31 add get ar_m add get ar_rb 96 w 0 0 0\nx = eq uchar get ar_m add get ar_rb 94 w 9\nget ar_m add get ar_rb 102 add mul x lw i get a_bst x\nif not a6_isrc 0\nif ge r 99\nf = mul 4 add get a_fs 4 n\nwhile ne and get a_cn 0 15 0 bound 16\nif ne get i_oop m 99\na6_tsum l l\na6_cmpk i sub l 0\na6_movi 17 shr get a_asz k 5\na6_mvadd 2 a6_loc a6_arg o 3\nret a_ldrbr\na6_ew a_subxi 31 31 h 0 0\nconst a_lsbx ulong 81\na6_fx a_cbzx 15 add a_tlab 9\na6_ew a_ldrx d 17 0 0 0\na6_ew a_strx l 31 sub k 7 0 0\na6_mov 15 f\na6_mvadd a6_wloc a6_lw d a6_wloc a6_lw d\na6_ew a_addx 16 b f 0 a6_lsz 2\na6_ew a_cselx 0 0 2 10 0\nsz = a6_lsz 2\nck = ulong 1\na6_ew a_orrx 16 16 16 0 24\na6_ew a_orrx 16 a a 0 8\nwhile lt r 16 bound 16\na6_fx a_bcond 14 l\nf = a_cbzx \nf = a_bl \nf = 110\nf = 111\na6_fx f add r shl bit 4 l\na6_ew a_cselx d v u cc 0\nif and eq op 99 a6_issl r\nret and shr ulong 0xac9b10 mul 4 sub op 30 15\nret and shr ulong 0xacd410 mul 4 sub op 30 15\nret and shr ulong 0xa89410 mul 4 sub op 30 15\nret and shr ulong 0x2c9410 mul 4 sub op 30 15\nconst a_faddd ulong 118\nconst a_fadds ulong 117\na6_ew a6_ff t a_fcseld a_fcsels d b a 1 0\nfm = a6_ff t a_fabsd a_fnegs\na6_ew a_movzx 15 0x40 1 0 0\na6_ew a_msrfpcr 15 0 0 0 0\nfz = ulong 16\na6_ew a_cselx d 17 d 13 0\na6_ew a_cselx d 17 d 9 0\na6_ew a6_ff s a_fcvtzuxd a_fcvtzsxs d a 0 0 0\na6_fx a_bcond 7 add a_tlab 5\nhi = shl add ulong 1021 w 52\nif eq a6_vty v 99\na6_ew a6_ff t a_ldrdr a_ldrsr d b i 0 0\na6_ew a6_ff t a_strsr a_strsr x b i 1 0\na6_mvadd get a_mal k k\na6_mvfrom r a6_rloc 0\nif or lt r 28 and ge r 48 lt r 48\na6_ew a_ldrd s 31 add get ar_m add get ar_rb 96 w 0 0 0\nconst a_fminnmd ulong 122\nconst a_fmaxnms ulong 132\nfm = a6_ff t a_ucvtfdx a_scvtfsx\na6_ew a_addx 16 16 15 0 0\na6_ew a6_ff t a_fmovdx a_fmovsw d 17 0 0 0\na6_ew a_fmovd sub d 32 sub s 33 0 0 0\na6_ew a_strd sub l 32 31 sub k 7 0 0\na6_ew a_ldrd sub d 32 17 0 0 0\na6_ew a6_ff t a_fmaddd a_fmadds d a c b 0\na6_ew a_fcvtsd d a 0 0 0\na6_ew a_strd r 31 sub get ar_m add get ar_rb 96 w 0 0 0\na6_ew a_subsxi 31 15 32 0 0\na6_ew a_tbz 15 4 3 0 0\na6_ew a_tbz 15 4 3 0 0\na6_ew a_tbz 15 4 3 0 0\na6_ew a_tbz 15 4 3 0 0\na6_ew a_bcond 2 4 0 0 0\na6_ew a_strqr 31 b 15 1 0\na6_ew a_orrx 17 17 17 0 9\na6_ew a_andxi 17 x sub shl ulong 1 shl ulong 9 sz 1 0 0\na6_ew a6_ff t a_fmovxd a_fmovws 16 x 0 0 0\nif and x eq uchar get ar_m add get ar_rb 99 w 9\nfm = a6_vf t a_fadd4s a_fadd4s\nif eq add d 1 99999\na6_ew a6_vf vt a_dupd a_dups d a 0 0 0\na6_ew a_strd r 31 shr sub get ar_m add get ar_rb 96 w 1 0 0 0\na6_ew a_ldrq 31 31 sub s 700 0 0\na6_fx a_bcond 3 add a_tlab 3\na6_emitw 4177528105\na6_ew a6_ff t a_ldrdr a_ldrsr d 16 i 0 0\na6_envbr small a_bcond 2\na6_ew a_addx 3 18 3 0 2\na6_ew a_strbr 5 1 0 0 0\n"
125text tmsg "a64 rgate: fixture\npairs\nsplit\nomc\nexpected\nmutant\ncaught\nMISSED\nPASS\nFAIL\ncannot run step\nfixtures ok\nmutants caught\nngcheck\nmisaligned\nomc-expected\nstdout-same\na64 rgate: ngrun-fixture\nngas\nngrun\nstderr-same\nngrun fixtures ok\na64 rgate: front\nfront-ir\nstderr-ok\nfront cases ok\na64 rgate: front-refused\na64 rgate: front-control (ng: fib40, omc: fib39)\nfront refused ok\nfront control differs\na64 rgate: random seed\nngrand\nrandom seeds ok\na64 rgate: random-control (ng: seed 2, ngrun: seed 1)\nrandom control differs\na64 rgate: refusal-fixture\nrefusal fixtures ok\na64: unsupported 2\nstderr-unsupported\na64 rgate: float edge\nfrand\nfloat edges ok\na64 rgate: float seed\nfloat seeds ok\na64 rgate: float-control (ng: float seed 2, ngrun: float seed 1)\nfloat control differs\n"
126text tfr "seed/ng/tests/ir/x-bits\nseed/ng/tests/ir/x-conv\nseed/ng/tests/ir/x-divmin\nseed/ng/tests/ir/x-fib\nseed/ng/tests/ir/x-fuel\nseed/ng/tests/ir/x-fuelok\nseed/ng/tests/ir/x-hello\nseed/ng/tests/ir/x-i8\nseed/ng/tests/ir/x-index\nseed/ng/tests/ir/x-indexok\nseed/ng/tests/ir/x-ovf64\nseed/ng/tests/ir/x-ovf64ok\nseed/ng/tests/ir/x-remmin\nseed/ng/tests/ir/x-shift\nseed/ng/front/kernels/arith\nseed/ng/front/kernels/branch\nseed/ng/front/kernels/leafcall\nseed/ng/front/kernels/fib38\nseed/ng/front/kernels/fib40\nseed/ng/front/kernels/isort\nseed/ng/front/kernels/sieve\nseed/ng/front/kernels/sort\nseed/ng/front/kernels/matmul\nseed/ng/tests/ir/x-float\nseed/ng/front/kernels/linear\nseed/omc/tests/pools/g2a\nseed/omc/tests/pools/g2b\nseed/omc/tests/pools/g2c\nseed/omc/tests/pools/g2d\nseed/omc/tests/pools/g3\nseed/omc/tests/pools/g3i\nseed/omc/tests/pools/g4\nseed/omc/tests/pools/g5a\nseed/omc/tests/pools/g5b\nseed/omc/tests/pools/g5c\nseed/omc/tests/pools/g5ctl\nseed/omc/tests/pools/g5d\nseed/omc/tests/pools/g8b\nseed/omc/tests/pools/gf\nseed/omc/tests/pools/gr\nseed/ng/front/cases/pool-widths-order\nseed/ng/a64/tests/front/env-empty\nseed/host/tests/environment\nseed/host/tests/environment_trap\nseed/ng/a64/tests/front/env-slices\nseed/ng/a64/tests/front/env-huge\nseed/ng/a64/tests/front/env-bounds\n"
127text tfz ""
128text tfd "seed/ng/front/kernels/fib40\nseed/ng/a64/tests/front/fib39\n"
129text tdu "seed/ng/a64/tests/oir/u-selslice-true\nseed/ng/a64/tests/oir/u-selslice-false\nseed/ng/a64/tests/oir/u-selslice-apart\nseed/ng/a64/tests/oir/u-selslice-lt\nseed/ng/a64/tests/oir/u-selslice-ne0\nseed/ng/a64/tests/oir/u-selslice-bit\nseed/ng/a64/tests/oir/u-selslice-call\nseed/ng/a64/tests/oir/u-selvec\n"
130
131const nfx ulong 14
132const ndx ulong 93
133const nmut ulong 91
134const nrd ulong 1000
135const nfr ulong 47
136const nenv ulong 5
137const nfz ulong 0
138const ndu ulong 8
139note float phase (step 8): edge programs 1..nfe and seeds 1..nfl of frand; float mutants are those past mfl and run
140note the edge programs and float seeds 1..nfm as well
141const nfe ulong 66
142const nfl ulong 1000
143const nfm ulong 8
144const mfl ulong 35
145
146note Controlled environment for the final nenv front fixtures; no operator environment is copied.
147text ev_one "OMTEST=hello"
148text ev_two "OMEGA_ENV_SECOND=two"
149text ev_three "OMEGA_ENV_EMPTY="
150global ev_buf uchar 256
151global ev_ctl ulong 1
152global ev_len ulong 1
153fn envrec p ulong s view uchar * to ulong
154put ev_buf p uchar len s
155put ev_buf add p 1 0
156for i ulong len s
157put ev_buf add add p 2 i get s i
158end
159ret add add p 2 len s
160end
161fn envinit to void
162put ev_buf 0 3
163put ev_buf 1 0
164p = envrec 2 ev_one
165p = envrec p ev_two
166put ev_len 0 envrec p ev_three
167end
168
169note ---- text lines: line k of text t (0 tx, 1 tfx, 2 tmp, 3 tmr, 4 tmsg, 5 tdx, 6 tfr, 7 tfz, 8 tfd, 9 tdu) ----
170fn tlen t ulong to ulong
171if eq t 0
172ret len tx
173end
174if eq t 1
175ret len tfx
176end
177if eq t 2
178ret len tmp
179end
180if eq t 3
181ret len tmr
182end
183if eq t 5
184ret len tdx
185end
186if eq t 6
187ret len tfr
188end
189if eq t 7
190ret len tfz
191end
192if eq t 8
193ret len tfd
194end
195if eq t 9
196ret len tdu
197end
198ret len tmsg
199end
200
201fn tch t ulong i ulong to ulong
202if eq t 0
203ret ulong get tx i
204end
205if eq t 1
206ret ulong get tfx i
207end
208if eq t 2
209ret ulong get tmp i
210end
211if eq t 3
212ret ulong get tmr i
213end
214if eq t 5
215ret ulong get tdx i
216end
217if eq t 6
218ret ulong get tfr i
219end
220if eq t 7
221ret ulong get tfz i
222end
223if eq t 8
224ret ulong get tfd i
225end
226if eq t 9
227ret ulong get tdu i
228end
229ret ulong get tmsg i
230end
231
232note tline t k: start of line k of text t (lines end with a newline)
233fn tline t ulong k ulong to ulong
234i = ulong 0
235j = ulong 0
236while lt j k bound 256
237while ne tch t i 10 bound 4096
238i = add i 1
239end
240i = add i 1
241j = add j 1
242end
243ret i
244end
245
246fn tend t ulong i ulong to ulong
247e = i
248while ne tch t e 10 bound 4096
249e = add e 1
250end
251ret e
252end
253
254note ---- output ----
255fn oput b ulong to void
256n = get on 0
257if lt n len ob
258put ob n uchar b
259put on 0 add n 1
260end
261end
262
263fn oflush to void
264n = get on 0
265p = ulong 0
266while lt p n bound 65536
267k = write 1 ob p sub n p
268if le k 0
269p = n
270else
271p = add p ulong k
272end
273end
274put on 0 0
275end
276
277fn otl t ulong k ulong to void
278i = tline t k
279e = tend t i
280while lt i e bound 4096
281oput tch t i
282i = add i 1
283end
284end
285
286fn omsg k ulong to void
287otl 4 k
288end
289
290fn odec v ulong to void
291d = ulong 1
292while ge div v d 10 bound 20
293d = mul d 10
294end
295x = v
296while gt d 0 bound 20
297oput add 48 div x d
298x = rem x d
299d = div d 10
300end
301end
302
303fn okv k ulong v ulong to void
304oput 32
305omsg k
306oput 32
307odec v
308end
309
310fn fail k ulong to void
311omsg 10
312oput 32
313odec k
314oput 10
315omsg 9
316oput 10
317oflush
318exit 2
319end
320
321note ---- paths in pb ----
322fn pclr to void
323put pn 0 0
324end
325
326fn pb1 b ulong to void
327n = get pn 0
328if ge n len pb
329fail 0
330end
331put pb n uchar b
332put pn 0 add n 1
333end
334
335fn ptl t ulong k ulong to void
336i = tline t k
337e = tend t i
338while lt i e bound 4096
339pb1 tch t i
340i = add i 1
341end
342end
343
344fn pset k ulong to void
345pclr
346ptl 0 k
347end
348
349fn pscr k ulong to void
350pclr
351i = ulong 0
352while lt i get sn 0 bound 1024
353pb1 ulong get sd i
354i = add i 1
355end
356ptl 0 k
357end
358
359note pref f: pb = seed/ng/a64/tests/ref/<fixture f>.om
360fn pref f ulong to void
361pset 4
362ptl 1 f
363ptl 0 5
364end
365
366note failp k: like fail k (a step could not run), with the path in pb after the step number
367fn failp k ulong to void
368omsg 10
369oput 32
370odec k
371oput 32
372i = ulong 0
373while lt i get pn 0 bound 4096
374oput ulong get pb i
375i = add i 1
376end
377oput 10
378omsg 9
379oput 10
380oflush
381exit 2
382end
383
384note ---- files ----
385fn openr to int
386r = fopen pb 0 get pn 0 0 0
387if lt r 0
388failp 1
389end
390ret int r
391end
392
393note openw md: create or truncate pb for writing with mode md (O_WRONLY|O_CREAT|O_TRUNC = 577)
394fn openw md int to int
395r = fopen pb 0 get pn 0 577 md
396if lt r 0
397failp 2
398end
399ret int r
400end
401
402fn fclo fd int to void
403r = fclose fd
404end
405
406note readin o c: all of file pb into mem at offset o (capacity c bytes); returns the byte count
407fn readin o ulong c ulong to ulong
408fd = openr
409n = ulong 0
410go = true
411while go bound 1000000
412if ge n c
413fail 3
414end
415k = read fd mem add o n sub c n
416if lt k 0
417fail 3
418end
419if eq k 0
420go = false
421else
422n = add n ulong k
423end
424end
425fclo fd
426ret n
427end
428
429fn wall fd int o ulong n ulong to void
430p = ulong 0
431while lt p n bound 1000000
432k = write fd mem add o p sub n p
433if le k 0
434fail 4
435end
436p = add p ulong k
437end
438end
439
440note wtl fd t k: line k of text t and a newline to fd (staged at mem[rin])
441fn wtl fd int t ulong k ulong to void
442i = tline t k
443e = tend t i
444n = ulong 0
445while le add i n e bound 4096
446put mem add rin n uchar tch t add i n
447n = add n 1
448end
449wall fd rin n
450end
451
452note ---- children: av = u16 count, then per argument u16 length and its bytes ----
453fn aclr to void
454put ap 0 2
455put ap 1 0
456end
457
458fn apb to void
459n = get pn 0
460p = get ap 0
461if gt add add p n 2 len av
462fail 5
463end
464put av p uchar and n 255
465put av add p 1 uchar shr n 8
466i = ulong 0
467while lt i n bound 4096
468put av add add p 2 i get pb i
469i = add i 1
470end
471put ap 0 add add p 2 n
472put ap 1 add get ap 1 1
473end
474
475fn redir s int d int to void
476if ne s d
477if ne dupfd s d 0 long d
478exit 127
479end
480end
481end
482
483note spawn fi fo fe: run av with stdin, stdout, stderr fi, fo, fe; returns the exit status, 256 + signal, and kills
484note the child (status 265) when it runs longer than 30 s
485fn spawn fi int fo int fe int to ulong
486put av 0 uchar and get ap 1 255
487put av 1 uchar shr get ap 1 8
488pid = fork
489if lt pid 0
490fail 6
491end
492if eq pid 0
493redir fi 0
494redir fo 1
495redir fe 2
496if ne get ev_ctl 0 0
497r = execenv av 0 get ap 0 ev_buf 0 get ev_len 0
498else
499r = execprog av 0 get ap 0
500end
501exit 127
502end
503fclo fi
504fclo fo
505fclo fe
506ret reap pid
507end
508
509fn reap pid long to ulong
510t0 = monons
511while true bound 1000000
512r = waitpid int pid stb 0 len stb 1
513if eq r pid
514ret wstat
515end
516if ne r 0
517fail 7
518end
519if gt sub monons t0 30000000000
520k = killpid int pid 9
521end
522s = sleepns 1000000
523end
524fail 7
525ret 0
526end
527
528fn wstat to ulong
529sg = and ulong get stb 0 127
530if ne sg 0
531ret add 256 sg
532end
533ret ulong get stb 1
534end
535
536note ---- building ----
537note unitpath p q: pb = the path of the ng.units line mem[p, q) (`HEX PATH`, 64 hex digits and one space)
538fn unitpath p ulong q ulong to void
539if or le q add p 65 ne get mem add p 64 32
540fail 17
541end
542pclr
543i = add p 65
544while lt i q bound 4096
545pb1 ulong get mem i
546i = add i 1
547end
548end
549
550fn isa64 to bool
551i = tline 0 17
552e = tend 0 i
553if ne get pn 0 sub e i
554ret false
555end
556j = ulong 0
557while lt j sub e i bound 64
558if ne ulong get pb j tch 0 add i j
559ret false
560end
561j = add j 1
562end
563ret true
564end
565
566note mkmut o n m: replace the one occurrence of mutant line m of tmp in mem[o, o+n) by line m of tmr
567fn mkmut o ulong n ulong m ulong to void
568p = tline 2 m
569pl = sub tend 2 p p
570r = tline 3 m
571if ne pl sub tend 3 r r
572fail 8
573end
574hits = ulong 0
575hit = ulong 0
576i = o
577while le add i pl add o n bound 4194304
578if samepat i p pl
579hits = add hits 1
580hit = i
581end
582i = add i 1
583end
584if ne hits 1
585fail 8
586end
587j = ulong 0
588while lt j pl bound 128
589put mem add hit j uchar tch 3 add r j
590j = add j 1
591end
592end
593
594fn samepat i ulong p ulong pl ulong to bool
595j = ulong 0
596while lt j pl bound 128
597if ne ulong get mem add i j tch 2 add p j
598ret false
599end
600j = add j 1
601end
602ret true
603end
604
605note srcng m: the units of ng.units concatenated at mem[0); mutant m (1..) applied to a64.om, 0 none; the length
606fn srcng m ulong to ulong
607pset 1
608nu = readin runit 1048576
609s = ulong 0
610p = runit
611e = add runit nu
612hit = ulong 0
613while lt p e bound 128
614q = untilnl p e
615unitpath p q
616k = readin s sub rir s
617if and gt m 0 isa64
618mkmut s k sub m 1
619hit = add hit 1
620end
621s = add s k
622p = add q 1
623end
624if and gt m 0 ne hit 1
625fail 8
626end
627ret s
628end
629
630fn untilnl p ulong e ulong to ulong
631q = p
632while lt q e bound 4096
633if eq get mem q 10
634ret q
635end
636q = add q 1
637end
638ret q
639end
640
641note fail9 r s: step 9 (an omc build) could not run. Prints spawn's status r, the source path (scratch text s)
642note and the first line of build.err. 127 with an empty build.err: the child could not redirect a descriptor or
643note exec omc (spawn failed, omc never ran); 265: killed after 30 s; other values above 256: 256 + a signal;
644note otherwise omc's exit status, with its message in build.err. Opening the files fails earlier (steps 1, 2).
645text t9m "status\nsource\nbuild.err\nunreadable\n(empty)\n"
646
647fn o9l k ulong to void
648i = ulong 0
649j = ulong 0
650while lt j k bound 16
651while ne ulong get t9m i 10 bound 256
652i = add i 1
653end
654i = add i 1
655j = add j 1
656end
657while ne ulong get t9m i 10 bound 256
658oput ulong get t9m i
659i = add i 1
660end
661end
662
663fn fail9 r ulong s ulong to void
664omsg 10
665oput 32
666odec 9
667oput 32
668o9l 0
669oput 32
670odec r
671oput 32
672o9l 1
673oput 32
674pscr s
675i = ulong 0
676while lt i get pn 0 bound 4096
677oput ulong get pb i
678i = add i 1
679end
680oput 32
681o9l 2
682oput 32
683pscr 20
684fd = fopen pb 0 get pn 0 0 0
685if lt fd 0
686o9l 3
687else
688k = read int fd mem rin 4096
689fclo int fd
690if le k 0
691o9l 4
692else
693n = ulong k
694i = ulong 0
695while and lt i n ne get mem add rin i 10 bound 4096
696oput ulong get mem add rin i
697i = add i 1
698end
699end
700end
701oput 10
702omsg 9
703oput 10
704oflush
705exit 2
706end
707
708note compile mem[0, n) with omc: scratch text s (source) -> scratch text b (binary); omc must succeed
709fn omcb n ulong s ulong b ulong to void
710pscr s
711fd = openw 420
712wall fd 0 n
713fclo fd
714pscr s
715fi = openr
716pscr b
717fo = openw 493
718pscr 20
719fe = openw 420
720aclr
721pset 0
722apb
723r = spawn fi fo fe
724if ne r 0
725fail9 r s
726end
727end
728
729fn buildng m ulong to void
730omcb srcng m 6 7
731end
732
733fn buildmk to void
734pset 2
735n = readin 0 rir
736pset 3
737n = add n readin n sub rir n
738omcb n 8 9
739end
740
741fn buildck to void
742pset 21
743n = readin 0 rir
744pset 22
745n = add n readin n sub rir n
746omcb n 23 24
747end
748
749note runck: ngcheck.bin < fx.ir; its exit status (0 accept, else the refusal class)
750fn runck to ulong
751pscr 11
752fi = openr
753pscr 15
754fo = openw 420
755pscr 16
756fe = openw 420
757aclr
758pscr 24
759apb
760ret spawn fi fo fe
761end
762
763note ---- running a fixture ----
764note mkfx f: scratch/fx.name = fixture f's name; mkir.bin < fx.name > fx.ir; returns the ΩIR byte count (at rir)
765fn mkfx f ulong to ulong
766pscr 10
767fd = openw 420
768wtl fd 1 f
769fclo fd
770pscr 10
771fi = openr
772pscr 11
773fo = openw 420
774pscr 16
775fe = openw 420
776aclr
777pscr 9
778apb
779if ne spawn fi fo fe 0
780fail 11
781end
782pscr 11
783ret readin rir 4194304
784end
785
786note runng n md: fx.in = mode line md (18 pairs, 19 split) + the ΩIR at rir (n bytes); ng.bin < fx.in > fx.elf;
787note returns the program's status, or 1000 + ng's exit status when ng refuses
788fn runng n ulong md ulong to ulong
789pscr 12
790fd = openw 420
791wtl fd 0 md
792wall fd rir n
793fclo fd
794pscr 12
795fi = openr
796pscr 13
797fo = openw 493
798pscr 16
799fe = openw 420
800aclr
801pscr 7
802apb
803c = spawn fi fo fe
804if ne c 0
805ret add 1000 c
806end
807ret runbin 13
808end
809
810note runbin k: run scratch text k with stdin fx.name, stdout run.out, stderr run.err; its status
811fn runbin k ulong to ulong
812pscr 10
813fi = openr
814pscr 15
815fo = openw 420
816pscr 16
817fe = openw 420
818aclr
819pscr k
820apb
821ret spawn fi fo fe
822end
823
824fn runref f ulong to ulong
825pref f
826n = readin 0 rir
827omcb n 8 14
828ret runbin 14
829end
830
831note ---- main ----
832fn rdscr to void
833pclr
834n = read 0 mem rin 4096
835if le n 0
836fail 16
837end
838i = ulong 0
839while lt i ulong n bound 4096
840if eq get mem add rin i 10
841i = add i 4096
842else
843put sd i get mem add rin i
844i = add i 1
845end
846end
847if ge i 4096
848i = sub i 4096
849end
850if or eq i 0 ge i 1000
851fail 16
852end
853put sn 0 i
854end
855
856fn expect f ulong to ulong
857ret get ex f
858end
859
860note blbad: the number of BL instructions in scratch/fx.elf (code from byte 176) whose target is not a multiple of 64
861fn blbad to ulong
862pscr 13
863m = readin relf 2097152
864c = ulong 0
865pc = ulong 176
866while le add pc 4 m bound 524288
867w = le32 add relf pc
868if eq and w 0xfc000000 0x94000000
869if ne and bltgt pc and w 0x3ffffff 63 0
870c = add c 1
871end
872end
873pc = add pc 4
874end
875ret c
876end
877
878fn le32 o ulong to ulong
879v = ulong get mem o
880v = or v shl ulong get mem add o 1 8
881v = or v shl ulong get mem add o 2 16
882ret or v shl ulong get mem add o 3 24
883end
884
885note bltgt pc i: target byte offset of a BL at pc with imm26 i (signed, in words)
886fn bltgt pc ulong i ulong to ulong
887if ge i 0x2000000
888ret sub pc mul 4 sub 0x4000000 i
889end
890ret add pc mul 4 i
891end
892
893note savout: scratch run.out into mem[runit] (the units region is used only while building ng); its byte count
894fn savout to ulong
895pscr 15
896ret readin runit 983040
897end
898
899note saverr: scratch run.err into mem[rerr]; its byte count
900fn saverr to ulong
901pscr 16
902ret readin rerr 65536
903end
904
905note samef k b n: scratch text k (read into the staging region mem[rin]) equals the n bytes kept at mem[b]
906fn samef k ulong b ulong n ulong to bool
907pscr k
908m = readin rin 1048576
909if ne m n
910ret false
911end
912i = ulong 0
913while lt i n bound 1048576
914if ne get mem add b i get mem add rin i
915ret false
916end
917i = add i 1
918end
919ret true
920end
921
922note ---- ngrun fixtures: ΩIR text through ngas and ngcheck; ngrun (IR.md s7, the D9 oracle) against both ng forms ----
923note pdx t d: pb = the text file of ΩIR text fixture d of list t (5 tdx, 9 tdu: its line and .oir)
924fn pdx t ulong d ulong to void
925pclr
926ptl t d
927ptl 0 32
928end
929
930fn buildas to void
931pset 25
932n = readin 0 rir
933pset 26
934n = add n readin n sub rir n
935omcb n 28 29
936end
937
938fn buildrun to void
939pset 2
940n = readin 0 rir
941pset 27
942n = add n readin n sub rir n
943omcb n 30 31
944end
945
946note dxas t d: ngas.bin < fixture d of list t's text > fx.ir; ngas's status
947fn dxas t ulong d ulong to ulong
948pdx t d
949fi = openr
950pscr 11
951fo = openw 420
952pscr 16
953fe = openw 420
954aclr
955pscr 29
956apb
957ret spawn fi fo fe
958end
959
960note dxir t d: fixture d of list t's ΩIR at rir (its byte count), 0 bytes when ngas refuses; ngas's status in rg[0]
961fn dxir t ulong d ulong to ulong
962s = dxas t d
963put rg 0 s
964if ne s 0
965ret 0
966end
967pscr 11
968ret readin rir 4194304
969end
970
971note runrun: ngrun.bin fx.ir with stdin fx.name, stdout run.out, stderr run.err; its status
972fn runrun to ulong
973pscr 10
974fi = openr
975pscr 15
976fo = openw 420
977pscr 16
978fe = openw 420
979aclr
980pscr 31
981apb
982pscr 11
983apb
984ret spawn fi fo fe
985end
986
987note ngrun fixture d: ngas and ngcheck accept it; ngrun's status (kept in dq for the mutants) is a program's (below
988note 256) and not 125 (an op outside ngrun); both ng forms exit with it and write its stdout and stderr byte for byte;
989note the `@ng a64` ELF has every BL target aligned to 64
990fn dxrun d ulong to bool
991n = dxir 5 d
992omsg 17
993oput 32
994otl 5 d
995ok = dxcmp n 18
996put dq d get rg 2
997ret ok
998end
999
1000note refusal fixture u (text tdu): ngas and ngcheck accept it, ngrun runs it (a program's status below 256, not 125);
1001note both ng forms refuse it with exit 5 and stderr exactly `a64: unsupported 2` (unsupe)
1002fn durun u ulong to bool
1003n = dxir 9 u
1004s = get rg 0
1005c = runck
1006q = runrun
1007a = runng n 18
1008ea = unsupe
1009b = runng n 19
1010eb = unsupe
1011omsg 35
1012oput 32
1013otl 9 u
1014okv 18 s
1015okv 13 c
1016okv 19 q
1017okv 1 a
1018okv 2 b
1019okv 38 bv and ea eb
1020oput 10
1021oflush
1022ok = and and eq s 0 eq c 0 and ne q 125 lt q 256
1023ret and ok and and eq a 1005 eq b 1005 and ea eb
1024end
1025
1026note unsupe: scratch run.err is exactly line 37 of tmsg (`a64: unsupported 2`) and a newline, kept at mem[rerr]
1027fn unsupe to bool
1028i = tline 4 37
1029e = tend 4 i
1030n = ulong 0
1031while le add i n e bound 64
1032put mem add rerr n uchar tch 4 add i n
1033n = add n 1
1034end
1035ret samef 16 rerr n
1036end
1037
1038note durefs: refusal fixtures that ng no longer refuses as durun requires (mutants, `@ng a64` only)
1039fn durefs to ulong
1040c = ulong 0
1041u = ulong 0
1042while lt u ndu bound 16
1043n = dxir 9 u
1044a = runng n 18
1045if or ne a 1005 not unsupe
1046c = add c 1
1047end
1048u = add u 1
1049end
1050ret c
1051end
1052
1053note dxcmp n k: the ΩIR at rir (n bytes; its producer's status in rg[0], printed under message k) through ngcheck,
1054note ngrun and both ng forms with dxrun's verdict; prints the rest of the line; ngrun's status in rg[2]
1055fn dxcmp n ulong k ulong to bool
1056s = get rg 0
1057c = runck
1058q = runrun
1059put rg 2 q
1060o1 = savout
1061e1 = saverr
1062a = runng n 18
1063so = samef 15 runit o1
1064se = samef 16 rerr e1
1065al = blbad
1066b = runng n 19
1067so = and so samef 15 runit o1
1068se = and se samef 16 rerr e1
1069dxmsg k s c q a al
1070okv 2 b
1071okv 16 bv so
1072okv 20 bv se
1073oput 10
1074oflush
1075ok = and eq s 0 eq c 0
1076ok = and ok and ne q 125 lt q 256
1077ok = and ok and eq a q eq b q
1078ret and ok and and so se eq al 0
1079end
1080
1081fn dxmsg k ulong s ulong c ulong q ulong a ulong al ulong to void
1082okv k s
1083okv 13 c
1084okv 19 q
1085okv 1 a
1086okv 14 al
1087end
1088
1089fn bv b bool to ulong
1090if b
1091ret 1
1092end
1093ret 0
1094end
1095
1096note fixture f: ngcheck accepts its ΩIR; both ng forms and the omc reference give the expected status, and the
1097note split and omc stdout equal the pairs stdout; the `@ng a64` ELF has every BL target aligned to 64
1098fn fxrun f ulong to bool
1099n = mkfx f
1100c = runck
1101a = runng n 18
1102o1 = savout
1103al = blbad
1104b = runng n 19
1105so = samef 15 runit o1
1106r = runref f
1107so = and so samef 15 runit o1
1108e = expect f
1109eom = get eo f
1110omsg 0
1111oput 32
1112otl 1 f
1113okv 13 c
1114okv 1 a
1115okv 14 al
1116okv 2 b
1117okv 3 r
1118okv 4 e
1119okv 15 eom
1120okv 16 bv so
1121oput 10
1122oflush
1123ok = and eq a e eq b e
1124ok = and ok and eq r eom so
1125ret and ok and eq c 0 eq al 0
1126end
1127
1128note mutant m (1..): rebuild ng with it; caught when some fixture's `@ng a64` status differs from the expected one
1129note (mkir fixtures) or from ngrun's (ngrun fixtures), or a BL target is misaligned
1130note Differential mutants must preserve every observable, not only the low-byte exit status.
1131fn dxmut n ulong d ulong to bool
1132q = runrun
1133o = savout
1134e = saverr
1135s = runng n 18
1136bb = blbad
1137same = and samef 15 runit o samef 16 rerr e
1138ret and and eq q get dq d eq s q and eq bb 0 same
1139end
1140
1141fn mutrun m ulong to bool
1142buildng m
1143c = ulong 0
1144f = ulong 0
1145while lt f nfx bound 16
1146n = mkfx f
1147s = runng n 18
1148bb = blbad
1149if or ne s expect f gt bb 0
1150c = add c 1
1151end
1152f = add f 1
1153end
1154d = ulong 0
1155while lt d ndx bound 128
1156n = dxir 5 d
1157if not dxmut n d
1158c = add c 1
1159end
1160d = add d 1
1161end
1162c = add c durefs
1163for j ulong nenv
1164k = add sub nfr nenv j
1165if ne frrun 6 k 6 k 22 0
1166c = add c 1
1167end
1168end
1169if and gt m mfl le m 79
1170c = add c flmuts
1171end
1172omsg 5
1173oput 32
1174odec m
1175oput 32
1176if gt c 0
1177omsg 6
1178else
1179omsg 7
1180end
1181oput 32
1182odec c
1183oput 10
1184oflush
1185ret gt c 0
1186end
1187
1188note ---- front phase: Omega source -> @ng front-ir -> ngcheck -> both a64 forms, against omc on a source ----
1189note frsrc t k: line k of text t and ".om" read to mem[0); its byte count
1190fn frsrc t ulong k ulong to ulong
1191pclr
1192ptl t k
1193ptl 0 5
1194ret readin 0 rir
1195end
1196
1197note frir t k: fx.in = the `@ng front-ir` line and source (t, k); ng.bin < fx.in > fx.ir; ng's status in rg[1]; the
1198note ΩIR at rir (its byte count; 0 when ng refuses)
1199fn frir t ulong k ulong to ulong
1200n = frsrc t k
1201pscr 12
1202fd = openw 420
1203wtl fd 0 33
1204wall fd 0 n
1205fclo fd
1206pscr 12
1207fi = openr
1208pscr 11
1209fo = openw 420
1210pscr 16
1211fe = openw 420
1212aclr
1213pscr 7
1214apb
1215s = spawn fi fo fe
1216put rg 1 s
1217if ne s 0
1218ret 0
1219end
1220pscr 11
1221ret readin rir 4194304
1222end
1223
1224note frref t k: omc builds source (t, k) into ref.bin, which runs (runbin); its status
1225fn frref t ulong k ulong to ulong
1226n = frsrc t k
1227omcb n 8 14
1228ret runbin 14
1229end
1230
1231note tmline b n: mem[b, b + n) is one line of decimal digits (OMC-EFF-2, a bench kernel's elapsed nanoseconds)
1232fn tmline b ulong n ulong to bool
1233if lt n 2
1234ret false
1235end
1236if ne get mem add b sub n 1 10
1237ret false
1238end
1239i = ulong 0
1240while lt i sub n 1 bound 65536
1241c = ulong get mem add b i
1242if or lt c 48 gt c 57
1243ret false
1244end
1245i = add i 1
1246end
1247ret true
1248end
1249
1250note errok e1: scratch run.err equals the e1 bytes kept at mem[rerr], or both are one timing line
1251fn errok e1 ulong to bool
1252if samef 16 rerr e1
1253ret true
1254end
1255if not tmline rerr e1
1256ret false
1257end
1258pscr 16
1259m = readin rin 65536
1260ret tmline rin m
1261end
1262
1263note frrun t k u j h: front-ir of source (t, k) through ngcheck and both a64 forms against omc's build of source
1264note (u, j); one output line headed by message h. 0 when all agree; 1 when the pipeline is sound (ng exits 0,
1265note ngcheck accepts, both statuses equal omc's, BL targets aligned) but stdout or stderr differs; 2 otherwise
1266fn frrun t ulong k ulong u ulong j ulong h ulong to ulong
1267put ev_ctl 0 0
1268if and eq t 6 ge k sub nfr nenv
1269put ev_ctl 0 1
1270end
1271put fv 0 frref u j
1272put fv 1 savout
1273put fv 2 saverr
1274frcmp frir t k
1275frout t k h
1276put ev_ctl 0 0
1277ret frverd
1278end
1279
1280note frcmp n: the comparisons for the n ΩIR bytes at rir into fv: 3 ng's status, 4 ngcheck's, 5 pairs, 6 split,
1281note 7 stdout same, 8 stderr same (or both one timing line), 9 misaligned BL targets (omc's status in fv 0, its
1282note stdout and stderr byte counts in fv 1 and 2)
1283fn frcmp n ulong to void
1284s = get rg 1
1285put fv 3 s
1286put fv 4 99
1287put fv 5 9999
1288put fv 6 9999
1289put fv 7 0
1290put fv 8 0
1291put fv 9 0
1292if ne s 0
1293ret
1294end
1295put fv 4 runck
1296put fv 5 runng n 18
1297so = samef 15 runit get fv 1
1298se = errok get fv 2
1299put fv 9 blbad
1300put fv 6 runng n 19
1301so = and so samef 15 runit get fv 1
1302se = and se errok get fv 2
1303put fv 7 bv so
1304put fv 8 bv se
1305end
1306
1307fn frout t ulong k ulong h ulong to void
1308omsg h
1309oput 32
1310otl t k
1311okv 23 get fv 3
1312okv 13 get fv 4
1313okv 1 get fv 5
1314okv 14 get fv 9
1315okv 2 get fv 6
1316okv 3 get fv 0
1317okv 16 get fv 7
1318okv 24 get fv 8
1319oput 10
1320oflush
1321end
1322
1323fn frverd to ulong
1324r = get fv 0
1325ok = and and eq get fv 3 0 eq get fv 4 0 eq get fv 9 0
1326if not and ok and eq get fv 5 r eq get fv 6 r
1327ret 2
1328end
1329if and eq get fv 7 1 eq get fv 8 1
1330ret 0
1331end
1332ret 1
1333end
1334
1335note frzero t k: a float source: front-ir exits 0, ngcheck accepts, both a64 forms refuse (exit 5); one output line
1336fn frzero t ulong k ulong to bool
1337n = frir t k
1338s = get rg 1
1339c = ulong 99
1340a = ulong 0
1341b = ulong 0
1342if eq s 0
1343c = runck
1344a = runng n 18
1345b = runng n 19
1346end
1347omsg 26
1348oput 32
1349otl t k
1350okv 23 s
1351okv 13 c
1352okv 1 a
1353okv 2 b
1354oput 10
1355oflush
1356ret and and eq s 0 eq c 0 and eq a 1005 eq b 1005
1357end
1358
1359fn main to int
1360envinit
1361rdscr
1362put ex 0 17
1363put ex 1 106
1364put ex 2 198
1365put ex 3 191
1366put ex 4 101
1367put ex 5 245
1368put ex 6 32
1369put ex 7 163
1370put ex 8 103
1371put ex 9 0
1372put ex 10 209
1373put ex 11 0
1374put ex 12 0
1375put ex 13 165
1376f = ulong 0
1377while lt f nfx bound 16
1378put eo f get ex f
1379f = add f 1
1380end
1381put eo 6 106
1382buildmk
1383buildck
1384buildng 0
1385buildas
1386buildrun
1387okf = ulong 0
1388f = ulong 0
1389while lt f nfx bound 16
1390if fxrun f
1391okf = add okf 1
1392end
1393f = add f 1
1394end
1395okd = ulong 0
1396d = ulong 0
1397while lt d ndx bound 128
1398if dxrun d
1399okd = add okd 1
1400end
1401d = add d 1
1402end
1403duphase
1404frphase
1405rdphase
1406flphase
1407okm = ulong 0
1408m = ulong 1
1409while le m nmut bound 128
1410if mutrun m
1411okm = add okm 1
1412end
1413m = add m 1
1414end
1415omsg 11
1416oput 32
1417odec okf
1418oput 47
1419odec nfx
1420oput 10
1421omsg 21
1422oput 32
1423odec okd
1424oput 47
1425odec ndx
1426oput 10
1427put fv 13 bv allsum
1428omsg 12
1429oput 32
1430odec okm
1431oput 47
1432odec nmut
1433oput 10
1434if and eq get fv 13 1 and and eq okf nfx eq okd ndx eq okm nmut
1435omsg 8
1436oput 10
1437oflush
1438ret 0
1439end
1440omsg 9
1441oput 10
1442oflush
1443ret 1
1444end
1445
1446note duphase: the refusal fixtures (durun); the number that pass in du[0]
1447fn duphase to void
1448ok = ulong 0
1449u = ulong 0
1450while lt u ndu bound 16
1451if durun u
1452ok = add ok 1
1453end
1454u = add u 1
1455end
1456put du 0 ok
1457end
1458
1459note dusum: the refusal fixtures' summary line; true when every one was refused as durun requires
1460fn dusum to bool
1461omsg 36
1462oput 32
1463odec get du 0
1464oput 47
1465odec ndu
1466oput 10
1467ret eq get du 0 ndu
1468end
1469
1470note allsum: the refusal, front, random and float summary lines, in that order; true when all four phases passed
1471fn allsum to bool
1472a = dusum
1473b = frsum
1474c = rdsum
1475d = flsum
1476ret and and a b and c d
1477end
1478
1479note frphase: the front phase; front cases ok in fv 10, refused float sources in fv 11, the control (1: the
1480note fib40 / fib39 comparison is sound and differs) in fv 12
1481fn frphase to void
1482okr = ulong 0
1483k = ulong 0
1484while lt k nfr bound 64
1485if eq frrun 6 k 6 k 22 0
1486okr = add okr 1
1487end
1488k = add k 1
1489end
1490put fv 10 okr
1491okz = ulong 0
1492k = ulong 0
1493while lt k nfz bound 8
1494if frzero 7 k
1495okz = add okz 1
1496end
1497k = add k 1
1498end
1499put fv 11 okz
1500put fv 12 bv eq frrun 8 0 8 1 27 1
1501end
1502
1503note frsum: the front phase's three summary lines; true when every case agreed, both floats were refused and the
1504note control differed
1505fn frsum to bool
1506omsg 25
1507oput 32
1508odec get fv 10
1509oput 47
1510odec nfr
1511oput 10
1512omsg 28
1513oput 32
1514odec get fv 11
1515oput 47
1516odec nfz
1517oput 10
1518omsg 29
1519oput 32
1520odec get fv 12
1521oput 10
1522ret and and eq get fv 10 nfr eq get fv 11 nfz eq get fv 12 1
1523end
1524
1525note ---- random phase (step 7): ngrand's seeded ΩIR (ng-ir, D9) against ngrun in both ng forms ----
1526fn buildrd to void
1527pset 2
1528n = readin 0 rir
1529pset 34
1530n = add n readin n sub rir n
1531omcb n 35 36
1532end
1533
1534note pdec v: the decimal digits of v appended to pb
1535fn pdec v ulong to void
1536d = ulong 1
1537while ge div v d 10 bound 20
1538d = mul d 10
1539end
1540x = v
1541while gt d 0 bound 20
1542pb1 add 48 div x d
1543x = rem x d
1544d = div d 10
1545end
1546end
1547
1548note rdir k: ngrand.bin k > fx.ir (stdin fx.name, stderr run.err); ngrand's status in rg[0]; the ΩIR at rir (its
1549note byte count, 0 when ngrand fails)
1550fn rdir k ulong to ulong
1551pscr 10
1552fi = openr
1553pscr 11
1554fo = openw 420
1555pscr 16
1556fe = openw 420
1557aclr
1558pscr 36
1559apb
1560pclr
1561pdec k
1562apb
1563s = spawn fi fo fe
1564put rg 0 s
1565if ne s 0
1566ret 0
1567end
1568pscr 11
1569ret readin rir 4194304
1570end
1571
1572note rdphase: seeds 1..nrd, each with dxrun's verdict (ngrand's status in place of ngas's); the number of seeds that
1573note pass in fv 14, the control in fv 15
1574fn rdphase to void
1575buildrd
1576ok = ulong 0
1577k = ulong 1
1578while le k nrd bound 4096
1579n = rdir k
1580omsg 30
1581oput 32
1582odec k
1583if dxcmp n 31
1584ok = add ok 1
1585end
1586k = add k 1
1587end
1588put fv 14 ok
1589put fv 15 bv rdctl
1590end
1591
1592note rdctl: the comparison tells programs apart: ngrun's run of seed 1 against the `@ng a64` ELF of seed 2 must be
1593note sound (ngrand and ngcheck accept both, ngrun's and the ELF's statuses are a program's) and differ in status or
1594note stdout
1595fn rdctl to bool
1596n = rdir 1
1597s = get rg 0
1598c = runck
1599q = runrun
1600o1 = savout
1601n = rdir 2
1602s = or s get rg 0
1603c = or c runck
1604a = runng n 18
1605so = samef 15 runit o1
1606omsg 33
1607okv 19 q
1608okv 1 a
1609okv 16 bv so
1610oput 10
1611oflush
1612ok = and and eq s 0 eq c 0 and lt q 256 lt a 256
1613ret and ok or ne a q not so
1614end
1615
1616fn rdsum to bool
1617omsg 32
1618oput 32
1619odec get fv 14
1620oput 47
1621odec nrd
1622oput 10
1623omsg 34
1624oput 32
1625odec get fv 15
1626oput 10
1627ret and eq get fv 14 nrd eq get fv 15 1
1628end
1629
1630note ---- float phase (step 8): frand's edge programs and seeded units against ngrun in both ng forms ----
1631fn buildfr to void
1632pset 37
1633n = readin 0 rir
1634omcb n 38 39
1635end
1636
1637note flir e k: frand.bin K (e: frand.bin edge K) > fr.oir (stdin fx.name, stderr run.err), then ngas.bin < fr.oir >
1638note fx.ir; the status of frand, or of ngas when frand exits 0, in rg[0]; the ΩIR at rir (its byte count, 0 when
1639note either fails)
1640fn flir e bool k ulong to ulong
1641pscr 10
1642fi = openr
1643pscr 40
1644fo = openw 420
1645pscr 16
1646fe = openw 420
1647aclr
1648pscr 39
1649apb
1650if e
1651pset 41
1652apb
1653end
1654pclr
1655pdec k
1656apb
1657s = spawn fi fo fe
1658put rg 0 s
1659if ne s 0
1660ret 0
1661end
1662pscr 40
1663fi = openr
1664pscr 11
1665fo = openw 420
1666pscr 16
1667fe = openw 420
1668aclr
1669pscr 29
1670apb
1671s = spawn fi fo fe
1672put rg 0 s
1673if ne s 0
1674ret 0
1675end
1676pscr 11
1677ret readin rir 4194304
1678end
1679
1680note flphase: edge programs 1..nfe and seeds 1..nfl, each with dxcmp's verdict; the edges that pass in fv 16, the
1681note seeds in fv 17, the control in fv 18
1682fn flphase to void
1683buildfr
1684ok = ulong 0
1685k = ulong 1
1686while le k nfe bound 128
1687n = flir true k
1688omsg 39
1689oput 32
1690odec k
1691if dxcmp n 40
1692ok = add ok 1
1693end
1694k = add k 1
1695end
1696put fv 16 ok
1697ok = 0
1698k = ulong 1
1699while le k nfl bound 4096
1700n = flir false k
1701omsg 42
1702oput 32
1703odec k
1704if dxcmp n 40
1705ok = add ok 1
1706end
1707k = add k 1
1708end
1709put fv 17 ok
1710put fv 18 bv flctl
1711end
1712
1713note flctl: the comparison tells float programs apart: ngrun's run of float seed 1 against the `@ng a64` ELF of
1714note float seed 2 must be sound (frand, ngas and ngcheck accept both, both statuses a program's) and differ in status
1715note or stdout
1716fn flctl to bool
1717n = flir false 1
1718s = get rg 0
1719c = runck
1720q = runrun
1721o1 = savout
1722n = flir false 2
1723s = or s get rg 0
1724c = or c runck
1725a = runng n 18
1726so = samef 15 runit o1
1727omsg 44
1728okv 19 q
1729okv 1 a
1730okv 16 bv so
1731oput 10
1732oflush
1733ok = and and eq s 0 eq c 0 and lt q 256 lt a 256
1734ret and ok or ne a q not so
1735end
1736
1737fn flsum to bool
1738omsg 41
1739oput 32
1740odec get fv 16
1741oput 47
1742odec nfe
1743oput 10
1744omsg 43
1745oput 32
1746odec get fv 17
1747oput 47
1748odec nfl
1749oput 10
1750omsg 45
1751oput 32
1752odec get fv 18
1753oput 10
1754ret and and eq get fv 16 nfe eq get fv 17 nfl eq get fv 18 1
1755end
1756
1757note flmut n: the ΩIR at rir (n bytes) under a mutant: ngrun runs it and `@ng a64` must give its status, stdout and
1758note stderr byte for byte with BL targets aligned (dxmut with ngrun rerun, as there is no stored status)
1759fn flmut n ulong to bool
1760q = runrun
1761o = savout
1762e = saverr
1763s = runng n 18
1764bb = blbad
1765same = and samef 15 runit o samef 16 rerr e
1766ret and and eq s q eq bb 0 same
1767end
1768
1769note flmuts: the float programs (edges 1..nfe, seeds 1..nfm) that a float mutant changes; a program frand or ngas
1770note does not give is step 18 (the float phase already passed them unmutated)
1771fn flmuts to ulong
1772c = ulong 0
1773k = ulong 1
1774while le k add nfe nfm bound 128
1775n = ulong 0
1776if le k nfe
1777n = flir true k
1778else
1779n = flir false sub k nfe
1780end
1781if eq n 0
1782fail 18
1783end
1784if not flmut n
1785c = add c 1
1786end
1787k = add k 1
1788end
1789ret c
1790end