aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-10-06 11:11:24 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-10-06 11:11:24 +0200
commit1741bee182f115d899bd31642b32f70b0c7ed32f (patch)
tree792a261f01c25af2cba795bc78d25b8c5068efa0 /tests
parent7ddb4265d30ef30df6e7098c979334109378357c (diff)
downloadAGH-engineering-thesis-1741bee182f115d899bd31642b32f70b0c7ed32f.tar.gz
AGH-engineering-thesis-1741bee182f115d899bd31642b32f70b0c7ed32f.zip
add translation of br_if instruction
Diffstat (limited to 'tests')
l---------tests/wasm_compile_br_if/Makefile1
-rw-r--r--tests/wasm_compile_br_if/instructions.wat27
l---------tests/wasm_compile_br_if/test.v1
-rw-r--r--tests/wasm_compile_br_if/words_to_verify.mem6
-rw-r--r--tests/wasm_compile_simple_module/test.v6
5 files changed, 38 insertions, 3 deletions
diff --git a/tests/wasm_compile_br_if/Makefile b/tests/wasm_compile_br_if/Makefile
new file mode 120000
index 0000000..e451c8b
--- /dev/null
+++ b/tests/wasm_compile_br_if/Makefile
@@ -0,0 +1 @@
+../wasm_compile_simple_module/Makefile \ No newline at end of file
diff --git a/tests/wasm_compile_br_if/instructions.wat b/tests/wasm_compile_br_if/instructions.wat
new file mode 100644
index 0000000..506a462
--- /dev/null
+++ b/tests/wasm_compile_br_if/instructions.wat
@@ -0,0 +1,27 @@
+;;; this test is loosely based on wasm_compile_br
+(module
+ (memory 0 1)
+ ;; this function returns -1 if its argument is 10 or 11 and 0 otherwise
+ (func $eq10or11 (param $x i32) (result i32)
+ (if (result i32)
+ (i32.sub
+ (get_local $x)
+ (i32.const 10))
+ (then
+ (br_if 0 (i32.add (i32.const -3) (i32.const 3))
+ (i32.sub (get_local $x) (i32.const 11)))
+ (i32.const 1)
+ (i32.sub))
+ (else
+ (i32.const -1))))
+ (func $main
+ ;; write 0x00000000 at MEMORY_BOTTOM_ADDR
+ (i32.store offset=0x0 align=2 (i32.const 0x0)
+ (call $eq10or11 (i32.const 12)))
+ ;; write 0xFFFFFFFF at MEMORY_BOTTOM_ADDR + 0x4
+ (i32.store offset=0x0 align=2 (i32.const 0x4)
+ (call $eq10or11 (i32.const 10)))
+ ;; write 0xFFFFFFFF at MEMORY_BOTTOM_ADDR + 0x8
+ (i32.store offset=0x0 align=2 (i32.const 0x8)
+ (call $eq10or11 (i32.const 11))))
+ (export "main" (func $main)))
diff --git a/tests/wasm_compile_br_if/test.v b/tests/wasm_compile_br_if/test.v
new file mode 120000
index 0000000..f0235d8
--- /dev/null
+++ b/tests/wasm_compile_br_if/test.v
@@ -0,0 +1 @@
+../wasm_compile_simple_module/test.v \ No newline at end of file
diff --git a/tests/wasm_compile_br_if/words_to_verify.mem b/tests/wasm_compile_br_if/words_to_verify.mem
new file mode 100644
index 0000000..aac1103
--- /dev/null
+++ b/tests/wasm_compile_br_if/words_to_verify.mem
@@ -0,0 +1,6 @@
+// address value
+ 0FFFFC 23
+
+ 200 00000000
+ 204 FFFFFFFF
+ 208 FFFFFFFF
diff --git a/tests/wasm_compile_simple_module/test.v b/tests/wasm_compile_simple_module/test.v
index 80f5590..5e28ba1 100644
--- a/tests/wasm_compile_simple_module/test.v
+++ b/tests/wasm_compile_simple_module/test.v
@@ -159,7 +159,7 @@ module wasm_compile_test();
CLK <= 0;
RST <= 1;
- for (i = 0; i < 5000; i++) begin
+ for (i = 0; i < 10000; i++) begin
#1;
CLK <= ~CLK;
@@ -194,9 +194,9 @@ module wasm_compile_test();
$finish;
end // if (M_finished)
- end // for (i = 0; i < 5000; i++)
+ end // for (i = 0; i < 10000; i++)
- $display("error: cpu hasn't finished its operations in 2500 ticks");
+ $display("error: cpu hasn't finished its operations in 5000 ticks");
$finish;
end // initial begin
endmodule // stack_machine_test