diff options
Diffstat (limited to 'tests/tst-immediate-exactness-runner.sh')
| -rwxr-xr-x | tests/tst-immediate-exactness-runner.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/tst-immediate-exactness-runner.sh b/tests/tst-immediate-exactness-runner.sh new file mode 100755 index 0000000..3fc3a42 --- /dev/null +++ b/tests/tst-immediate-exactness-runner.sh @@ -0,0 +1,65 @@ +#!/bin/sh +set -eu +: "${CPU_AS:?}" +TMP="${TMPDIR:-/tmp}/libcpu-imm-$$" +trap 'rm -f "$TMP".s "$TMP".o "$TMP".err "$TMP".out' EXIT HUP INT TERM +cat > "$TMP.s" <<'EOS' +.text +LDR r4096@0x00000, 3.14243987129849274029174912694696912849214e-286 +HALT +EOS +if "$CPU_AS" -o "$TMP.o" "$TMP.s" >"$TMP.out" 2>"$TMP.err"; then + echo "cpu-as unexpectedly accepted inexact wide LDR" >&2 + exit 1 +fi +grep -F "$TMP.s:2: error:" "$TMP.err" >/dev/null +grep -F 'LDR immediate is not exactly representable as real64;' "$TMP.err" >/dev/null +grep -F 'use .real <bits>, value in DATA and LOAD' "$TMP.err" >/dev/null + +cat > "$TMP.s" <<'EOS' +.text +LDR r32@0x00000, 0.1 +HALT +EOS +if "$CPU_AS" -o "$TMP.o" "$TMP.s" >"$TMP.out" 2>"$TMP.err"; then + echo "cpu-as unexpectedly accepted inexact real32 LDR" >&2 + exit 1 +fi +grep -F 'LDR immediate is not exactly representable as real32;' "$TMP.err" >/dev/null + +cat > "$TMP.s" <<'EOS' +.text +LDC c128@0x00000, 0.1r0+32.0j0 +HALT +EOS +if "$CPU_AS" -o "$TMP.o" "$TMP.s" >"$TMP.out" 2>"$TMP.err"; then + echo "cpu-as unexpectedly accepted inexact complex immediate" >&2 + exit 1 +fi +grep -F 'LDC immediate component is not exactly representable as real32;' "$TMP.err" >/dev/null +grep -F 'use .complex <bits>, real, imag in DATA and LOAD' "$TMP.err" >/dev/null + +cat > "$TMP.s" <<'EOS' +.text +LDI r8@0x00000, 255 +HALT +EOS +if "$CPU_AS" -o "$TMP.o" "$TMP.s" >"$TMP.out" 2>"$TMP.err"; then + echo "cpu-as unexpectedly accepted lossy narrow integer immediate" >&2 + exit 1 +fi +grep -F 'LDI immediate is not exactly representable as integer8;' "$TMP.err" >/dev/null +grep -F 'use .integer <bits>, value in DATA and LOAD' "$TMP.err" >/dev/null + +cat > "$TMP.s" <<'EOS' +.text +LDI r128@0x00000, 9223372036854775808 +HALT +EOS +if "$CPU_AS" -o "$TMP.o" "$TMP.s" >"$TMP.out" 2>"$TMP.err"; then + echo "cpu-as unexpectedly accepted integer wider than IMM64" >&2 + exit 1 +fi +grep -F 'LDI immediate is not exactly representable as integer64;' "$TMP.err" >/dev/null + +echo 'libcpu immediate exactness runner regression: PASS' |
