Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | ; This is a very early test that just checks the representation of i32 |
| 2 | ; arithmetic instructions. No assembly tests are done. |
| 3 | |
| 4 | ; RUN: %llvm2ice --verbose inst %s | FileCheck %s |
| 5 | ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
Karl Schimpf | a667fb8 | 2014-05-19 14:56:51 -0700 | [diff] [blame] | 6 | ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 7 | ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| 8 | ; RUN: | FileCheck --check-prefix=DUMP %s |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 9 | |
| 10 | define i32 @Add(i32 %a, i32 %b) { |
| 11 | ; CHECK: define i32 @Add |
| 12 | entry: |
| 13 | %add = add i32 %b, %a |
| 14 | ; CHECK: add |
| 15 | tail call void @Use(i32 %add) |
| 16 | ; CHECK: call Use |
| 17 | ret i32 %add |
| 18 | } |
| 19 | |
| 20 | declare void @Use(i32) |
| 21 | |
| 22 | define i32 @And(i32 %a, i32 %b) { |
| 23 | ; CHECK: define i32 @And |
| 24 | entry: |
| 25 | %and = and i32 %b, %a |
| 26 | ; CHECK: and |
| 27 | tail call void @Use(i32 %and) |
| 28 | ; CHECK: call Use |
| 29 | ret i32 %and |
| 30 | } |
| 31 | |
| 32 | define i32 @Or(i32 %a, i32 %b) { |
| 33 | ; CHECK: define i32 @Or |
| 34 | entry: |
| 35 | %or = or i32 %b, %a |
| 36 | ; CHECK: or |
| 37 | tail call void @Use(i32 %or) |
| 38 | ; CHECK: call Use |
| 39 | ret i32 %or |
| 40 | } |
| 41 | |
| 42 | define i32 @Xor(i32 %a, i32 %b) { |
| 43 | ; CHECK: define i32 @Xor |
| 44 | entry: |
| 45 | %xor = xor i32 %b, %a |
| 46 | ; CHECK: xor |
| 47 | tail call void @Use(i32 %xor) |
| 48 | ; CHECK: call Use |
| 49 | ret i32 %xor |
| 50 | } |
| 51 | |
| 52 | define i32 @Sub(i32 %a, i32 %b) { |
| 53 | ; CHECK: define i32 @Sub |
| 54 | entry: |
| 55 | %sub = sub i32 %a, %b |
| 56 | ; CHECK: sub |
| 57 | tail call void @Use(i32 %sub) |
| 58 | ; CHECK: call Use |
| 59 | ret i32 %sub |
| 60 | } |
| 61 | |
| 62 | define i32 @Mul(i32 %a, i32 %b) { |
| 63 | ; CHECK: define i32 @Mul |
| 64 | entry: |
| 65 | %mul = mul i32 %b, %a |
| 66 | ; CHECK: imul |
| 67 | tail call void @Use(i32 %mul) |
| 68 | ; CHECK: call Use |
| 69 | ret i32 %mul |
| 70 | } |
| 71 | |
| 72 | define i32 @Sdiv(i32 %a, i32 %b) { |
| 73 | ; CHECK: define i32 @Sdiv |
| 74 | entry: |
| 75 | %div = sdiv i32 %a, %b |
| 76 | ; CHECK: cdq |
| 77 | ; CHECK: idiv |
| 78 | tail call void @Use(i32 %div) |
| 79 | ; CHECK: call Use |
| 80 | ret i32 %div |
| 81 | } |
| 82 | |
| 83 | define i32 @Srem(i32 %a, i32 %b) { |
| 84 | ; CHECK: define i32 @Srem |
| 85 | entry: |
| 86 | %rem = srem i32 %a, %b |
| 87 | ; CHECK: cdq |
| 88 | ; CHECK: idiv |
| 89 | tail call void @Use(i32 %rem) |
| 90 | ; CHECK: call Use |
| 91 | ret i32 %rem |
| 92 | } |
| 93 | |
| 94 | define i32 @Udiv(i32 %a, i32 %b) { |
| 95 | ; CHECK: define i32 @Udiv |
| 96 | entry: |
| 97 | %div = udiv i32 %a, %b |
| 98 | ; CHECK: div |
| 99 | tail call void @Use(i32 %div) |
| 100 | ; CHECK: call Use |
| 101 | ret i32 %div |
| 102 | } |
| 103 | |
| 104 | define i32 @Urem(i32 %a, i32 %b) { |
| 105 | ; CHECK: define i32 @Urem |
| 106 | entry: |
| 107 | %rem = urem i32 %a, %b |
| 108 | ; CHECK: div |
| 109 | tail call void @Use(i32 %rem) |
| 110 | ; CHECK: call Use |
| 111 | ret i32 %rem |
| 112 | } |
| 113 | |
Jim Stichnoth | ef8cf0e | 2014-08-26 22:16:29 -0700 | [diff] [blame^] | 114 | ; Check for a valid addressing mode in the x86-32 mul instruction when |
| 115 | ; the second source operand is an immediate. |
| 116 | define i64 @MulImm() { |
| 117 | entry: |
| 118 | %mul = mul i64 3, 4 |
| 119 | ret i64 %mul |
| 120 | } |
| 121 | ; CHECK-LABEL: MulImm |
| 122 | ; CHECK-NOT: mul {{[0-9]+}} |
| 123 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 124 | ; ERRORS-NOT: ICE translation error |
| 125 | ; DUMP-NOT: SZ |