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