diff options
| author | Alasdair Armstrong | 2019-03-27 16:21:05 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2019-03-27 16:32:08 +0000 |
| commit | 790de19f73f1c164aba2259a6fe3f1a50eeff70c (patch) | |
| tree | 10111abcc6596db21754ef8917e77dc80b46cd96 /test | |
| parent | deab63011f13417cf305d292a5bf959bd20b79bc (diff) | |
Interactive: Refactor sail.ml
Rather than having a separate variable for each backend X,
opt_print_X, just have a single variable opt_print_target, where
target contains a string option, such as `Some "lem"` or `Some
"ocaml"`, then we have a function target that takes that string and
invokes the appropriate backend, so the main function in sail.ml goes
from being a giant if-then-else block to a single call to
target !opt_target ast env
This allows us to implement a :compile <target> command in the
interactive toplevel
Also implement a :rewrites <target> command which performs all the
rewrites for a specific target, so rather than doing e.g.
> sail -c -O -o out $FILES
one could instead interactively do
> sail -i
:option -undefined_gen
:load $FILES
:option -O
:option -o out
:rewrites c
:compile c
:quit
for the same result.
To support this the behavior of the interactive mode has changed
slightly. It no longer performs any rewrites at all, so a :rewrites
interpreter is currently needed to interpret functions in the
interactive toplevel, nor does it automatically set any other flags,
so -undefined_gen is needed in this case, which is usually implied by
the -c flag.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/arm/run_tests.sh | 2 | ||||
| -rw-r--r-- | test/arm/test.isail | 1 | ||||
| -rw-r--r-- | test/c/execute.isail | 1 | ||||
| -rwxr-xr-x | test/c/run_tests.py | 2 | ||||
| -rw-r--r-- | test/ocaml/bitfield/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/hello_world/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/loop/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/lsl/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/pattern1/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/reg_alias/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/reg_passing/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/reg_ref/test.isail | 1 | ||||
| -rwxr-xr-x | test/ocaml/run_tests.sh | 2 | ||||
| -rw-r--r-- | test/ocaml/short_circuit/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/string_equality/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/string_of_struct/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/trycatch/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/types/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/vec_32_64/test.isail | 1 | ||||
| -rw-r--r-- | test/ocaml/void/test.isail | 1 |
20 files changed, 20 insertions, 3 deletions
diff --git a/test/arm/run_tests.sh b/test/arm/run_tests.sh index b24cc584..9d7af14f 100755 --- a/test/arm/run_tests.sh +++ b/test/arm/run_tests.sh @@ -83,7 +83,7 @@ printf "\nLoading specification into interpreter...\n" cd $SAILDIR/aarch64 -if $SAILDIR/sail -no_lexp_bounds_check -is $DIR/test.isail no_vector.sail 1> /dev/null 2> /dev/null; +if $SAILDIR/sail -undefined_gen -no_lexp_bounds_check -is $DIR/test.isail no_vector.sail 1> /dev/null 2> /dev/null; then green "loaded no_vector specification" "ok"; diff --git a/test/arm/test.isail b/test/arm/test.isail index 8775ed8f..f3f4dfa1 100644 --- a/test/arm/test.isail +++ b/test/arm/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter :elf ../test/arm/test_O2.elf :output ../test/arm/iresult initialize_registers() diff --git a/test/c/execute.isail b/test/c/execute.isail index f4b5ea0f..018dd92c 100644 --- a/test/c/execute.isail +++ b/test/c/execute.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run main() diff --git a/test/c/run_tests.py b/test/c/run_tests.py index 2ee44fca..be953749 100755 --- a/test/c/run_tests.py +++ b/test/c/run_tests.py @@ -40,7 +40,7 @@ def test_interpreter(name): basename = os.path.splitext(os.path.basename(filename))[0] tests[filename] = os.fork() if tests[filename] == 0: - step('sail -is execute.isail -iout {}.iresult {}'.format(basename, filename)) + step('sail -undefined_gen -is execute.isail -iout {}.iresult {}'.format(basename, filename)) step('diff {}.iresult {}.expect'.format(basename, basename)) print '{} {}{}{}'.format(filename, color.PASS, 'ok', color.END) sys.exit() diff --git a/test/ocaml/bitfield/test.isail b/test/ocaml/bitfield/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/bitfield/test.isail +++ b/test/ocaml/bitfield/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/hello_world/test.isail b/test/ocaml/hello_world/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/hello_world/test.isail +++ b/test/ocaml/hello_world/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/loop/test.isail b/test/ocaml/loop/test.isail index 6a9595e3..009d3eab 100644 --- a/test/ocaml/loop/test.isail +++ b/test/ocaml/loop/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter :output result main() :run diff --git a/test/ocaml/lsl/test.isail b/test/ocaml/lsl/test.isail index 6a9595e3..009d3eab 100644 --- a/test/ocaml/lsl/test.isail +++ b/test/ocaml/lsl/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter :output result main() :run diff --git a/test/ocaml/pattern1/test.isail b/test/ocaml/pattern1/test.isail index 6a9595e3..009d3eab 100644 --- a/test/ocaml/pattern1/test.isail +++ b/test/ocaml/pattern1/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter :output result main() :run diff --git a/test/ocaml/reg_alias/test.isail b/test/ocaml/reg_alias/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/reg_alias/test.isail +++ b/test/ocaml/reg_alias/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/reg_passing/test.isail b/test/ocaml/reg_passing/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/reg_passing/test.isail +++ b/test/ocaml/reg_passing/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/reg_ref/test.isail b/test/ocaml/reg_ref/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/reg_ref/test.isail +++ b/test/ocaml/reg_ref/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/run_tests.sh b/test/ocaml/run_tests.sh index c160ef9f..d077cd80 100755 --- a/test/ocaml/run_tests.sh +++ b/test/ocaml/run_tests.sh @@ -96,7 +96,7 @@ cd $DIR for i in `ls -d */`; do cd $DIR/$i; - if $SAILDIR/sail -no_warn -is test.isail ../prelude.sail `ls *.sail` 1> /dev/null; + if $SAILDIR/sail -no_warn -undefined_gen -is test.isail ../prelude.sail `ls *.sail` 1> /dev/null; then if diff expect result; then diff --git a/test/ocaml/short_circuit/test.isail b/test/ocaml/short_circuit/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/short_circuit/test.isail +++ b/test/ocaml/short_circuit/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/string_equality/test.isail b/test/ocaml/string_equality/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/string_equality/test.isail +++ b/test/ocaml/string_equality/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/string_of_struct/test.isail b/test/ocaml/string_of_struct/test.isail index 6a9595e3..009d3eab 100644 --- a/test/ocaml/string_of_struct/test.isail +++ b/test/ocaml/string_of_struct/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter :output result main() :run diff --git a/test/ocaml/trycatch/test.isail b/test/ocaml/trycatch/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/trycatch/test.isail +++ b/test/ocaml/trycatch/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/types/test.isail b/test/ocaml/types/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/types/test.isail +++ b/test/ocaml/types/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/vec_32_64/test.isail b/test/ocaml/vec_32_64/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/vec_32_64/test.isail +++ b/test/ocaml/vec_32_64/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result diff --git a/test/ocaml/void/test.isail b/test/ocaml/void/test.isail index b3eb5d41..e5926ff5 100644 --- a/test/ocaml/void/test.isail +++ b/test/ocaml/void/test.isail @@ -1,3 +1,4 @@ +:rewrites interpreter initialize_registers() :run :output result |
