blob: f81b317ec05e5eaf4c897c1097ba3a720dbcf96f [file] [log] [blame]
Jan Voung86ebec12015-08-09 07:58:35 -07001; 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
16define internal i32 @doubleArgs(double %a, i32 %b, double %c) {
17entry:
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
25define internal i32 @floatArgs(float %a, i32 %b, float %c) {
26entry:
27 ret i32 %b
28}
29; CHECK-LABEL: floatArgs
30; CHECK: mov eax,DWORD PTR [esp+0x8]
31; CHECK-NEXT: ret
32
33define internal i32 @passFpArgs(float %a, double %b, float %c, double %d, float %e, double %f) {
34entry:
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
50declare i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z)
51
52define internal i32 @passFpConstArg(float %a, double %b) {
53entry:
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
61define internal i32 @passFp32ConstArg(float %a) {
62entry:
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
71declare i32 @ignoreFp32ArgsNoInline(float %x, i32 %y, float %z)
72
73define internal float @returnFloatArg(float %a) {
74entry:
75 ret float %a
76}
77; CHECK-LABEL: returnFloatArg
78; CHECK: fld DWORD PTR [esp
79
80define internal double @returnDoubleArg(double %a) {
81entry:
82 ret double %a
83}
84; CHECK-LABEL: returnDoubleArg
85; CHECK: fld QWORD PTR [esp
86
87define internal float @returnFloatConst() {
88entry:
89 ret float 0x3FF3AE1480000000
90}
91; CHECK-LABEL: returnFloatConst
92; CHECK: fld
93
94define internal double @returnDoubleConst() {
95entry:
96 ret double 1.230000e+00
97}
98; CHECK-LABEL: returnDoubleConst
99; CHECK: fld