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 br_table
{0, 1, 2} # 2 entries, default
59 end_block
# first entry jumps here.
62 end_block
# second entry jumps here.
65 end_block
# default jumps here.
67 end_block
# "switch" exit.
74 # Test correct parsing of instructions with / and : in them:
75 # TODO: enable once instruction has been added.
76 #i32x4.trunc_sat_f32x4_s
86 br_on_exn
0, __cpp_exception
93 i32.load16_u
.L.str:p2align=0
97 global.get __stack_pointer
100 .section .rodata..L.str,"",@
105 .asciz "ello, World!"
111 .section .init_array.42,"",@
115 .ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
116 .globaltype __stack_pointer, i32
119 # CHECK-LABEL: empty_func:
120 # CHECK-NEXT: .functype empty_func () -> ()
121 # CHECK-NEXT: end_function
122 # CHECK-LABEL: test0:
123 # CHECK-NEXT: .functype test0 (i32, i64) -> (i32)
124 # CHECK-NEXT: .eventtype __cpp_exception i32
125 # CHECK-NEXT: .local f32, f64
126 # CHECK-NEXT: local.get 2
127 # CHECK-NEXT: local.set 2
128 # CHECK-NEXT: i32.const -1
129 # CHECK-NEXT: f64.const 0x1.999999999999ap1
130 # CHECK-NEXT: f32.const -0x1p0
131 # CHECK-NEXT: f32.const -infinity
132 # CHECK-NEXT: f32.const nan
133 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
134 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7
135 # CHECK-NEXT: local.get 0
136 # CHECK-NEXT: f64.store 1234:p2align=4
137 # CHECK-NEXT: f64.store 1234
138 # CHECK-NEXT: block i32
139 # CHECK-NEXT: i32.const 1
140 # CHECK-NEXT: local.get 0
141 # CHECK-NEXT: i32.ge_s
142 # CHECK-NEXT: br_if 0 # 0: down to label0
143 # CHECK-NEXT: .LBB0_1:
144 # CHECK-NEXT: loop i32 # label1:
145 # CHECK-NEXT: call something1
146 # CHECK-NEXT: i64.const 1234
147 # CHECK-NEXT: i32.call something2
148 # CHECK-NEXT: i32.const 0
149 # CHECK-NEXT: call_indirect (i32, f64) -> ()
150 # CHECK-NEXT: i32.const 1
151 # CHECK-NEXT: i32.add
152 # CHECK-NEXT: local.tee 0
153 # CHECK-NEXT: local.get 0
154 # CHECK-NEXT: i32.lt_s
155 # CHECK-NEXT: br_if 0 # 0: up to label1
156 # CHECK-NEXT: .LBB0_2:
157 # CHECK-NEXT: end_loop
158 # CHECK-NEXT: end_block # label0:
159 # CHECK-NEXT: local.get 4
160 # CHECK-NEXT: local.get 5
162 # CHECK-NEXT: block i64
163 # CHECK-NEXT: block f32
164 # CHECK-NEXT: block f64
165 # CHECK-NEXT: br_table {0, 1, 2} # 1: down to label4
166 # CHECK-NEXT: # 2: down to label3
167 # CHECK-NEXT: end_block # label5:
168 # CHECK-NEXT: i32.const 1
169 # CHECK-NEXT: br 2 # 2: down to label2
170 # CHECK-NEXT: end_block # label4:
171 # CHECK-NEXT: i32.const 2
172 # CHECK-NEXT: br 1 # 1: down to label2
173 # CHECK-NEXT: end_block # label3:
174 # CHECK-NEXT: i32.const 3
175 # CHECK-NEXT: end_block # label2:
181 # CHECK-NEXT: f32x4.add
182 # CHECK-NEXT: i32.trunc_f32_s
183 # CHECK-NEXT: try exnref
184 # CHECK-NEXT: i32.atomic.load 0
185 # CHECK-NEXT: atomic.notify 0
186 # CHECK-NEXT: .LBB0_3:
188 # CHECK-NEXT: local.set 0
189 # CHECK-NEXT: block i32
190 # CHECK-NEXT: local.get 0
191 # CHECK-NEXT: br_on_exn 0, __cpp_exception
192 # CHECK-NEXT: rethrow
193 # CHECK-NEXT: .LBB0_4:
194 # CHECK-NEXT: end_block
195 # CHECK-NEXT: end_try
196 # CHECK-NEXT: i32.const .L.str
197 # CHECK-NEXT: i32.load8_u .L.str+2
198 # CHECK-NEXT: i32.load16_u .L.str:p2align=0
199 # CHECK-NEXT: throw 0
200 # CHECK-NEXT: .LBB0_5:
201 # CHECK-NEXT: global.get __stack_pointer
202 # CHECK-NEXT: end_function
204 # CHECK: .section .rodata..L.str,"",@
205 # CHECK-NEXT: .hidden .L.str
206 # CHECK-NEXT: .L.str:
207 # CHECK-NEXT: .int8 72
208 # CHECK-NEXT: .asciz "ello, World!"
209 # CHECK-NEXT: .int16 1234
210 # CHECK-NEXT: .int64 5000000000
211 # CHECK-NEXT: .int32 2000000000
212 # CHECK-NEXT: .size .L.str, 28
214 # CHECK: .section .init_array.42,"",@
215 # CHECK-NEXT: .p2align 2
216 # CHECK-NEXT: .int32 test0
218 # CHECK: .globaltype __stack_pointer, i32