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 test0 (i32, i64) -> (i32)
8 .eventtype __cpp_exception i32
9 .local f32, f64, v128, v128
10 # Explicit getlocal/setlocal:
15 f64.const
0x1.999999999999ap1
19 v128.const
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
20 v128.const
0, 1, 2, 3, 4, 5, 6, 7
21 # Indirect addressing:
23 f64.store
1234:p2align
=4
24 f64.store
1234 # Natural alignment (3)
25 # Loops, conditionals, binary ops, calls etc:
30 br_if
0 # 0: down to label0
43 br_if
0 # 0: up to label1
53 br_table
{0, 1, 2} # 2 entries, default
54 end_block
# first entry jumps here.
57 end_block
# second entry jumps here.
60 end_block
# default jumps here.
62 end_block
# "switch" exit.
69 # Test correct parsing of instructions with / and : in them:
70 # TODO: enable once instruction has been added.
71 #i32x4.trunc_sat_f32x4_s
81 br_on_exn
0, __cpp_exception
88 i32.load16_u
.L.str:p2align=0
92 global.get __stack_pointer
95 .section .rodata..L.str,"",@
100 .asciz "ello, World!"
106 .section .init_array.42,"",@
110 .ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
111 .globaltype __stack_pointer, i32
114 # CHECK-LABEL: test0:
115 # CHECK-NEXT: .functype test0 (i32, i64) -> (i32)
116 # CHECK-NEXT: .eventtype __cpp_exception i32
117 # CHECK-NEXT: .local f32, f64
118 # CHECK-NEXT: local.get 2
119 # CHECK-NEXT: local.set 2
120 # CHECK-NEXT: i32.const -1
121 # CHECK-NEXT: f64.const 0x1.999999999999ap1
122 # CHECK-NEXT: f32.const -0x1p0
123 # CHECK-NEXT: f32.const -infinity
124 # CHECK-NEXT: f32.const nan
125 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
126 # CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7
127 # CHECK-NEXT: local.get 0
128 # CHECK-NEXT: f64.store 1234:p2align=4
129 # CHECK-NEXT: f64.store 1234
130 # CHECK-NEXT: block i32
131 # CHECK-NEXT: i32.const 1
132 # CHECK-NEXT: local.get 0
133 # CHECK-NEXT: i32.ge_s
134 # CHECK-NEXT: br_if 0 # 0: down to label0
135 # CHECK-NEXT: .LBB0_1:
136 # CHECK-NEXT: loop i32 # label1:
137 # CHECK-NEXT: call something1
138 # CHECK-NEXT: i64.const 1234
139 # CHECK-NEXT: i32.call something2
140 # CHECK-NEXT: i32.const 0
141 # CHECK-NEXT: call_indirect 0
142 # CHECK-NEXT: i32.const 1
143 # CHECK-NEXT: i32.add
144 # CHECK-NEXT: local.tee 0
145 # CHECK-NEXT: local.get 0
146 # CHECK-NEXT: i32.lt_s
147 # CHECK-NEXT: br_if 0 # 0: up to label1
148 # CHECK-NEXT: .LBB0_2:
149 # CHECK-NEXT: end_loop
150 # CHECK-NEXT: end_block # label0:
151 # CHECK-NEXT: local.get 4
152 # CHECK-NEXT: local.get 5
154 # CHECK-NEXT: block i64
155 # CHECK-NEXT: block f32
156 # CHECK-NEXT: block f64
157 # CHECK-NEXT: br_table {0, 1, 2} # 1: down to label4
158 # CHECK-NEXT: # 2: down to label3
159 # CHECK-NEXT: end_block # label5:
160 # CHECK-NEXT: i32.const 1
161 # CHECK-NEXT: br 2 # 2: down to label2
162 # CHECK-NEXT: end_block # label4:
163 # CHECK-NEXT: i32.const 2
164 # CHECK-NEXT: br 1 # 1: down to label2
165 # CHECK-NEXT: end_block # label3:
166 # CHECK-NEXT: i32.const 3
167 # CHECK-NEXT: end_block # label2:
173 # CHECK-NEXT: f32x4.add
174 # CHECK-NEXT: i32.trunc_f32_s
175 # CHECK-NEXT: try exnref
176 # CHECK-NEXT: i32.atomic.load 0
177 # CHECK-NEXT: atomic.notify 0
178 # CHECK-NEXT: .LBB0_3:
180 # CHECK-NEXT: local.set 0
181 # CHECK-NEXT: block i32
182 # CHECK-NEXT: local.get 0
183 # CHECK-NEXT: br_on_exn 0, __cpp_exception
184 # CHECK-NEXT: rethrow
185 # CHECK-NEXT: .LBB0_4:
186 # CHECK-NEXT: end_block
187 # CHECK-NEXT: end_try
188 # CHECK-NEXT: i32.const .L.str
189 # CHECK-NEXT: i32.load8_u .L.str+2
190 # CHECK-NEXT: i32.load16_u .L.str:p2align=0
191 # CHECK-NEXT: throw 0
192 # CHECK-NEXT: .LBB0_5:
193 # CHECK-NEXT: global.get __stack_pointer
194 # CHECK-NEXT: end_function
196 # CHECK: .section .rodata..L.str,"",@
197 # CHECK-NEXT: .hidden .L.str
198 # CHECK-NEXT: .L.str:
199 # CHECK-NEXT: .int8 72
200 # CHECK-NEXT: .asciz "ello, World!"
201 # CHECK-NEXT: .int16 1234
202 # CHECK-NEXT: .int64 5000000000
203 # CHECK-NEXT: .int32 2000000000
204 # CHECK-NEXT: .size .L.str, 28
206 # CHECK: .section .init_array.42,"",@
207 # CHECK-NEXT: .p2align 2
208 # CHECK-NEXT: .int32 test0
210 # CHECK: .globaltype __stack_pointer, i32