blob: e1c170d17c83ca495827644ef4ed736d742087c8 (
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; Check that array types and operations are emitted properly in the binary format.
;; RUN: wasm-opt %s -all -S -o - | filecheck %s
;; RUN: wasm-opt %s -all --roundtrip -S -o - | filecheck %s --check-prefix=ROUNDTRIP
;; Check that we can roundtrip through the text format as well.
;; RUN: wasm-opt %s -all -S -o - | wasm-opt -all -S -o - | filecheck %s
(module
;; CHECK: (type $byte-array (array (mut i8)))
;; ROUNDTRIP: (type $byte-array (array (mut i8)))
(type $byte-array (array (mut i8)))
;; CHECK: (type $func-array (array (mut funcref)))
;; ROUNDTRIP: (type $func-array (array (mut funcref)))
(type $func-array (array (mut funcref)))
(data "hello")
(elem func $len $impossible-len $unreachable-len)
;; CHECK: (type $2 (func (param arrayref) (result i32)))
;; CHECK: (type $3 (func (param (ref array)) (result i32)))
;; CHECK: (type $4 (func (param nullref) (result i32)))
;; CHECK: (type $5 (func (result (ref $byte-array))))
;; CHECK: (type $6 (func (result (ref $func-array))))
;; CHECK: (data $0 "hello")
;; CHECK: (elem $0 func $len $impossible-len $unreachable-len)
;; CHECK: (func $len (type $3) (param $a (ref array)) (result i32)
;; CHECK-NEXT: (array.len
;; CHECK-NEXT: (local.get $a)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (type $2 (func (param arrayref) (result i32)))
;; ROUNDTRIP: (type $3 (func (param (ref array)) (result i32)))
;; ROUNDTRIP: (type $4 (func (param nullref) (result i32)))
;; ROUNDTRIP: (type $5 (func (result (ref $byte-array))))
;; ROUNDTRIP: (type $6 (func (result (ref $func-array))))
;; ROUNDTRIP: (data $0 "hello")
;; ROUNDTRIP: (elem $0 func $len $impossible-len $unreachable-len)
;; ROUNDTRIP: (func $len (type $3) (param $a (ref array)) (result i32)
;; ROUNDTRIP-NEXT: (array.len
;; ROUNDTRIP-NEXT: (local.get $a)
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $len (param $a (ref array)) (result i32)
(array.len
(local.get $a)
)
)
;; CHECK: (func $impossible-len (type $4) (param $none nullref) (result i32)
;; CHECK-NEXT: (array.len
;; CHECK-NEXT: (local.get $none)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (func $impossible-len (type $4) (param $none nullref) (result i32)
;; ROUNDTRIP-NEXT: (array.len
;; ROUNDTRIP-NEXT: (local.get $none)
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $impossible-len (param $none nullref) (result i32)
(array.len
(local.get $none)
)
)
;; CHECK: (func $unreachable-len (type $2) (param $a arrayref) (result i32)
;; CHECK-NEXT: (array.len
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (func $unreachable-len (type $2) (param $a arrayref) (result i32)
;; ROUNDTRIP-NEXT: (unreachable)
;; ROUNDTRIP-NEXT: )
(func $unreachable-len (param $a arrayref) (result i32)
(array.len
(unreachable)
)
)
;; CHECK: (func $unannotated-len (type $2) (param $a arrayref) (result i32)
;; CHECK-NEXT: (array.len
;; CHECK-NEXT: (local.get $a)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (func $unannotated-len (type $2) (param $a arrayref) (result i32)
;; ROUNDTRIP-NEXT: (array.len
;; ROUNDTRIP-NEXT: (local.get $a)
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $unannotated-len (param $a arrayref) (result i32)
(array.len
(local.get $a)
)
)
;; CHECK: (func $new-data (type $5) (result (ref $byte-array))
;; CHECK-NEXT: (array.new_data $byte-array $0
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i32.const 5)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (func $new-data (type $5) (result (ref $byte-array))
;; ROUNDTRIP-NEXT: (array.new_data $byte-array $0
;; ROUNDTRIP-NEXT: (i32.const 0)
;; ROUNDTRIP-NEXT: (i32.const 5)
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $new-data (result (ref $byte-array))
(array.new_data $byte-array 0
(i32.const 0)
(i32.const 5)
)
)
;; CHECK: (func $new-elem (type $6) (result (ref $func-array))
;; CHECK-NEXT: (array.new_elem $func-array $0
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (i32.const 3)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; ROUNDTRIP: (func $new-elem (type $6) (result (ref $func-array))
;; ROUNDTRIP-NEXT: (array.new_elem $func-array $0
;; ROUNDTRIP-NEXT: (i32.const 0)
;; ROUNDTRIP-NEXT: (i32.const 3)
;; ROUNDTRIP-NEXT: )
;; ROUNDTRIP-NEXT: )
(func $new-elem (result (ref $func-array))
(array.new_elem $func-array 0
(i32.const 0)
(i32.const 3)
)
)
)
|