From 8c5ba37d098bc90f7064fb825ed0abdadd4e87c3 Mon Sep 17 00:00:00 2001 From: David Mak Date: Fri, 26 Jul 2024 10:42:40 +0800 Subject: [PATCH] standalone: Add 32-bit execution tests to check_demo.sh --- nac3standalone/demo/check_demo.sh | 25 +++++++++++++++++-------- nac3standalone/demo/run_demo.sh | 20 ++++++++++++++++---- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/nac3standalone/demo/check_demo.sh b/nac3standalone/demo/check_demo.sh index d481af85..272b4ea0 100755 --- a/nac3standalone/demo/check_demo.sh +++ b/nac3standalone/demo/check_demo.sh @@ -14,12 +14,21 @@ while [ $# -gt 1 ]; do done demo="$1" -echo -n "Checking $demo... " -./interpret_demo.py "$demo" > interpreted.log -./run_demo.sh --out run.log "${nac3args[@]}" "$demo" -./run_demo.sh --lli --out run_lli.log "${nac3args[@]}" "$demo" -diff -Nau interpreted.log run.log -diff -Nau interpreted.log run_lli.log -echo "ok" +echo "### Checking $demo..." -rm -f interpreted.log run.log run_lli.log \ No newline at end of file +# Get reference output +echo ">>>>>> Running $demo with the Python interpreter" +./interpret_demo.py "$demo" > interpreted.log + +echo "...... Trying NAC3's 32-bit code generator output" +./run_demo.sh -m32 --out run_32.log "${nac3args[@]}" "$demo" +diff -Nau interpreted.log run_32.log + +echo "...... Trying NAC3's 64-bit code generator output" +./run_demo.sh --out run_64.log "${nac3args[@]}" "$demo" +diff -Nau interpreted.log run_64.log + +echo "...... OK" + +rm -f interpreted.log \ + run_32.log run_64.log \ No newline at end of file diff --git a/nac3standalone/demo/run_demo.sh b/nac3standalone/demo/run_demo.sh index 01a1de3e..5d1380fc 100755 --- a/nac3standalone/demo/run_demo.sh +++ b/nac3standalone/demo/run_demo.sh @@ -11,7 +11,7 @@ declare -a nac3args while [ $# -ge 1 ]; do case "$1" in --help) - echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] -- [NAC3ARGS...]" + echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] [-m32] -- [NAC3ARGS...]" exit ;; --out) @@ -21,6 +21,9 @@ while [ $# -ge 1 ]; do --debug) debug=1 ;; + -m32) + m32=1 + ;; --) shift break @@ -48,10 +51,19 @@ fi rm -f ./*.o ./*.bc demo -$nac3standalone "${nac3args[@]}" +if [ -z "$m32" ]; then + $nac3standalone "${nac3args[@]}" -clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c -clang -lm -o demo module.o demo.o + clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c + clang -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o +else + # Enable SSE2 to avoid rounding errors with X87's 80-bit fp precision computations + + $nac3standalone --triple i386-pc-linux-gnu --target-features +sse2 "${nac3args[@]}" + + clang -m32 -c -std=gnu11 -Wall -Wextra -O3 -msse2 -o demo.o demo.c + clang -m32 -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o +fi if [ -z "$outfile" ]; then ./demo