Skip to content

Commit c682d23

Browse files
authored
Winch aarch64 jmp (#9051)
* winch aarch64 jmp * winch aarch64 branch * winch aarch64 jmp_table * winch aarch64 branch tests * winch aarch64 jmp: add islands for long range branches
1 parent ba864e9 commit c682d23

File tree

15 files changed

+25882
-14
lines changed

15 files changed

+25882
-14
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-br_if-cond")
5+
(block (br_if 0 (br 0)))
6+
)
7+
)
8+
;; wasm[0]::function[0]:
9+
;; stp x29, x30, [sp, #-0x10]!
10+
;; mov x29, sp
11+
;; mov x28, sp
12+
;; mov x9, x0
13+
;; sub sp, sp, #0x10
14+
;; mov x28, sp
15+
;; stur x0, [x28, #8]
16+
;; stur x1, [x28]
17+
;; add sp, sp, #0x10
18+
;; mov x28, sp
19+
;; ldp x29, x30, [sp], #0x10
20+
;; ret
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-br-value") (result i32)
5+
(block (result i32) (br 0 (br 0 (i32.const 9))))
6+
)
7+
)
8+
;; wasm[0]::function[0]:
9+
;; stp x29, x30, [sp, #-0x10]!
10+
;; mov x29, sp
11+
;; mov x28, sp
12+
;; mov x9, x0
13+
;; sub sp, sp, #0x10
14+
;; mov x28, sp
15+
;; stur x0, [x28, #8]
16+
;; stur x1, [x28]
17+
;; mov x16, #9
18+
;; mov w0, w16
19+
;; add sp, sp, #0x10
20+
;; mov x28, sp
21+
;; ldp x29, x30, [sp], #0x10
22+
;; ret
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-if-cond") (result i32)
5+
(block (result i32)
6+
(if (result i32) (br 0 (i32.const 2))
7+
(then (i32.const 0))
8+
(else (i32.const 1))
9+
)
10+
)
11+
)
12+
)
13+
;; wasm[0]::function[0]:
14+
;; stp x29, x30, [sp, #-0x10]!
15+
;; mov x29, sp
16+
;; mov x28, sp
17+
;; mov x9, x0
18+
;; sub sp, sp, #0x10
19+
;; mov x28, sp
20+
;; stur x0, [x28, #8]
21+
;; stur x1, [x28]
22+
;; mov x16, #2
23+
;; mov w0, w16
24+
;; add sp, sp, #0x10
25+
;; mov x28, sp
26+
;; ldp x29, x30, [sp], #0x10
27+
;; ret
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-if-else") (param i32 i32) (result i32)
5+
(block (result i32)
6+
(if (result i32) (local.get 0)
7+
(then (local.get 1))
8+
(else (br 1 (i32.const 4)))
9+
)
10+
)
11+
)
12+
)
13+
;; wasm[0]::function[0]:
14+
;; stp x29, x30, [sp, #-0x10]!
15+
;; mov x29, sp
16+
;; mov x28, sp
17+
;; mov x9, x0
18+
;; sub sp, sp, #0x18
19+
;; mov x28, sp
20+
;; stur x0, [x28, #0x10]
21+
;; stur x1, [x28, #8]
22+
;; stur w2, [x28, #4]
23+
;; stur w3, [x28]
24+
;; ldur w0, [x28, #4]
25+
;; tst w0, w0
26+
;; b.eq #0x40
27+
;; b #0x38
28+
;; 38: ldur w0, [x28]
29+
;; b #0x48
30+
;; 40: mov x16, #4
31+
;; mov w0, w16
32+
;; add sp, sp, #0x18
33+
;; mov x28, sp
34+
;; ldp x29, x30, [sp], #0x10
35+
;; ret
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-if-then") (param i32 i32) (result i32)
5+
(block (result i32)
6+
(if (result i32) (local.get 0)
7+
(then (br 1 (i32.const 3)))
8+
(else (local.get 1))
9+
)
10+
)
11+
)
12+
)
13+
;; wasm[0]::function[0]:
14+
;; stp x29, x30, [sp, #-0x10]!
15+
;; mov x29, sp
16+
;; mov x28, sp
17+
;; mov x9, x0
18+
;; sub sp, sp, #0x18
19+
;; mov x28, sp
20+
;; stur x0, [x28, #0x10]
21+
;; stur x1, [x28, #8]
22+
;; stur w2, [x28, #4]
23+
;; stur w3, [x28]
24+
;; ldur w0, [x28, #4]
25+
;; tst w0, w0
26+
;; b.eq #0x44
27+
;; b #0x38
28+
;; 38: mov x16, #3
29+
;; mov w0, w16
30+
;; b #0x48
31+
;; 44: ldur w0, [x28]
32+
;; add sp, sp, #0x18
33+
;; mov x28, sp
34+
;; ldp x29, x30, [sp], #0x10
35+
;; ret
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
4+
(module
5+
(func (export "as-loop-first") (result i32)
6+
(block (result i32) (loop (result i32) (br 1 (i32.const 3)) (i32.const 2)))
7+
)
8+
)
9+
;; wasm[0]::function[0]:
10+
;; stp x29, x30, [sp, #-0x10]!
11+
;; mov x29, sp
12+
;; mov x28, sp
13+
;; mov x9, x0
14+
;; sub sp, sp, #0x10
15+
;; mov x28, sp
16+
;; stur x0, [x28, #8]
17+
;; stur x1, [x28]
18+
;; mov x16, #3
19+
;; mov w0, w16
20+
;; add sp, sp, #0x10
21+
;; mov x28, sp
22+
;; ldp x29, x30, [sp], #0x10
23+
;; ret
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (;0;) (result i32)
5+
(local i32)
6+
local.get 0
7+
loop ;; label = @1
8+
local.get 0
9+
block ;; label = @2
10+
end
11+
br 0 (;@1;)
12+
end
13+
)
14+
(export "" (func 0))
15+
)
16+
;; wasm[0]::function[0]:
17+
;; stp x29, x30, [sp, #-0x10]!
18+
;; mov x29, sp
19+
;; mov x28, sp
20+
;; mov x9, x0
21+
;; sub sp, sp, #0x18
22+
;; mov x28, sp
23+
;; stur x0, [x28, #0x10]
24+
;; stur x1, [x28, #8]
25+
;; mov x16, #0
26+
;; stur x16, [x28]
27+
;; ldur w16, [x28, #4]
28+
;; sub sp, sp, #8
29+
;; mov x28, sp
30+
;; stur x16, [x28, #8]
31+
;; ldur w16, [x28, #0xc]
32+
;; sub sp, sp, #8
33+
;; mov x28, sp
34+
;; stur x16, [x28, #8]
35+
;; add sp, sp, #8
36+
;; mov x28, sp
37+
;; b #0x38
38+
;; 54: add sp, sp, #0x18
39+
;; mov x28, sp
40+
;; ldp x29, x30, [sp], #0x10
41+
;; ret
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-br-if-cond")
5+
(block (br_if 0 (br_if 0 (i32.const 1) (i32.const 1))))
6+
)
7+
)
8+
;; wasm[0]::function[0]:
9+
;; stp x29, x30, [sp, #-0x10]!
10+
;; mov x29, sp
11+
;; mov x28, sp
12+
;; mov x9, x0
13+
;; sub sp, sp, #0x10
14+
;; mov x28, sp
15+
;; stur x0, [x28, #8]
16+
;; stur x1, [x28]
17+
;; mov x16, #1
18+
;; mov w0, w16
19+
;; tst w0, w0
20+
;; b.ne #0x48
21+
;; b #0x34
22+
;; 34: mov x16, #1
23+
;; mov w0, w16
24+
;; tst w0, w0
25+
;; b.ne #0x48
26+
;; b #0x48
27+
;; 48: add sp, sp, #0x10
28+
;; mov x28, sp
29+
;; ldp x29, x30, [sp], #0x10
30+
;; ret
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-br-value") (result i32)
5+
(block (result i32) (br 0 (br_if 0 (i32.const 1) (i32.const 2))))
6+
)
7+
)
8+
;; wasm[0]::function[0]:
9+
;; stp x29, x30, [sp, #-0x10]!
10+
;; mov x29, sp
11+
;; mov x28, sp
12+
;; mov x9, x0
13+
;; sub sp, sp, #0x10
14+
;; mov x28, sp
15+
;; stur x0, [x28, #8]
16+
;; stur x1, [x28]
17+
;; mov x16, #2
18+
;; mov w1, w16
19+
;; mov x16, #1
20+
;; mov w0, w16
21+
;; tst w1, w1
22+
;; b.ne #0x3c
23+
;; b #0x3c
24+
;; 3c: add sp, sp, #0x10
25+
;; mov x28, sp
26+
;; ldp x29, x30, [sp], #0x10
27+
;; ret
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-if-cond") (param i32) (result i32)
5+
(block (result i32)
6+
(if (result i32)
7+
(br_if 0 (i32.const 1) (local.get 0))
8+
(then (i32.const 2))
9+
(else (i32.const 3))
10+
)
11+
)
12+
)
13+
)
14+
;; wasm[0]::function[0]:
15+
;; stp x29, x30, [sp, #-0x10]!
16+
;; mov x29, sp
17+
;; mov x28, sp
18+
;; mov x9, x0
19+
;; sub sp, sp, #0x18
20+
;; mov x28, sp
21+
;; stur x0, [x28, #0x10]
22+
;; stur x1, [x28, #8]
23+
;; stur w2, [x28, #4]
24+
;; ldur w1, [x28, #4]
25+
;; mov x16, #1
26+
;; mov w0, w16
27+
;; tst w1, w1
28+
;; b.ne #0x5c
29+
;; b #0x3c
30+
;; 3c: tst w0, w0
31+
;; b.eq #0x54
32+
;; b #0x48
33+
;; 48: mov x16, #2
34+
;; mov w0, w16
35+
;; b #0x5c
36+
;; 54: mov x16, #3
37+
;; mov w0, w16
38+
;; add sp, sp, #0x18
39+
;; mov x28, sp
40+
;; ldp x29, x30, [sp], #0x10
41+
;; ret
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
;;! target = "aarch64"
2+
;;! test = "winch"
3+
(module
4+
(func (export "as-local-set-value") (param i32) (result i32)
5+
(local i32)
6+
(block (result i32)
7+
(local.set 0 (br_if 0 (i32.const 17) (local.get 0)))
8+
(i32.const -1)
9+
)
10+
)
11+
)
12+
;; wasm[0]::function[0]:
13+
;; stp x29, x30, [sp, #-0x10]!
14+
;; mov x29, sp
15+
;; mov x28, sp
16+
;; mov x9, x0
17+
;; sub sp, sp, #0x18
18+
;; mov x28, sp
19+
;; stur x0, [x28, #0x10]
20+
;; stur x1, [x28, #8]
21+
;; stur w2, [x28, #4]
22+
;; mov x16, #0
23+
;; stur w16, [x28]
24+
;; mov x16, #0
25+
;; ldur w1, [x28, #4]
26+
;; mov x16, #0x11
27+
;; mov w0, w16
28+
;; tst w1, w1
29+
;; b.ne #0x54
30+
;; b #0x48
31+
;; 48: stur w0, [x28, #4]
32+
;; orr x16, xzr, #0xffffffff
33+
;; mov w0, w16
34+
;; add sp, sp, #0x18
35+
;; mov x28, sp
36+
;; ldp x29, x30, [sp], #0x10
37+
;; ret

0 commit comments

Comments
 (0)