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/blob/main/seed/omc/tests/nocaps/groups.sh # 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 branch `main` Branches Tags History `omega-mv / seed / omc / tests / nocaps / groups.sh` 96 lines ยท 7223 bytes Raw Blame History 1 #!/bin/sh 2 # groups.sh DIR -- write one unit per arena group of omc into DIR, each driving its group past the first 3 # room the group is given (OMEGESE 9.6: a_isize gives names, long names, functions, calls and trap sites an 4 # input-sized first room of at most 8192 entries; every other group starts at 64 entries; the output starts 5 # at 65536 bytes). For each NAME.om: 6 # NAME.grp lines "GROUP MIN": in the unit's omc-use record, GROUP=N/H must have N >= MIN, a count past 7 # that group's largest first room, so the group grew (N is what the group was asked to hold) 8 # NAME.want the exit status the compiled program must give (absent: the unit is compiled only) 9 # NAME.run how the program runs: "native" (AArch64, default) or "x86" (qemu-x86_64, EMULATED) 10 # gate-nocaps step 4 compiles every unit with seed/out/omc and with a checked twin of the same source (each 11 # inline table access a region-checked call: an index past its region is trap 3 there, exit 103). 12 set -eu 13 D=$1 14 mkdir -p "$D" 15 # names: 9,000 globals and the input past 64 KiB; the first and the last keep their values apart: 5 + 7 = 12. 16 awk 'BEGIN { for (i = 0; i < 9000; i++) printf "global g%d uint 1\n", i; print "fn main to int" 17 print "put g0 0 uint 5"; print "put g8999 0 uint 7"; print "ret int add get g0 0 get g8999 0"; print "end" }' > "$D/names.om" 18 echo 12 > "$D/names.want" 19 printf 'names 8193\nnamehash 1025\ninp 65536\n' > "$D/names.grp" 20 # longnames: 9,000 names of 9..63 bytes (the long-name table and its hash): 5 + 7 = 12. 21 awk 'BEGIN { for (i = 0; i < 9000; i++) printf "global a_long_global_%05d uint 1\n", i; print "fn main to int" 22 print "put a_long_global_00000 0 uint 5"; print "put a_long_global_08999 0 uint 7" 23 print "ret int add get a_long_global_00000 0 get a_long_global_08999 0"; print "end" }' > "$D/longnames.om" 24 echo 12 > "$D/longnames.want" 25 printf 'long 8193\nlonghash 1025\n' > "$D/longnames.grp" 26 # fns: 9,000 functions (and the function hash); main calls the first and the last: 0 + 8999, mod 256 = 39. 27 awk 'BEGIN { for (i = 0; i < 9000; i++) printf "fn q%d to ulong\nret %d\nend\n", i, i 28 print "fn main to int"; print "a = q0"; print "b = q8999"; print "ret int rem add a b 256"; print "end" }' > "$D/fns.om" 29 echo 39 > "$D/fns.want" 30 printf 'fns 8193\nfnhash 1025\n' > "$D/fns.grp" 31 # calls: 9,000 calls in one function, past 64 KiB of output: 9000 mod 256 = 40. 32 awk 'BEGIN { print "fn inc x ulong to ulong"; print "ret add x 1"; print "end"; print "fn main to int"; print "x = ulong 0" 33 for (i = 0; i < 9000; i++) print "x = inc x"; print "ret int rem x 256"; print "end" }' > "$D/calls.om" 34 echo 40 > "$D/calls.want" 35 printf 'calls 8193\nout 65537\n' > "$D/calls.grp" 36 # traps: 9,000 trap sites (each signed add can overflow): 9000 mod 256 = 40. 37 awk 'BEGIN { print "fn main to int"; print "x = long 0"; for (i = 0; i < 9000; i++) print "x = add x long 1" 38 print "ret int rem x long 256"; print "end" }' > "$D/traps.om" 39 echo 40 > "$D/traps.want" 40 printf 'traps 8193\n' > "$D/traps.grp" 41 # blocks: 300 blocks nested; the innermost returns 9. 42 awk 'BEGIN { print "fn main to int"; print "x = ulong 1"; for (i = 0; i < 300; i++) print "if eq x 1" 43 print "ret 9"; for (i = 0; i < 300; i++) print "end"; print "ret 0"; print "end" }' > "$D/blocks.om" 44 echo 9 > "$D/blocks.want" 45 printf 'blocks 65\n' > "$D/blocks.grp" 46 # breaks: one loop with 300 breaks (the break list is per loop), each taken at x = 150; x counts up from 0. 47 awk 'BEGIN { print "fn main to int"; print "x = ulong 0"; print "while true" 48 for (k = 0; k < 300; k++) { print "if eq x 150"; print "break"; print "end" } 49 print "x = add x 1"; print "end"; print "ret int x"; print "end" }' > "$D/breaks.om" 50 echo 150 > "$D/breaks.want" 51 printf 'breaks 65\n' > "$D/breaks.grp" 52 # conts: 300 continues in one loop that runs 3 times; each pass takes the continue at k = x and x counts 53 # them: 3. 54 awk 'BEGIN { print "fn main to int"; print "x = ulong 0"; print "i = ulong 0"; print "while lt i 3"; print "i = add i 1" 55 for (k = 0; k < 300; k++) { printf "if eq rem x 300 %d\n", k; print "x = add x 1"; print "continue"; print "end" } 56 print "end"; print "ret int rem x 256"; print "end" }' > "$D/conts.om" 57 echo 3 > "$D/conts.want" 58 printf 'conts 65\n' > "$D/conts.grp" 59 # inlret: an inline function with 300 rets, expanded once: it returns its argument, 150. 60 awk 'BEGIN { print "om2"; print "fn pick x ulong to ulong inline"; for (k = 0; k < 300; k++) { printf "if eq x %d\n", k; printf "ret %d\n", k; print "end" } 61 print "ret 0"; print "end"; print "fn main to int"; print "y = pick 150"; print "ret int y"; print "end" }' > "$D/inlret.om" 62 echo 150 > "$D/inlret.want" 63 printf 'inlret 65\n' > "$D/inlret.grp" 64 # inledge: 1,000 inline edges and no call (12 leaves, a root expanding them, 76 functions expanding the 65 # root: 13 * 76 + 12); main returns the root, 12. 66 awk 'BEGIN { print "om2"; for (i = 1; i <= 12; i++) printf "fn b%d to int inline\nret 1\nend\n", i 67 print "fn a to int inline"; print "x = int 0"; for (i = 1; i <= 12; i++) printf "x = add x b%d\n", i; print "ret x"; print "end" 68 for (j = 1; j < 76; j++) printf "fn g%d to int\nret a\nend\n", j; print "fn main to int"; print "ret a"; print "end" }' > "$D/inledge.om" 69 echo 12 > "$D/inledge.want" 70 printf 'inledge 1000\n' > "$D/inledge.grp" 71 # depth: a value nested 300 deep (300 conversions of y, which is 7). 72 awk 'BEGIN { print "fn main to int"; print "y = ulong 7"; printf "x = "; for (i = 0; i < 300; i++) printf "ulong " 73 print "y"; print "ret int rem x 256"; print "end" }' > "$D/depth.om" 74 echo 7 > "$D/depth.want" 75 printf 'depth 65\n' > "$D/depth.grp" 76 # site: an om2 diag unit with 300 trap sites (one omc-site record each on stderr): 300 mod 256 = 44. 77 awk 'BEGIN { print "om2 diag"; print "fn main to int"; print "x = long 0"; for (i = 0; i < 300; i++) print "x = add x long 1" 78 print "ret int rem x long 256"; print "end" }' > "$D/site.om" 79 echo 44 > "$D/site.want" 80 printf 'site 65\n' > "$D/site.grp" 81 # kahn: a function-mode unit (no main) of 300 functions, each calling the one before it (ksettle). 82 awk 'BEGIN { print "fn k0 x ulong to ulong"; print "ret x"; print "end" 83 for (i = 1; i < 300; i++) { printf "fn k%d x ulong to ulong\n", i; printf "ret k%d add x 1\n", i - 1; print "end" } }' > "$D/kahn.om" 84 printf 'kahnfn 65\nkahncall 65\n' > "$D/kahn.grp" 85 # x86addr: target x86linux, 300 globals each read at a variable index (an address fixup each): 300 mod 256 = 44. 86 awk 'BEGIN { print "target x86linux"; for (i = 0; i < 300; i++) printf "global g%d uint 1\n", i; print "fn main to int"; print "s = uint 0" 87 print "i = ulong 0"; for (i = 0; i < 300; i++) printf "put g%d i uint 1\n", i; for (i = 0; i < 300; i++) printf "s = add s get g%d i\n", i 88 print "ret int rem s 256"; print "end" }' > "$D/x86addr.om" 89 echo 44 > "$D/x86addr.want" 90 echo x86 > "$D/x86addr.run" 91 printf 'x86addr 65\n' > "$D/x86addr.grp" 92 # x86exit: target x86efi, 300 exit statements (each a branch to the shared firmware return): compiled only. 93 awk 'BEGIN { print "target x86efi"; print "fn main to int"; print "x = ulong 7" 94 for (k = 0; k < 300; k++) { printf "if eq x %d\n", k; printf "exit %d\n", k; print "end" } 95 print "ret 0"; print "end" }' > "$D/x86exit.om" 96 printf 'x86exit 65\n' > "$D/x86exit.grp"