OLD | NEW |
1 ; RUN: opt -verify-pnaclabi-functions -analyze < %s |& FileCheck %s | 1 ; RUN: opt -verify-pnaclabi-functions -analyze < %s |& FileCheck %s |
2 ; Test instruction opcodes allowed by PNaCl ABI | 2 ; Test instruction opcodes allowed by PNaCl ABI |
| 3 ; No testing yet of operands, types, attributes, etc |
3 | 4 |
4 target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64
:64:64-p:32:32:32-v128:32:32" | 5 target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64
:64:64-p:32:32:32-v128:32:32" |
5 target triple = "le32-unknown-nacl" | 6 target triple = "le32-unknown-nacl" |
6 | 7 |
7 define i32 @terminators() nounwind { | 8 define void @terminators() { |
8 ; Terminator instructions | 9 ; Terminator instructions |
9 terminators: | 10 terminators: |
10 ret i32 0 | 11 ret void |
11 br i1 0, label %next2, label %next | 12 br i1 0, label %next2, label %next |
12 next: | 13 next: |
13 switch i32 1, label %next2 [i32 0, label %next] | 14 switch i32 1, label %next2 [i32 0, label %next] |
14 next2: | 15 next2: |
15 unreachable | 16 unreachable |
16 resume i8 0 | 17 resume i8 0 |
17 indirectbr i8* undef, [label %next, label %next2] | 18 indirectbr i8* undef, [label %next, label %next2] |
18 ; CHECK-NOT: disallowed | 19 ; CHECK-NOT: disallowed |
19 ; CHECK: Function terminators has disallowed instruction: indirectbr | 20 ; CHECK: Function terminators has disallowed instruction: indirectbr |
20 } | 21 } |
| 22 |
| 23 define void @binops() { |
| 24 ; Binary operations |
| 25 %a1 = add i32 0, 0 |
| 26 %a2 = sub i32 0, 0 |
| 27 %a3 = fsub float 0.0, 0.0 |
| 28 %a4 = mul i32 0, 0 |
| 29 %a5 = fmul float 0.0, 0.0 |
| 30 %a6 = udiv i32 0, 1 |
| 31 %a7 = sdiv i32 0, 1 |
| 32 %a8 = fdiv float 0.0, 1.0 |
| 33 %a9 = urem i32 0, 1 |
| 34 %a10 = srem i32 0, 1 |
| 35 %a11 = frem float 0.0, 1.0 |
| 36 ; Bitwise binary operations |
| 37 %a12 = shl i32 1, 1 |
| 38 %a13 = lshr i32 1, 1 |
| 39 %a14 = ashr i32 1, 1 |
| 40 %a15 = and i32 1, 1 |
| 41 %a16 = or i32 1, 1 |
| 42 %a17 = xor i32 1, 1 |
| 43 ret void |
| 44 } |
| 45 |
| 46 define void @vectors() { |
| 47 ; CHECK-NOT: disallowed |
| 48 %a1 = extractelement <2 x i32> <i32 0, i32 0>, i32 0 |
| 49 ; CHECK: Function vectors has disallowed instruction: extractelement |
| 50 %a2 = shufflevector <2 x i32> undef , <2 x i32> undef, <2 x i32> undef |
| 51 ; CHECK: Function vectors has disallowed instruction: shufflevector |
| 52 %a3 = insertelement <2 x i32> undef, i32 1, i32 0 |
| 53 ; CHECK: Function vectors has disallowed instruction: insertelement |
| 54 ret void |
| 55 } |
| 56 |
| 57 define void @aggregates() { |
| 58 ; Aggregate operations |
| 59 %a1 = extractvalue { i32, i32 } { i32 0, i32 0 }, 0 |
| 60 %a2 = insertvalue {i32, float} undef, i32 1, 0 |
| 61 ret void |
| 62 } |
| 63 |
| 64 define void @memory() { |
| 65 ; Memory operations |
| 66 %a1 = alloca i32 |
| 67 %a2 = load i32* undef |
| 68 store i32 undef, i32* undef |
| 69 fence acq_rel |
| 70 %a3 = cmpxchg i32* undef, i32 undef, i32 undef acq_rel |
| 71 %a4 = atomicrmw add i32* undef, i32 1 acquire |
| 72 %a5 = getelementptr { i32, i32}* undef |
| 73 ret void |
| 74 } |
| 75 |
| 76 define void @conversion() { |
| 77 ; Conversion operations |
| 78 %a1 = trunc i32 undef to i8 |
| 79 %a2 = zext i8 undef to i32 |
| 80 %a3 = sext i8 undef to i32 |
| 81 %a4 = fptrunc double undef to float |
| 82 %a5 = fpext float undef to double |
| 83 %a6 = fptoui double undef to i64 |
| 84 %a7 = fptosi double undef to i64 |
| 85 %a8 = uitofp i64 undef to double |
| 86 %a9 = sitofp i64 undef to double |
| 87 %a10 = ptrtoint i8* undef to i32 |
| 88 %a11 = inttoptr i32 undef to i8* |
| 89 %a12 = bitcast i8* undef to i32* |
| 90 ret void |
| 91 } |
| 92 |
| 93 define void @other() { |
| 94 entry: |
| 95 %a1 = icmp eq i32 undef, undef |
| 96 %a2 = fcmp eq float undef, undef |
| 97 br i1 undef, label %foo, label %bar |
| 98 foo: |
| 99 ; phi predecessor labels have to match to appease module verifier |
| 100 %a3 = phi i32 [0, %entry], [0, %foo] |
| 101 %a4 = select i1 true, i8 undef, i8 undef |
| 102 %a5 = va_arg i8** undef, i32 |
| 103 call void @conversion() |
| 104 br i1 undef, label %foo, label %bar |
| 105 bar: |
| 106 ret void |
| 107 } |
| 108 ; CHECK-NOT: disallowed |
| 109 ; If another check is added, there should be a check-not in between each check |
OLD | NEW |