OLD | NEW |
(Empty) | |
| 1 ; Tests various aspects of x86 immediate encoding. Some encodings are shorter. |
| 2 ; For example, the encoding is shorter for 8-bit immediates or when using EAX. |
| 3 ; This assumes that EAX is chosen as the first free register in O2 mode. |
| 4 |
| 5 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
| 6 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 7 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 8 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s |
| 9 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 10 |
| 11 define internal i32 @testXor8Imm8(i32 %arg) { |
| 12 entry: |
| 13 %arg_i8 = trunc i32 %arg to i8 |
| 14 %result_i8 = xor i8 %arg_i8, 127 |
| 15 %result = zext i8 %result_i8 to i32 |
| 16 ret i32 %result |
| 17 } |
| 18 ; CHECK-LABEL: testXor8Imm8 |
| 19 ; CHECK: 34 7f xor al, 127 |
| 20 |
| 21 define internal i32 @testXor8Imm8Neg(i32 %arg) { |
| 22 entry: |
| 23 %arg_i8 = trunc i32 %arg to i8 |
| 24 %result_i8 = xor i8 %arg_i8, -128 |
| 25 %result = zext i8 %result_i8 to i32 |
| 26 ret i32 %result |
| 27 } |
| 28 ; CHECK-LABEL: testXor8Imm8Neg |
| 29 ; CHECK: 34 80 xor al, -128 |
| 30 |
| 31 define internal i32 @testXor8Imm8NotEAX(i32 %arg, i32 %arg2, i32 %arg3) { |
| 32 entry: |
| 33 %arg_i8 = trunc i32 %arg to i8 |
| 34 %arg2_i8 = trunc i32 %arg2 to i8 |
| 35 %arg3_i8 = trunc i32 %arg3 to i8 |
| 36 %x1 = xor i8 %arg_i8, 127 |
| 37 %x2 = xor i8 %arg2_i8, 127 |
| 38 %x3 = xor i8 %arg3_i8, 127 |
| 39 %x4 = add i8 %x1, %x2 |
| 40 %x5 = add i8 %x4, %x3 |
| 41 %result = zext i8 %x5 to i32 |
| 42 ret i32 %result |
| 43 } |
| 44 ; CHECK-LABEL: testXor8Imm8NotEAX |
| 45 ; CHECK: 80 f{{[1-3]}} 7f xor {{[^a]}}l, 127 |
| 46 |
| 47 define internal i32 @testXor32Imm8(i32 %arg) { |
| 48 entry: |
| 49 %result = xor i32 %arg, 127 |
| 50 ret i32 %result |
| 51 } |
| 52 ; CHECK-LABEL: testXor32Imm8 |
| 53 ; CHECK: 83 f0 7f xor eax, 127 |
| 54 |
| 55 define internal i32 @testXor32Imm8Neg(i32 %arg) { |
| 56 entry: |
| 57 %result = xor i32 %arg, -128 |
| 58 ret i32 %result |
| 59 } |
| 60 ; CHECK-LABEL: testXor32Imm8Neg |
| 61 ; CHECK: 83 f0 80 xor eax, -128 |
| 62 |
| 63 define internal i32 @testXor32Imm32Eax(i32 %arg) { |
| 64 entry: |
| 65 %result = xor i32 %arg, 16777216 |
| 66 ret i32 %result |
| 67 } |
| 68 ; CHECK-LABEL: testXor32Imm32Eax |
| 69 ; CHECK: 35 00 00 00 01 xor eax, 16777216 |
| 70 |
| 71 define internal i32 @testXor32Imm32NegEax(i32 %arg) { |
| 72 entry: |
| 73 %result = xor i32 %arg, -256 |
| 74 ret i32 %result |
| 75 } |
| 76 ; CHECK-LABEL: testXor32Imm32NegEax |
| 77 ; CHECK: 35 00 ff ff ff xor eax, 4294967040 |
| 78 |
| 79 define internal i32 @testXor32Imm32NotEAX(i32 %arg, i32 %arg2, i32 %arg3) { |
| 80 entry: |
| 81 %x = xor i32 %arg, 32767 |
| 82 %x2 = xor i32 %arg2, 32767 |
| 83 %x3 = xor i32 %arg3, 32767 |
| 84 %add1 = add i32 %x, %x2 |
| 85 %add2 = add i32 %add1, %x3 |
| 86 ret i32 %add2 |
| 87 } |
| 88 ; CHECK-LABEL: testXor32Imm32NotEAX |
| 89 ; CHECK: 81 f{{[1-3]}} ff 7f 00 00 xor e{{[^a]}}x, 32767 |
| 90 |
| 91 ; Should be similar for add, sub, etc., so sample a few. |
| 92 |
| 93 define internal i32 @testAdd8Imm8(i32 %arg) { |
| 94 entry: |
| 95 %arg_i8 = trunc i32 %arg to i8 |
| 96 %result_i8 = add i8 %arg_i8, 126 |
| 97 %result = zext i8 %result_i8 to i32 |
| 98 ret i32 %result |
| 99 } |
| 100 ; CHECK-LABEL: testAdd8Imm8 |
| 101 ; CHECK: 04 7e add al, 126 |
| 102 |
| 103 define internal i32 @testSub8Imm8(i32 %arg) { |
| 104 entry: |
| 105 %arg_i8 = trunc i32 %arg to i8 |
| 106 %result_i8 = sub i8 %arg_i8, 125 |
| 107 %result = zext i8 %result_i8 to i32 |
| 108 ret i32 %result |
| 109 } |
| 110 ; CHECK-LABEL: testSub8Imm8 |
| 111 ; CHECK: 2c 7d sub al, 125 |
| 112 |
| 113 ; ERRORS-NOT: ICE translation error |
| 114 ; DUMP-NOT: SZ |
OLD | NEW |