Add support for calls that return two FP values in
[oota-llvm.git] / test / CodeGen / X86 / fp-stack-2results.ll
1 ; RUN: llvm-as < %s | llc -march=x86 | grep fldz
2 ; RUN: llvm-as < %s | llc -march=x86-64 | grep fld1
3
4 ; This is basically this code on x86-64:
5 ; _Complex long double test() { return 1.0; }
6 define {x86_fp80, x86_fp80} @test() {
7   %A = fpext double 1.0 to x86_fp80
8   %B = fpext double 0.0 to x86_fp80
9   ret x86_fp80 %A, x86_fp80 %B
10 }
11
12
13 ;_test2:
14 ;       fld1
15 ;       fld     %st(0)
16 ;       ret
17 define {x86_fp80, x86_fp80} @test2() {
18   %A = fpext double 1.0 to x86_fp80
19   ret x86_fp80 %A, x86_fp80 %A
20 }
21
22 ; Uses both values.
23 define void @call1(x86_fp80 *%P1, x86_fp80 *%P2) {
24   %a = call {x86_fp80,x86_fp80} @test()
25   %b = getresult {x86_fp80,x86_fp80} %a, 0
26   store x86_fp80 %b, x86_fp80* %P1
27
28   %c = getresult {x86_fp80,x86_fp80} %a, 1
29   store x86_fp80 %c, x86_fp80* %P2
30   ret void 
31 }
32
33 ; Uses both values, requires fxch
34 define void @call2(x86_fp80 *%P1, x86_fp80 *%P2) {
35   %a = call {x86_fp80,x86_fp80} @test()
36   %b = getresult {x86_fp80,x86_fp80} %a, 1
37   store x86_fp80 %b, x86_fp80* %P1
38
39   %c = getresult {x86_fp80,x86_fp80} %a, 0
40   store x86_fp80 %c, x86_fp80* %P2
41   ret void
42 }
43
44 ; Uses ST(0), ST(1) is dead but must be popped.
45 define void @call3(x86_fp80 *%P1, x86_fp80 *%P2) {
46   %a = call {x86_fp80,x86_fp80} @test()
47   %b = getresult {x86_fp80,x86_fp80} %a, 0
48   store x86_fp80 %b, x86_fp80* %P1
49   ret void 
50 }
51
52 ; Uses ST(1), ST(0) is dead and must be popped.
53 define void @call4(x86_fp80 *%P1, x86_fp80 *%P2) {
54   %a = call {x86_fp80,x86_fp80} @test()
55
56   %c = getresult {x86_fp80,x86_fp80} %a, 1
57   store x86_fp80 %c, x86_fp80* %P2
58   ret void 
59 }
60