Skip to content

Commit 0f40ad3

Browse files
matetokodikulcsaradam
authored andcommitted
WIP: add wamr_compilert test and dhrystone
Signed-off-by: Máté Tokodi [email protected]
1 parent a782a85 commit 0f40ad3

File tree

12 files changed

+1120
-1
lines changed

12 files changed

+1120
-1
lines changed

test/other/wamr-compiler/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WAMR test benchmarks
2+
3+
This folder contains tests for WAMR AOT compiler and its generated code.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
;; Copyright (C) 2023 Amazon Inc. All rights reserved.
2+
;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
;;
4+
;; Those tests verify if passing constant negative value
5+
;; as a right parameter of the shift operator (along
6+
;; with a constant value of the left operator) causes
7+
;; any problems. See: https://github.com/bytecodealliance/wasm-micro-runtime/pull/2619
8+
(module
9+
(memory (export "memory") 1 1)
10+
11+
(func $assert_eq (param i32 i32)
12+
(i32.ne (local.get 0) (local.get 1))
13+
if
14+
unreachable
15+
end
16+
)
17+
18+
(func $i32_shr_u
19+
(call $assert_eq
20+
(i32.shr_u (i32.const -1) (i32.const -5))
21+
(i32.const 31)
22+
)
23+
)
24+
25+
(func $i32_shr_s
26+
(call $assert_eq
27+
(i32.shr_s (i32.const 32) (i32.const -30))
28+
(i32.const 8)
29+
)
30+
)
31+
32+
(func $i32_shl
33+
(call $assert_eq
34+
(i32.shl (i32.const -1) (i32.const -30))
35+
(i32.const -4)
36+
)
37+
)
38+
39+
(func $const_ret (result i32)
40+
i32.const -5
41+
)
42+
43+
;; *_func_call tests validate the potential LLVM optimizations
44+
;; where the right parameter of the shift operation is an
45+
;; indirect constant value.
46+
(func $i32_shr_u_func_call
47+
(call $assert_eq
48+
(i32.shr_u (i32.const -1) (call $const_ret))
49+
(i32.const 31)
50+
)
51+
)
52+
53+
(func $i32_shr_s_func_call
54+
(call $assert_eq
55+
(i32.shr_s
56+
(i32.const 1073741824) ;; 2^30
57+
(call $const_ret)
58+
)
59+
(i32.const 8)
60+
)
61+
)
62+
63+
(func $i32_shl_func_call
64+
(call $assert_eq
65+
(i32.shl (i32.const -1) (call $const_ret))
66+
(i32.const -134217728)
67+
)
68+
)
69+
70+
(func (export "_start")
71+
call $i32_shr_u
72+
call $i32_shr_s
73+
call $i32_shl
74+
call $i32_shr_u_func_call
75+
call $i32_shr_s_func_call
76+
call $i32_shl_func_call
77+
)
78+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Dhrystone
2+
------------------------------------------------------------------------------
3+
`dhrystone.wasm` was compiled from
4+
https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/tests/benchmarks/dhrystone
5+
via `wasi-sdk` and `emcc`:
6+
```shell
7+
/opt/wasi-sdk/bin/clang -O3 \
8+
-o dhrystone_clang_O3.wasm src/dhry_1.c src/dhry_2.c -I include \
9+
-Wl,--export=__heap_base -Wl,--export=__data_end
10+
11+
/opt/wasi-sdk/bin/clang -O2 \
12+
-o dhrystone_clang_O2.wasm src/dhry_1.c src/dhry_2.c -I include \
13+
-Wl,--export=__heap_base -Wl,--export=__data_end
14+
15+
/opt/wasi-sdk/bin/clang -O1 \
16+
-o dhrystone_clang_O1.wasm src/dhry_1.c src/dhry_2.c -I include \
17+
-Wl,--export=__heap_base -Wl,--export=__data_end
18+
19+
/opt/wasi-sdk/bin/clang -O0 \
20+
-o dhrystone_clang_O0.wasm src/dhry_1.c src/dhry_2.c -I include \
21+
-Wl,--export=__heap_base -Wl,--export=__data_end
22+
23+
emcc \
24+
-o dhrystone_emcc.wasm src/dhry_1.c src/dhry_2.c -I include \
25+
-Wl,--export=__heap_base -Wl,--export=__data_end
26+
```
157 KB
Binary file not shown.
128 KB
Binary file not shown.
127 KB
Binary file not shown.
127 KB
Binary file not shown.
32.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)