[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / test / MC / WebAssembly / basic-assembly.s
blob17b501b25689d937bf8d0c46748c0468d5721a0c
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 block () -> (i32, i32)
59 i32.const 1
60 i32.const 2
61 end_block
62 drop
63 drop
64 br_table {0, 1, 2} # 2 entries, default
65 end_block # first entry jumps here.
66 i32.const 1
67 br 2
68 end_block # second entry jumps here.
69 i32.const 2
70 br 1
71 end_block # default jumps here.
72 i32.const 3
73 end_block # "switch" exit.
74 if # void
75 if i32
76 end_if
77 else
78 end_if
79 f32x4.add
80 # Test correct parsing of instructions with / and : in them:
81 # TODO: enable once instruction has been added.
82 #i32x4.trunc_sat_f32x4_s
83 i32.trunc_f32_s
84 try exnref
85 i32.atomic.load 0
86 atomic.notify 0
87 .LBB0_3:
88 catch
89 local.set 0
90 block i32
91 local.get 0
92 br_on_exn 0, __cpp_exception
93 rethrow
94 .LBB0_4:
95 end_block
96 end_try
97 i32.const .L.str
98 i32.load8_u .L.str+2
99 i32.load16_u .L.str:p2align=0
100 throw 0
101 .LBB0_5:
102 #i32.trunc_sat_f32_s
103 global.get __stack_pointer
104 end_function
106 .section .rodata..L.str,"",@
107 .hidden .L.str
108 .type .L.str,@object
109 .L.str:
110 .int8 'H'
111 .asciz "ello, World!"
112 .int16 1234
113 .int64 5000000000
114 .int32 2000000000
115 .size .L.str, 28
117 .section .init_array.42,"",@
118 .p2align 2
119 .int32 test0
121 .ident "clang version 9.0.0 (trunk 364502) (llvm/trunk 364571)"
122 .globaltype __stack_pointer, i32
124 # CHECK: .text
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
167 # CHECK-NEXT: block
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
175 # CHECK-NEXT: drop
176 # CHECK-NEXT: drop
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:
188 # CHECK-NEXT: if
189 # CHECK-NEXT: if i32
190 # CHECK-NEXT: end_if
191 # CHECK-NEXT: else
192 # CHECK-NEXT: end_if
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:
199 # CHECK-NEXT: catch
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