Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1123)

Side by Side Diff: tests_lit/reader_tests/switch.ll

Issue 576243002: Add switch instruction to Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues in patch set 2. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/PNaClTranslator.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ; Test switch instructions.
2
3 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
4 ; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \
5 ; RUN: -allow-pnacl-reader-error-recovery \
6 ; RUN: -allow-local-symbol-tables \
7 ; RUN: | FileCheck %s
8
9 define void @testDefaultSwitch(i32 %a) {
10 entry:
11 switch i32 %a, label %exit [
12 ]
13 exit:
14 ret void
15 }
16
17 ; CHECK: define void @testDefaultSwitch(i32 %a) {
18 ; CHECK-NEXT: entry:
19 ; CHECK-NEXT: switch i32 %a, label %exit [
20 ; CHECK-NEXT: ]
21 ; CHECK-NEXT: exit:
22 ; CHECK-NEXT: ret void
23 ; CHECK-NEXT: }
24
25 define i32 @testSwitch(i32 %a) {
26 entry:
27 switch i32 %a, label %sw.default [
28 i32 1, label %sw.epilog
29 i32 2, label %sw.epilog
30 i32 3, label %sw.epilog
31 i32 7, label %sw.bb1
32 i32 8, label %sw.bb1
33 i32 15, label %sw.bb2
34 i32 14, label %sw.bb2
35 ]
36
37 sw.default: ; preds = %entry
38 %add = add i32 %a, 27
39 br label %sw.epilog
40
41 sw.bb1: ; preds = %entry, %entry
42 %phitmp = sub i32 21, %a
43 br label %sw.bb2
44
45 sw.bb2: ; preds = %sw.bb1, %entry, %en try
46 %result.0 = phi i32 [ 1, %entry ], [ 1, %entry ], [ %phitmp, %sw.bb1 ]
47 br label %sw.epilog
48
49 sw.epilog: ; preds = %sw.bb2, %sw.default , %entry, %entry, %entry
50 %result.1 = phi i32 [ %add, %sw.default ], [ %result.0, %sw.bb2 ], [ 17, %entr y ], [ 17, %entry ], [ 17, %entry ]
51 ret i32 %result.1
52 }
53
54 ; CHECK-NEXT: define i32 @testSwitch(i32 %a) {
55 ; CHECK-NEXT: entry:
56 ; CHECK-NEXT: switch i32 %a, label %sw.default [
57 ; CHECK-NEXT: i32 1, label %sw.epilog
58 ; CHECK-NEXT: i32 2, label %sw.epilog
59 ; CHECK-NEXT: i32 3, label %sw.epilog
60 ; CHECK-NEXT: i32 7, label %sw.bb1
61 ; CHECK-NEXT: i32 8, label %sw.bb1
62 ; CHECK-NEXT: i32 15, label %sw.bb2
63 ; CHECK-NEXT: i32 14, label %sw.bb2
64 ; CHECK-NEXT: ]
65 ; CHECK-NEXT: sw.default:
66 ; CHECK-NEXT: %add = add i32 %a, 27
67 ; CHECK-NEXT: br label %sw.epilog
68 ; CHECK-NEXT: sw.bb1:
69 ; CHECK-NEXT: %phitmp = sub i32 21, %a
70 ; CHECK-NEXT: br label %sw.bb2
71 ; CHECK-NEXT: sw.bb2:
72 ; CHECK-NEXT: %result.0 = phi i32 [ 1, %entry ], [ 1, %entry ], [ %phitmp, %sw .bb1 ]
73 ; CHECK-NEXT: br label %sw.epilog
74 ; CHECK-NEXT: sw.epilog:
75 ; CHECK-NEXT: %result.1 = phi i32 [ %add, %sw.default ], [ %result.0, %sw.bb2 ], [ 17, %entry ], [ 17, %entry ], [ 17, %entry ]
76 ; CHECK-NEXT: ret i32 %result.1
77 ; CHECK-NEXT: }
78
79 define void @testSignedI32Values(i32 %a) {
80 entry:
81 switch i32 %a, label %labelDefault [
82 i32 0, label %label0
83 i32 -1, label %labelM1
84 i32 3, label %labelOther
85 i32 -3, label %labelOther
86 i32 -2147483648, label %labelMin ; min signed i32
87 i32 2147483647, label %labelMax ; max signed i32
88 ]
89 labelDefault:
90 ret void
91 label0:
92 ret void
93 labelM1:
94 ret void
95 labelMin:
96 ret void
97 labelMax:
98 ret void
99 labelOther:
100 ret void
101 }
102
103 ; CHECK-NEXT: define void @testSignedI32Values(i32 %a) {
104 ; CHECK-NEXT: entry:
105 ; CHECK-NEXT: switch i32 %a, label %labelDefault [
106 ; CHECK-NEXT: i32 0, label %label0
107 ; CHECK-NEXT: i32 -1, label %labelM1
108 ; CHECK-NEXT: i32 3, label %labelOther
109 ; CHECK-NEXT: i32 -3, label %labelOther
110 ; CHECK-NEXT: i32 -2147483648, label %labelMin
111 ; CHECK-NEXT: i32 2147483647, label %labelMax
112 ; CHECK-NEXT: ]
113 ; CHECK-NEXT: labelDefault:
114 ; CHECK-NEXT: ret void
115 ; CHECK-NEXT: label0:
116 ; CHECK-NEXT: ret void
117 ; CHECK-NEXT: labelM1:
118 ; CHECK-NEXT: ret void
119 ; CHECK-NEXT: labelMin:
120 ; CHECK-NEXT: ret void
121 ; CHECK-NEXT: labelMax:
122 ; CHECK-NEXT: ret void
123 ; CHECK-NEXT: labelOther:
124 ; CHECK-NEXT: ret void
125 ; CHECK-NEXT: }
126
127 ; Test values that cross signed i32 size boundaries.
128 define void @testSignedI32Boundary(i32 %a) {
129 entry:
130 switch i32 %a, label %exit [
131 i32 -2147483649, label %exit ; min signed i32 - 1
132 i32 2147483648, label %exit ; max signed i32 + 1
133 ]
134 exit:
135 ret void
136 }
137
138 ; CHECK-NEXT: define void @testSignedI32Boundary(i32 %a) {
139 ; CHECK-NEXT: entry:
140 ; CHECK-NEXT: switch i32 %a, label %exit [
141 ; CHECK-NEXT: i32 2147483647, label %exit
142 ; CHECK-NEXT: i32 -2147483648, label %exit
143 ; CHECK-NEXT: ]
144 ; CHECK-NEXT: exit:
145 ; CHECK-NEXT: ret void
146 ; CHECK-NEXT: }
147
148 define void @testUnsignedI32Values(i32 %a) {
149 entry:
150 switch i32 %a, label %exit [
151 i32 0, label %exit
152 i32 2147483647, label %exit ; max signed i32
153 i32 4294967295, label %exit ; max unsigned i32
154 ]
155 exit:
156 ret void
157 }
158
159 ; CHECK-NEXT: define void @testUnsignedI32Values(i32 %a) {
160 ; CHECK-NEXT: entry:
161 ; CHECK-NEXT: switch i32 %a, label %exit [
162 ; CHECK-NEXT: i32 0, label %exit
163 ; CHECK-NEXT: i32 2147483647, label %exit
164 ; ; Note that -1 is signed version of 4294967295
165 ; CHECK-NEXT: i32 -1, label %exit
166 ; CHECK-NEXT: ]
167 ; CHECK-NEXT: exit:
168 ; CHECK-NEXT: ret void
169 ; CHECK-NEXT: }
170
171 ; Test values that cross unsigned i32 boundaries.
172 define void @testUnsignedI32Boundary(i32 %a) {
173 entry:
174 switch i32 %a, label %exit [
175 i32 4294967296, label %exit ; max unsigned i32 + 1
176 ]
177 exit:
178 ret void
179 }
180
181 ; CHECK-NEXT: define void @testUnsignedI32Boundary(i32 %a) {
182 ; CHECK-NEXT: entry:
183 ; CHECK-NEXT: switch i32 %a, label %exit [
184 ; CHECK-NEXT: i32 0, label %exit
185 ; CHECK-NEXT: ]
186 ; CHECK-NEXT: exit:
187 ; CHECK-NEXT: ret void
188 ; CHECK-NEXT: }
189
190 define void @testSignedI64Values(i64 %a) {
191 entry:
192 switch i64 %a, label %exit [
193 i64 0, label %exit
194 i64 -9223372036854775808, label %exit ; min signed i64
195 i64 9223372036854775807, label %exit ; max signed i64
196 ]
197 exit:
198 ret void
199 }
200
201 ; CHECK-NEXT: define void @testSignedI64Values(i64 %a) {
202 ; CHECK-NEXT: entry:
203 ; CHECK-NEXT: switch i64 %a, label %exit [
204 ; CHECK-NEXT: i64 0, label %exit
205 ; CHECK-NEXT: i64 -9223372036854775808, label %exit
206 ; CHECK-NEXT: i64 9223372036854775807, label %exit
207 ; CHECK-NEXT: ]
208 ; CHECK-NEXT: exit:
209 ; CHECK-NEXT: ret void
210 ; CHECK-NEXT: }
211
212 ; Test values that cross signed i64 size boundaries.
213 define void @testSignedI64Boundary(i64 %a) {
214 entry:
215 switch i64 %a, label %exit [
216 i64 0, label %exit
217 i64 -9223372036854775809, label %exit ; min signed i64 - 1
218 i64 9223372036854775808, label %exit ; max signed i64 + 1
219 ]
220 exit:
221 ret void
222 }
223
224 ; CHECK-NEXT: define void @testSignedI64Boundary(i64 %a) {
225 ; CHECK-NEXT: entry:
226 ; CHECK-NEXT: switch i64 %a, label %exit [
227 ; CHECK-NEXT: i64 0, label %exit
228 ; CHECK-NEXT: i64 9223372036854775807, label %exit
229 ; CHECK-NEXT: i64 -9223372036854775808, label %exit
230 ; CHECK-NEXT: ]
231 ; CHECK-NEXT: exit:
232 ; CHECK-NEXT: ret void
233 ; CHECK-NEXT: }
234
235 define void @testUnsignedI64Values(i64 %a) {
236 entry:
237 switch i64 %a, label %exit [
238 i64 0, label %exit
239 i64 9223372036854775807, label %exit ; max signed i64
240 i64 18446744073709551615, label %exit ; max unsigned i64
241 ]
242 exit:
243 ret void
244 }
245
246 ; CHECK-NEXT: define void @testUnsignedI64Values(i64 %a) {
247 ; CHECK-NEXT: entry:
248 ; CHECK-NEXT: switch i64 %a, label %exit [
249 ; CHECK-NEXT: i64 0, label %exit
250 ; CHECK-NEXT: i64 9223372036854775807, label %exit
251 ; CHECK-NEXT: i64 -1, label %exit
252 ; CHECK-NEXT: ]
253 ; CHECK-NEXT: exit:
254 ; CHECK-NEXT: ret void
255 ; CHECK-NEXT: }
256
257 ; Test values that cross unsigned i64 size boundaries.
258 define void @testUnsignedI64Boundary(i64 %a) {
259 entry:
260 switch i64 %a, label %exit [
261 i64 18446744073709551616, label %exit ; max unsigned i64 + 1
262 ]
263 exit:
264 ret void
265 }
266
267 ; CHECK-NEXT: define void @testUnsignedI64Boundary(i64 %a) {
268 ; CHECK-NEXT: entry:
269 ; CHECK-NEXT: switch i64 %a, label %exit [
270 ; CHECK-NEXT: i64 0, label %exit
271 ; CHECK-NEXT: ]
272 ; CHECK-NEXT: exit:
273 ; CHECK-NEXT: ret void
274 ; CHECK-NEXT: }
275
276 define void @testSignedI16Values(i32 %p) {
277 entry:
278 %a = trunc i32 %p to i16
279 switch i16 %a, label %exit [
280 i16 0, label %exit
281 i16 -1, label %exit
282 i16 3, label %exit
283 i16 -3, label %exit
284 i16 -32768, label %exit ; min signed i16
285 i16 32767, label %exit ; max unsigned i16
286 ]
287 exit:
288 ret void
289 }
290
291 ; CHECK-NEXT: define void @testSignedI16Values(i32 %p) {
292 ; CHECK-NEXT: entry:
293 ; CHECK-NEXT: %a = trunc i32 %p to i16
294 ; CHECK-NEXT: switch i16 %a, label %exit [
295 ; CHECK-NEXT: i16 0, label %exit
296 ; CHECK-NEXT: i16 -1, label %exit
297 ; CHECK-NEXT: i16 3, label %exit
298 ; CHECK-NEXT: i16 -3, label %exit
299 ; CHECK-NEXT: i16 -32768, label %exit
300 ; CHECK-NEXT: i16 32767, label %exit
301 ; CHECK-NEXT: ]
302 ; CHECK-NEXT: exit:
303 ; CHECK-NEXT: ret void
304 ; CHECK-NEXT: }
305
306 ; Test values that cross signed i16 size boundaries.
307 define void @testSignedI16Boundary(i32 %p) {
308 entry:
309 %a = trunc i32 %p to i16
310 switch i16 %a, label %exit [
311 i16 -32769, label %exit ; min signed i16 - 1
312 i16 32768, label %exit ; max unsigned i16 + 1
313 ]
314 exit:
315 ret void
316 }
317
318 ; CHECK-NEXT: define void @testSignedI16Boundary(i32 %p) {
319 ; CHECK-NEXT: entry:
320 ; CHECK-NEXT: %a = trunc i32 %p to i16
321 ; CHECK-NEXT: switch i16 %a, label %exit [
322 ; CHECK-NEXT: i16 32767, label %exit
323 ; CHECK-NEXT: i16 -32768, label %exit
324 ; CHECK-NEXT: ]
325 ; CHECK-NEXT: exit:
326 ; CHECK-NEXT: ret void
327 ; CHECK-NEXT: }
328
329 define void @testUnsignedI16Values(i32 %p) {
330 entry:
331 %a = trunc i32 %p to i16
332 switch i16 %a, label %exit [
333 i16 0, label %exit
334 i16 32767, label %exit ; max signed i16
335 i16 65535, label %exit ; max unsigned i16
336 ]
337 exit:
338 ret void
339 }
340
341 ; CHECK-NEXT: define void @testUnsignedI16Values(i32 %p) {
342 ; CHECK-NEXT: entry:
343 ; CHECK-NEXT: %a = trunc i32 %p to i16
344 ; CHECK-NEXT: switch i16 %a, label %exit [
345 ; CHECK-NEXT: i16 0, label %exit
346 ; CHECK-NEXT: i16 32767, label %exit
347 ; ; Note that -1 is signed version of 65535
348 ; CHECK-NEXT: i16 -1, label %exit
349 ; CHECK-NEXT: ]
350 ; CHECK-NEXT: exit:
351 ; CHECK-NEXT: ret void
352 ; CHECK-NEXT: }
353
354 ; Test values that cross unsigned i16 size boundaries.
355 define void @testUnsignedI16Boundary(i32 %p) {
356 entry:
357 %a = trunc i32 %p to i16
358 switch i16 %a, label %exit [
359 i16 65536, label %exit ; max unsigned i16 + 1
360 ]
361 exit:
362 ret void
363 }
364
365 ; CHECK-NEXT: define void @testUnsignedI16Boundary(i32 %p) {
366 ; CHECK-NEXT: entry:
367 ; CHECK-NEXT: %a = trunc i32 %p to i16
368 ; CHECK-NEXT: switch i16 %a, label %exit [
369 ; CHECK-NEXT: i16 0, label %exit
370 ; CHECK-NEXT: ]
371 ; CHECK-NEXT: exit:
372 ; CHECK-NEXT: ret void
373 ; CHECK-NEXT: }
374
375 define void @testSignedI8Values(i32 %p) {
376 entry:
377 %a = trunc i32 %p to i8
378 switch i8 %a, label %exit [
379 i8 0, label %exit
380 i8 -1, label %exit
381 i8 3, label %exit
382 i8 -3, label %exit
383 i8 -128, label %exit ; min signed i8
384 i8 127, label %exit ; max unsigned i8
385 ]
386 exit:
387 ret void
388 }
389
390 ; CHECK-NEXT: define void @testSignedI8Values(i32 %p) {
391 ; CHECK-NEXT: entry:
392 ; CHECK-NEXT: %a = trunc i32 %p to i8
393 ; CHECK-NEXT: switch i8 %a, label %exit [
394 ; CHECK-NEXT: i8 0, label %exit
395 ; CHECK-NEXT: i8 -1, label %exit
396 ; CHECK-NEXT: i8 3, label %exit
397 ; CHECK-NEXT: i8 -3, label %exit
398 ; CHECK-NEXT: i8 -128, label %exit
399 ; CHECK-NEXT: i8 127, label %exit
400 ; CHECK-NEXT: ]
401 ; CHECK-NEXT: exit:
402 ; CHECK-NEXT: ret void
403 ; CHECK-NEXT: }
404
405 ; Test values that cross signed i8 size boundaries.
406 define void @testSignedI8Boundary(i32 %p) {
407 entry:
408 %a = trunc i32 %p to i8
409 switch i8 %a, label %exit [
410 i8 -129, label %exit ; min signed i8 - 1
411 i8 128, label %exit ; max unsigned i8 + 1
412 ]
413 exit:
414 ret void
415 }
416
417 ; CHECK-NEXT: define void @testSignedI8Boundary(i32 %p) {
418 ; CHECK-NEXT: entry:
419 ; CHECK-NEXT: %a = trunc i32 %p to i8
420 ; CHECK-NEXT: switch i8 %a, label %exit [
421 ; CHECK-NEXT: i8 127, label %exit
422 ; CHECK-NEXT: i8 -128, label %exit
423 ; CHECK-NEXT: ]
424 ; CHECK-NEXT: exit:
425 ; CHECK-NEXT: ret void
426 ; CHECK-NEXT: }
427
428
429 define void @testUnsignedI8Values(i32 %p) {
430 entry:
431 %a = trunc i32 %p to i8
432 switch i8 %a, label %exit [
433 i8 0, label %exit
434 i8 127, label %exit ; max signed i8
435 i8 255, label %exit ; max unsigned i8
436 ]
437 exit:
438 ret void
439 }
440
441 ; CHECK-NEXT: define void @testUnsignedI8Values(i32 %p) {
442 ; CHECK-NEXT: entry:
443 ; CHECK-NEXT: %a = trunc i32 %p to i8
444 ; CHECK-NEXT: switch i8 %a, label %exit [
445 ; CHECK-NEXT: i8 0, label %exit
446 ; CHECK-NEXT: i8 127, label %exit
447 ; ; Note that -1 is signed version of 255
448 ; CHECK-NEXT: i8 -1, label %exit
449 ; CHECK-NEXT: ]
450 ; CHECK-NEXT: exit:
451 ; CHECK-NEXT: ret void
452 ; CHECK-NEXT: }
453
454 ; Test values that cross unsigned i8 size boundaries.
455 define void @testUnsignedI8Boundary(i32 %p) {
456 entry:
457 %a = trunc i32 %p to i8
458 switch i8 %a, label %exit [
459 i8 256, label %exit ; max unsigned i8
460 ]
461 exit:
462 ret void
463 }
464
465 ; CHECK-NEXT: define void @testUnsignedI8Boundary(i32 %p) {
466 ; CHECK-NEXT: entry:
467 ; CHECK-NEXT: %a = trunc i32 %p to i8
468 ; CHECK-NEXT: switch i8 %a, label %exit [
469 ; CHECK-NEXT: i8 0, label %exit
470 ; CHECK-NEXT: ]
471 ; CHECK-NEXT: exit:
472 ; CHECK-NEXT: ret void
473 ; CHECK-NEXT: }
474
475 define void @testI1Values(i32 %p) {
476 entry:
477 %a = trunc i32 %p to i1
478 switch i1 %a, label %exit [
479 i1 true, label %exit
480 i1 false, label %exit
481 ]
482 exit:
483 ret void
484 }
485
486 ; CHECK-NEXT: define void @testI1Values(i32 %p) {
487 ; CHECK-NEXT: entry:
488 ; CHECK-NEXT: %a = trunc i32 %p to i1
489 ; CHECK-NEXT: switch i1 %a, label %exit [
490 ; CHECK-NEXT: i1 -1, label %exit
491 ; CHECK-NEXT: i1 0, label %exit
492 ; CHECK-NEXT: ]
493 ; CHECK-NEXT: exit:
494 ; CHECK-NEXT: ret void
495 ; CHECK-NEXT: }
496
OLDNEW
« no previous file with comments | « src/PNaClTranslator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698