Jan Voung | 86ebec1 | 2015-08-09 07:58:35 -0700 | [diff] [blame] | 1 | ; This tries to be a comprehensive test of f32 and f64 call/return ops. |
| 2 | ; The CHECK lines are only checking for basic instruction patterns |
| 3 | ; that should be present regardless of the optimization level, so |
| 4 | ; there are no special OPTM1 match lines. |
| 5 | |
| 6 | ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 7 | ; RUN: --target x8632 -i %s --args -O2 \ |
| 8 | ; RUN: | %if --need=target_X8632 --command FileCheck %s |
| 9 | ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 10 | ; RUN: --target x8632 -i %s --args -Om1 \ |
| 11 | ; RUN: | %if --need=target_X8632 --command FileCheck %s |
| 12 | |
| 13 | ; Can't test on ARM yet. Need to use several vpush {contiguous FP regs}, |
| 14 | ; instead of push {any GPR list}. |
| 15 | |
| 16 | define internal i32 @doubleArgs(double %a, i32 %b, double %c) { |
| 17 | entry: |
| 18 | ret i32 %b |
| 19 | } |
| 20 | ; CHECK-LABEL: doubleArgs |
| 21 | ; CHECK: mov eax,DWORD PTR [esp+0xc] |
| 22 | ; CHECK-NEXT: ret |
| 23 | ; ARM32-LABEL: doubleArgs |
| 24 | |
| 25 | define internal i32 @floatArgs(float %a, i32 %b, float %c) { |
| 26 | entry: |
| 27 | ret i32 %b |
| 28 | } |
| 29 | ; CHECK-LABEL: floatArgs |
| 30 | ; CHECK: mov eax,DWORD PTR [esp+0x8] |
| 31 | ; CHECK-NEXT: ret |
| 32 | |
| 33 | define internal i32 @passFpArgs(float %a, double %b, float %c, double %d, float %e, double %f) { |
| 34 | entry: |
| 35 | %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double %b) |
| 36 | %call1 = call i32 @ignoreFpArgsNoInline(float %c, i32 123, double %d) |
| 37 | %call2 = call i32 @ignoreFpArgsNoInline(float %e, i32 123, double %f) |
| 38 | %add = add i32 %call1, %call |
| 39 | %add3 = add i32 %add, %call2 |
| 40 | ret i32 %add3 |
| 41 | } |
| 42 | ; CHECK-LABEL: passFpArgs |
| 43 | ; CHECK: mov DWORD PTR [esp+0x4],0x7b |
| 44 | ; CHECK: call {{.*}} R_{{.*}} ignoreFpArgsNoInline |
| 45 | ; CHECK: mov DWORD PTR [esp+0x4],0x7b |
| 46 | ; CHECK: call {{.*}} R_{{.*}} ignoreFpArgsNoInline |
| 47 | ; CHECK: mov DWORD PTR [esp+0x4],0x7b |
| 48 | ; CHECK: call {{.*}} R_{{.*}} ignoreFpArgsNoInline |
| 49 | |
| 50 | declare i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z) |
| 51 | |
| 52 | define internal i32 @passFpConstArg(float %a, double %b) { |
| 53 | entry: |
| 54 | %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double 2.340000e+00) |
| 55 | ret i32 %call |
| 56 | } |
| 57 | ; CHECK-LABEL: passFpConstArg |
| 58 | ; CHECK: mov DWORD PTR [esp+0x4],0x7b |
| 59 | ; CHECK: call {{.*}} R_{{.*}} ignoreFpArgsNoInline |
| 60 | |
| 61 | define internal i32 @passFp32ConstArg(float %a) { |
| 62 | entry: |
| 63 | %call = call i32 @ignoreFp32ArgsNoInline(float %a, i32 123, float 2.0) |
| 64 | ret i32 %call |
| 65 | } |
| 66 | ; CHECK-LABEL: passFp32ConstArg |
| 67 | ; CHECK: mov DWORD PTR [esp+0x4],0x7b |
| 68 | ; CHECK: movss DWORD PTR [esp+0x8] |
| 69 | ; CHECK: call {{.*}} R_{{.*}} ignoreFp32ArgsNoInline |
| 70 | |
| 71 | declare i32 @ignoreFp32ArgsNoInline(float %x, i32 %y, float %z) |
| 72 | |
| 73 | define internal float @returnFloatArg(float %a) { |
| 74 | entry: |
| 75 | ret float %a |
| 76 | } |
| 77 | ; CHECK-LABEL: returnFloatArg |
| 78 | ; CHECK: fld DWORD PTR [esp |
| 79 | |
| 80 | define internal double @returnDoubleArg(double %a) { |
| 81 | entry: |
| 82 | ret double %a |
| 83 | } |
| 84 | ; CHECK-LABEL: returnDoubleArg |
| 85 | ; CHECK: fld QWORD PTR [esp |
| 86 | |
| 87 | define internal float @returnFloatConst() { |
| 88 | entry: |
| 89 | ret float 0x3FF3AE1480000000 |
| 90 | } |
| 91 | ; CHECK-LABEL: returnFloatConst |
| 92 | ; CHECK: fld |
| 93 | |
| 94 | define internal double @returnDoubleConst() { |
| 95 | entry: |
| 96 | ret double 1.230000e+00 |
| 97 | } |
| 98 | ; CHECK-LABEL: returnDoubleConst |
| 99 | ; CHECK: fld |