1 # RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s
2 # Check that it converts to .o without errors, but don't check any output:
3 # RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling -o %t.o < %s
7 .functype empty_func () -> ()
12 .functype test0 (i32, i64) -> (i32)
13 .eventtype __cpp_exception i32
14 .local f32, f64, v128, v128
15 # Explicit getlocal/setlocal:
20 f64.const
0x1.999999999999ap1
24 v128.const
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
25 v128.const
0, 1, 2, 3, 4, 5, 6, 7
26 # Indirect addressing:
28 f64.store
1234:p2align
=4
29 f64.store
1234 # Natural alignment (3)
30 # Loops, conditionals, binary ops, calls etc:
35 br_if
0 # 0: down to label0
42 call_indirect
(i32
, f64
) -> ()
48 br_if
0 # 0: up to label1
58 block
() -> (i32
, i32
)
64 br_table
{0, 1, 2} # 2 entries, default
65 end_block
# first entry jumps here.
68 end_block
# second entry jumps here.
71 end_block
# default jumps here.
73 end_block
# "switch" exit.
80 # Test correct parsing of instructions with / and : in them:
81 # TODO: enable once instruction has been added.
82 #i32x4.trunc_sat_f32x4_s
92 br_on_exn
0, __cpp_exception
99 i32.load16_u
.L.str:p2align=0
103 global.get __stack_pointer
106 .section .rodata..L.str,"",@
111 .asciz "ello, World!"
117 .section .init_array.42,"",@
121 .ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
122 .globaltype __stack_pointer, i32
125 # CHECK-LABEL: empty_func:
126 # CHECK-NEXT: .functype empty_func () -> ()
127 # CHECK-NEXT: end_function
128 # CHECK-LABEL: test0:
129 # CHECK-NEXT: .functype test0 (i32, i64) -> (i32)
130 # CHECK-NEXT: .eventtype __cpp_exception i32
131 # CHECK-NEXT: .local f32, f64
132 # CHECK-NEXT: local.get 2
133 # CHECK-NEXT: local.set 2
134 # CHECK-NEXT: i32.const -1
135 # CHECK-NEXT: f64.const 0x1.999999999999ap1
136 # CHECK-NEXT: f32.const -0x1p0
137 # CHECK-NEXT: f32.const -infinity
138 # CHECK-NEXT: f32.const nan
139 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
140 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7
141 # CHECK-NEXT: local.get 0
142 # CHECK-NEXT: f64.store 1234:p2align=4
143 # CHECK-NEXT: f64.store 1234
144 # CHECK-NEXT: block i32
145 # CHECK-NEXT: i32.const 1
146 # CHECK-NEXT: local.get 0
147 # CHECK-NEXT: i32.ge_s
148 # CHECK-NEXT: br_if 0 # 0: down to label0
149 # CHECK-NEXT: .LBB0_1:
150 # CHECK-NEXT: loop i32 # label1:
151 # CHECK-NEXT: call something1
152 # CHECK-NEXT: i64.const 1234
153 # CHECK-NEXT: i32.call something2
154 # CHECK-NEXT: i32.const 0
155 # CHECK-NEXT: call_indirect (i32, f64) -> ()
156 # CHECK-NEXT: i32.const 1
157 # CHECK-NEXT: i32.add
158 # CHECK-NEXT: local.tee 0
159 # CHECK-NEXT: local.get 0
160 # CHECK-NEXT: i32.lt_s
161 # CHECK-NEXT: br_if 0 # 0: up to label1
162 # CHECK-NEXT: .LBB0_2:
163 # CHECK-NEXT: end_loop
164 # CHECK-NEXT: end_block # label0:
165 # CHECK-NEXT: local.get 4
166 # CHECK-NEXT: local.get 5
168 # CHECK-NEXT: block i64
169 # CHECK-NEXT: block f32
170 # CHECK-NEXT: block f64
171 # CHECK-NEXT: block () -> (i32, i32)
172 # CHECK-NEXT: i32.const 1
173 # CHECK-NEXT: i32.const 2
174 # CHECK-NEXT: end_block
177 # CHECK-NEXT: br_table {0, 1, 2} # 1: down to label4
178 # CHECK-NEXT: # 2: down to label3
179 # CHECK-NEXT: end_block # label5:
180 # CHECK-NEXT: i32.const 1
181 # CHECK-NEXT: br 2 # 2: down to label2
182 # CHECK-NEXT: end_block # label4:
183 # CHECK-NEXT: i32.const 2
184 # CHECK-NEXT: br 1 # 1: down to label2
185 # CHECK-NEXT: end_block # label3:
186 # CHECK-NEXT: i32.const 3
187 # CHECK-NEXT: end_block # label2:
193 # CHECK-NEXT: f32x4.add
194 # CHECK-NEXT: i32.trunc_f32_s
195 # CHECK-NEXT: try exnref
196 # CHECK-NEXT: i32.atomic.load 0
197 # CHECK-NEXT: atomic.notify 0
198 # CHECK-NEXT: .LBB0_3:
200 # CHECK-NEXT: local.set 0
201 # CHECK-NEXT: block i32
202 # CHECK-NEXT: local.get 0
203 # CHECK-NEXT: br_on_exn 0, __cpp_exception
204 # CHECK-NEXT: rethrow
205 # CHECK-NEXT: .LBB0_4:
206 # CHECK-NEXT: end_block
207 # CHECK-NEXT: end_try
208 # CHECK-NEXT: i32.const .L.str
209 # CHECK-NEXT: i32.load8_u .L.str+2
210 # CHECK-NEXT: i32.load16_u .L.str:p2align=0
211 # CHECK-NEXT: throw 0
212 # CHECK-NEXT: .LBB0_5:
213 # CHECK-NEXT: global.get __stack_pointer
214 # CHECK-NEXT: end_function
216 # CHECK: .section .rodata..L.str,"",@
217 # CHECK-NEXT: .hidden .L.str
218 # CHECK-NEXT: .L.str:
219 # CHECK-NEXT: .int8 72
220 # CHECK-NEXT: .asciz "ello, World!"
221 # CHECK-NEXT: .int16 1234
222 # CHECK-NEXT: .int64 5000000000
223 # CHECK-NEXT: .int32 2000000000
224 # CHECK-NEXT: .size .L.str, 28
226 # CHECK: .section .init_array.42,"",@
227 # CHECK-NEXT: .p2align 2
228 # CHECK-NEXT: .int32 test0
230 # CHECK: .globaltype __stack_pointer, i32