omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / omc / gate8.sh
| 1 | #!/bin/sh |
| 2 | # gate8.sh -- f32 and f64 (OMEGESE 9.9). seed/out/omc is the compiler under test; it is built and |
| 3 | # proved self-identical by seed/omega-from-seed.sh. Expected bit patterns were computed outside this |
| 4 | # compiler (IEEE-754), never copied from it. om4 refuses every float word, which is checked here too. |
| 5 | # RC=0 only when every case below ran and passed. |
| 6 | set -eu |
| 7 | R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 8 | cd "$R" |
| 9 | B=build/seed/r8 |
| 10 | T=seed/omc/tests/float |
| 11 | S=seed/out/omc |
| 12 | OM4=seed/rung4/om4.bin |
| 13 | mkdir -p "$B" |
| 14 | [ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; } |
| 15 | bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } |
| 16 | say() { printf '%s\n' "$*"; } |
| 17 | |
| 18 | for f in f64_bits.om f32_bits.om; do |
| 19 | set +e |
| 20 | "$OM4" < "$T/$f" > "$B/om4-$f.bin" 2> "$B/om4-$f.err" |
| 21 | orc=$? |
| 22 | set -e |
| 23 | [ "$orc" != 0 ] || bad "om4 accepted float syntax in $f" |
| 24 | done |
| 25 | say "PASS om4 refuses float syntax" |
| 26 | |
| 27 | n=0 |
| 28 | run_ok() { # name |
| 29 | n=$((n+1)) |
| 30 | set +e |
| 31 | "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err" |
| 32 | crc=$? |
| 33 | set -e |
| 34 | [ "$crc" = 0 ] || bad "$1: compiler exit $crc ($(cat "$B/$1.err"))" |
| 35 | chmod +x "$B/$1.bin" |
| 36 | set +e |
| 37 | "$B/$1.bin" > /dev/null |
| 38 | rrc=$? |
| 39 | set -e |
| 40 | [ "$rrc" = 0 ] || bad "$1: ran $rrc, wanted 0" |
| 41 | say "PASS $1 exit 0" |
| 42 | } |
| 43 | |
| 44 | refuse() { # name expect-error |
| 45 | n=$((n+1)) |
| 46 | set +e |
| 47 | "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err" |
| 48 | crc=$? |
| 49 | set -e |
| 50 | [ "$crc" = "$2" ] || bad "$1: compiler exit $crc, wanted $2 ($(cat "$B/$1.err"))" |
| 51 | grep -q "error $2" "$B/$1.err" || bad "$1: diagnostic does not name error $2" |
| 52 | say "PASS $1 error $2" |
| 53 | } |
| 54 | |
| 55 | # The same unit under each x86 target (FR-9 rows neg_fma_*): x86 refuses fma (error 9: no FMA3, no |
| 56 | # unfused fallback) only after typing its operands, so an ill-typed fma gets AArch64's exact |
| 57 | # refusal there, one line later for the prepended target line. Run after refuse NAME. |
| 58 | refuse_x86() { # name expect-error |
| 59 | al=$(sed -n "s/^omc: line \([0-9]*\): error $2\$/\1/p" "$B/$1.err") |
| 60 | [ -n "$al" ] || bad "$1: no AArch64 diagnostic for error $2" |
| 61 | for tg in x86linux x86efi; do |
| 62 | n=$((n+1)) |
| 63 | { printf 'target %s\n' "$tg"; cat "$T/$1.om"; } > "$B/$1.$tg.om" |
| 64 | set +e |
| 65 | "$S" < "$B/$1.$tg.om" > "$B/$1.$tg.bin" 2> "$B/$1.$tg.err" |
| 66 | crc=$? |
| 67 | set -e |
| 68 | [ "$crc" = "$2" ] || bad "$1 ($tg): compiler exit $crc, wanted $2 ($(cat "$B/$1.$tg.err"))" |
| 69 | printf 'omc: line %s: error %s\n' "$((al+1))" "$2" | cmp -s - "$B/$1.$tg.err" \ |
| 70 | || bad "$1 ($tg): diagnostic $(cat "$B/$1.$tg.err"), wanted line $((al+1)) error $2" |
| 71 | say "PASS $1 $tg error $2" |
| 72 | done |
| 73 | } |
| 74 | |
| 75 | run_ok f64_bits |
| 76 | run_ok f32_bits |
| 77 | run_ok arith |
| 78 | run_ok compare |
| 79 | run_ok convert |
| 80 | run_ok arrays |
| 81 | run_ok globals |
| 82 | run_ok params |
| 83 | run_ok structs |
| 84 | run_ok intrinsics |
| 85 | run_ok f32_return |
| 86 | run_ok fma |
| 87 | refuse neg_fma_int 7 |
| 88 | refuse neg_fma_int2 7 |
| 89 | refuse neg_fma_int3 7 |
| 90 | refuse neg_fma_mix2 7 |
| 91 | refuse neg_fma_mix3 7 |
| 92 | refuse neg_fma_ambig 11 |
| 93 | refuse neg_fma_ambig2 11 |
| 94 | refuse neg_fma_ambig3 11 |
| 95 | refuse_x86 neg_fma_int 7 |
| 96 | refuse_x86 neg_fma_int2 7 |
| 97 | refuse_x86 neg_fma_int3 7 |
| 98 | refuse_x86 neg_fma_mix2 7 |
| 99 | refuse_x86 neg_fma_mix3 7 |
| 100 | refuse_x86 neg_fma_ambig 11 |
| 101 | refuse_x86 neg_fma_ambig2 11 |
| 102 | refuse_x86 neg_fma_ambig3 11 |
| 103 | refuse neg_fma_x86 9 |
| 104 | refuse neg_fma_x86efi 9 |
| 105 | refuse neg_fma_ir 3 |
| 106 | run_ok convert_sat |
| 107 | run_ok vreg |
| 108 | run_ok vcmp |
| 109 | run_ok bitcast_int |
| 110 | refuse neg_intr_int 7 |
| 111 | refuse neg_intr_mixed 7 |
| 112 | refuse neg_intr_ambig 11 |
| 113 | refuse neg_mixed 7 |
| 114 | refuse neg_index 7 |
| 115 | refuse neg_for 7 |
| 116 | refuse neg_read 7 |
| 117 | refuse neg_ambiguous 11 |
| 118 | refuse neg_dot 6 |
| 119 | refuse neg_overflow 8 |
| 120 | refuse neg_overflow2 8 |
| 121 | refuse neg_overflow3 8 |
| 122 | refuse neg_ir 3 |
| 123 | refuse neg_void_value 7 |
| 124 | refuse neg_f32_fall 18 |
| 125 | refuse neg_bitcast_width 7 |
| 126 | refuse neg_int_assign 7 |
| 127 | refuse neg_int_ret 7 |
| 128 | refuse neg_int_arg 7 |
| 129 | refuse neg_int_put 7 |
| 130 | |
| 131 | # Literal rounding (#1024): 512 literals, each rounded once to nearest even. lit_round.want holds the |
| 132 | # bits from seed/omc/float-lits.py's exact rational oracle (Python fractions), never from omc. |
| 133 | n=$((n+1)) |
| 134 | "$S" < "$T/lit_round.om" > "$B/lit_round.bin" 2> "$B/lit_round.err" || bad "lit_round: compiler refused it ($(cat "$B/lit_round.err"))" |
| 135 | chmod +x "$B/lit_round.bin" |
| 136 | "$B/lit_round.bin" | od -An -v -tx8 -w8 | tr -d ' ' > "$B/lit_round.got" |
| 137 | cut -d' ' -f1 "$T/lit_round.want" | cmp -s - "$B/lit_round.got" || bad "lit_round: bits differ from lit_round.want" |
| 138 | say "PASS lit_round $(wc -l < "$T/lit_round.want") literals" |
| 139 | |
| 140 | say "PASS gate8 $n cases" |
| 141 | exit 0 |