summaryrefslogtreecommitdiff
path: root/test/lit/passes/generate-dyncalls_all-features.wast
blob: 99611727b2a2c003817e219af4da951e11b8f5cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.

;; RUN: foreach %s %t wasm-opt --generate-dyncalls --all-features -S -o - | filecheck %s

(module
 ;; CHECK:      (type $0 (func (param i32 i32 i32)))

 ;; CHECK:      (type $1 (func (result i32)))

 ;; CHECK:      (type $2 (func (param i32) (result i64)))

 ;; CHECK:      (type $3 (func (param i32) (result i32)))

 ;; CHECK:      (type $4 (func (param i32 i32) (result i64)))

 ;; CHECK:      (type $5 (func (param i32 i32)))

 ;; CHECK:      (import "env" "invoke_vii" (func $invoke_vii (type $0) (param i32 i32 i32)))
 (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32)))
 ;; CHECK:      (table $0 2 2 funcref)

 ;; CHECK:      (elem $0 (i32.const 0) $f1 $f2)

 ;; CHECK:      (export "dynCall_i" (func $dynCall_i))

 ;; CHECK:      (export "dynCall_ji" (func $dynCall_ji))

 ;; CHECK:      (export "dynCall_vii" (func $dynCall_vii))

 ;; CHECK:      (func $f1 (type $1) (result i32)
 ;; CHECK-NEXT:  (i32.const 1024)
 ;; CHECK-NEXT: )
 (func $f1 (result i32)
  (i32.const 1024)
 )
 ;; CHECK:      (func $f2 (type $2) (param $0 i32) (result i64)
 ;; CHECK-NEXT:  (i64.const 42)
 ;; CHECK-NEXT: )
 (func $f2 (param i32) (result i64)
  (i64.const 42)
 )
 (table 2 2 funcref)
 (elem (i32.const 0) $f1 $f2)
)
;; CHECK:      (func $dynCall_i (type $3) (param $fptr i32) (result i32)
;; CHECK-NEXT:  (call_indirect $0 (type $1)
;; CHECK-NEXT:   (local.get $fptr)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $dynCall_ji (type $4) (param $fptr i32) (param $0 i32) (result i64)
;; CHECK-NEXT:  (call_indirect $0 (type $2)
;; CHECK-NEXT:   (local.get $0)
;; CHECK-NEXT:   (local.get $fptr)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $dynCall_vii (type $0) (param $fptr i32) (param $0 i32) (param $1 i32)
;; CHECK-NEXT:  (call_indirect $0 (type $5)
;; CHECK-NEXT:   (local.get $0)
;; CHECK-NEXT:   (local.get $1)
;; CHECK-NEXT:   (local.get $fptr)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )
(module
 ;; CHECK:      (type $0 (func (param i32 i32 i32)))

 ;; CHECK:      (type $1 (func (result i32)))

 ;; CHECK:      (type $2 (func (param i32) (result i32)))

 ;; CHECK:      (type $3 (func (param i32 i32)))

 ;; CHECK:      (import "env" "table" (table $timport$0 1 1 funcref))

 ;; CHECK:      (import "env" "invoke_vii" (func $invoke_vii (type $0) (param i32 i32 i32)))
 (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32)))
 (import "env" "table" (table 1 1 funcref))
 (elem (i32.const 0) $f)
 ;; CHECK:      (elem $0 (i32.const 0) $f)

 ;; CHECK:      (export "dynCall_i" (func $dynCall_i))

 ;; CHECK:      (export "dynCall_vii" (func $dynCall_vii))

 ;; CHECK:      (func $f (type $1) (result i32)
 ;; CHECK-NEXT:  (i32.const 42)
 ;; CHECK-NEXT: )
 (func $f (result i32)
  (i32.const 42)
 )
)
;; CHECK:      (func $dynCall_i (type $2) (param $fptr i32) (result i32)
;; CHECK-NEXT:  (call_indirect $timport$0 (type $1)
;; CHECK-NEXT:   (local.get $fptr)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )

;; CHECK:      (func $dynCall_vii (type $0) (param $fptr i32) (param $0 i32) (param $1 i32)
;; CHECK-NEXT:  (call_indirect $timport$0 (type $3)
;; CHECK-NEXT:   (local.get $0)
;; CHECK-NEXT:   (local.get $1)
;; CHECK-NEXT:   (local.get $fptr)
;; CHECK-NEXT:  )
;; CHECK-NEXT: )