codegen: fix bug on riscv when --ptrcomp was used
[ajla.git] / test.sh
blobea6b7121876c7cc2cf55aae35f10aeb29b269f71
1 #!/bin/sh -ex
3 # Copyright (C) 2024 Mikulas Patocka
5 # This file is part of Ajla.
7 # Ajla is free software: you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation, either version 3 of the License, or (at your option) any later
10 # version.
12 # Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Ajla. If not, see <https://www.gnu.org/licenses/>.
19 targets=" \
20 aarch64-linux-gnu \
21 alpha-linux-gnu \
22 arm-linux-gnueabi \
23 arm-linux-gnueabihf \
24 hppa-linux-gnu \
25 loongarch64-linux-gnu \
26 m68k-linux-gnu \
27 mips-linux-gnu \
28 mips64-linux-gnuabi64 \
29 mips64el-linux-gnuabi64 \
30 mipsel-linux-gnu \
31 mipsisa32r6-linux-gnu \
32 mipsisa32r6el-linux-gnu \
33 mipsisa64r6-linux-gnuabi64 \
34 mipsisa64r6el-linux-gnuabi64 \
35 powerpc-linux-gnu \
36 powerpc64-linux-gnu \
37 powerpc64le-linux-gnu \
38 riscv64-linux-gnu \
39 s390x-linux-gnu \
40 sh4-linux-gnu \
41 sparc64-linux-gnu \
42 x86_64-linux-gnu \
44 if [ "$#" -gt 0 ]; then
45 targets="$@"
47 for a in $targets; do
48 if ! which $a-gcc; then
49 echo $a-gcc not found
50 continue
52 PFX=""
53 MLIB=""
54 case "$a" in
55 mips-linux-gnu) MLIB="-mabi=n32";;
56 mipsel-linux-gnu) MLIB="-mabi=n32";;
57 mipsisa32r6-linux-gnu) PFX="qemu-mips -L /usr/mipsisa32r6-linux-gnu/";;
58 mipsisa32r6el-linux-gnu) PFX="qemu-mipsel -L /usr/mipsisa32r6el-linux-gnu/";;
59 mipsisa64r6-linux-gnuabi64) PFX="qemu-mips64 -L /usr/mipsisa64r6-linux-gnuabi64/";;
60 mipsisa64r6el-linux-gnuabi64) PFX="qemu-mips64el -L /usr/mipsisa64r6el-linux-gnuabi64/";;
61 x86_64-linux-gnu) MLIB="-m32 -mx32";;
62 esac
63 for m in '' $MLIB; do
64 for b in '' --enable-bitwise-frame; do
65 CC="$a-gcc $m" CF='-O1 -DDEBUG_ENV' ./rebuild --host=$a $b
66 do_ptrcomp=true
67 case "$a" in
68 arm-linux-gnueabi |\
69 arm-linux-gnueabihf |\
70 hppa-linux-gnu |\
71 m68k-linux-gnu |\
72 mips-linux-gnu |\
73 mipsel-linux-gnu |\
74 mipsisa32r6-linux-gnu |\
75 mipsisa32r6el-linux-gnu |\
76 powerpc-linux-gnu) do_ptrcomp=false;;
77 x86_64-linux-gnu) if [ "$m" = -m32 -o "$m" = -mx32 ]; then do_ptrcomp=false; fi;;
78 esac
79 $PFX ./ajla programs/test/empty.ajla
80 $PFX ./ajla programs/test/test.ajla 2
81 $PFX ./ajla programs/test/test.ajla 100
82 $PFX ./ajla programs/test/test-fp.ajla 2
83 $PFX ./ajla programs/test/test-fp.ajla 50
84 if $do_ptrcomp; then
85 $PFX ./ajla --ptrcomp programs/test/empty.ajla
86 $PFX ./ajla --ptrcomp programs/test/test.ajla 2
87 $PFX ./ajla --ptrcomp programs/test/test.ajla 100
88 $PFX ./ajla --ptrcomp programs/test/test-fp.ajla 2
89 $PFX ./ajla --ptrcomp programs/test/test-fp.ajla 50
91 done
92 done
93 done