summaryrefslogtreecommitdiff
path: root/tests/tst-immediate-exactness-runner.sh
blob: 3fc3a42220ae11896175ba67c92f583adf3875df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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'