[llvm-objdump] - Remove one overload of reportError. NFCI.
[llvm-complete.git] / test / MC / WebAssembly / basic-assembly.s
blob6de4cff8a052c1c6bdca08ce25cb66fa9c0b6be8
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
6 empty_func:
7 .functype empty_func () -> ()
8 end_function
10 test0:
11 # Test all types:
12 .functype test0 (i32, i64) -> (i32)
13 .eventtype __cpp_exception i32
14 .local f32, f64, v128, v128
15 # Explicit getlocal/setlocal:
16 local.get 2
17 local.set 2
18 # Immediates:
19 i32.const -1
20 f64.const 0x1.999999999999ap1
21 f32.const -1.0
22 f32.const -infinity
23 f32.const nan
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:
27 local.get 0
28 f64.store 1234:p2align=4
29 f64.store 1234 # Natural alignment (3)
30 # Loops, conditionals, binary ops, calls etc:
31 block i32
32 i32.const 1
33 local.get 0
34 i32.ge_s
35 br_if 0 # 0: down to label0
36 .LBB0_1:
37 loop i32 # label1:
38 call something1
39 i64.const 1234
40 i32.call something2
41 i32.const 0
42 call_indirect (i32, f64) -> ()
43 i32.const 1
44 i32.add
45 local.tee 0
46 local.get 0
47 i32.lt_s
48 br_if 0 # 0: up to label1
49 .LBB0_2:
50 end_loop
51 end_block # label0:
52 local.get 4
53 local.get 5
54 block void
55 block i64
56 block f32
57 block f64
58 br_table {0, 1, 2} # 2 entries, default
59 end_block # first entry jumps here.
60 i32.const 1
61 br 2
62 end_block # second entry jumps here.
63 i32.const 2
64 br 1
65 end_block # default jumps here.
66 i32.const 3
67 end_block # "switch" exit.
68 if # void
69 if i32
70 end_if
71 else
72 end_if
73 f32x4.add
74 # Test correct parsing of instructions with / and : in them:
75 # TODO: enable once instruction has been added.
76 #i32x4.trunc_sat_f32x4_s
77 i32.trunc_f32_s
78 try exnref
79 i32.atomic.load 0
80 atomic.notify 0
81 .LBB0_3:
82 catch
83 local.set 0
84 block i32
85 local.get 0
86 br_on_exn 0, __cpp_exception
87 rethrow
88 .LBB0_4:
89 end_block
90 end_try
91 i32.const .L.str
92 i32.load8_u .L.str+2
93 i32.load16_u .L.str:p2align=0
94 throw 0
95 .LBB0_5:
96 #i32.trunc_sat_f32_s
97 global.get __stack_pointer
98 end_function
100 .section .rodata..L.str,"",@
101 .hidden .L.str
102 .type .L.str,@object
103 .L.str:
104 .int8 'H'
105 .asciz "ello, World!"
106 .int16 1234
107 .int64 5000000000
108 .int32 2000000000
109 .size .L.str, 28
111 .section .init_array.42,"",@
112 .p2align 2
113 .int32 test0
115 .ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
116 .globaltype __stack_pointer, i32
118 # CHECK: .text
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
161 # CHECK-NEXT: block
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:
176 # CHECK-NEXT: if
177 # CHECK-NEXT: if i32
178 # CHECK-NEXT: end_if
179 # CHECK-NEXT: else
180 # CHECK-NEXT: end_if
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:
187 # CHECK-NEXT: catch
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