[llvm-commits] [llvm] r48632 - in /llvm/trunk: lib/Target/X86/X86CallingConv.td lib/Target/X86/X86FloatingPoint.cpp test/CodeGen/X86/fp-stack-2results.ll
Chris Lattner
sabre at nondot.org
Thu Mar 20 22:57:20 PDT 2008
Author: lattner
Date: Fri Mar 21 00:57:20 2008
New Revision: 48632
URL: http://llvm.org/viewvc/llvm-project?rev=48632&view=rev
Log:
Enable support for returning two long-double values in ST(0)/ST(1).
This allows us to compile fp-stack-2results.ll into:
_test:
fldz
fld1
ret
which returns 1 in ST(0) and 0 in ST(1). This is needed for x86-64
_Complex long double.
Added:
llvm/trunk/test/CodeGen/X86/fp-stack-2results.ll
Modified:
llvm/trunk/lib/Target/X86/X86CallingConv.td
llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp
Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=48632&r1=48631&r2=48632&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CallingConv.td (original)
+++ llvm/trunk/lib/Target/X86/X86CallingConv.td Fri Mar 21 00:57:20 2008
@@ -38,15 +38,15 @@
CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToReg<[MM0]>>,
// Long double types are always returned in ST0 (even with SSE).
- CCIfType<[f80], CCAssignToReg<[ST0]>>
+ CCIfType<[f80], CCAssignToReg<[ST0, ST1]>>
]>;
// X86-32 C return-value convention.
def RetCC_X86_32_C : CallingConv<[
// The X86-32 calling convention returns FP values in ST0, otherwise it is the
// same as the common X86 calling conv.
- CCIfType<[f32], CCAssignToReg<[ST0]>>,
- CCIfType<[f64], CCAssignToReg<[ST0]>>,
+ CCIfType<[f32], CCAssignToReg<[ST0, ST1]>>,
+ CCIfType<[f64], CCAssignToReg<[ST0, ST1]>>,
CCDelegateTo<RetCC_X86Common>
]>;
Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp?rev=48632&r1=48631&r2=48632&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Fri Mar 21 00:57:20 2008
@@ -1053,9 +1053,6 @@
return;
}
- assert(0 && "TODO: This code should work, but has never been tested."
- "Test it when we have multiple FP return values working");
-
// Otherwise, we are returning two values:
// 2) If returning the same value for both, we only have one thing in the FP
// stack. Consider: RET FP1, FP1
@@ -1083,7 +1080,7 @@
/// 4) Finally, FirstFPRegOp must be in ST(0) and SecondFPRegOp must be in
/// ST(1). Just remove both from our understanding of the stack and return.
assert(getStackEntry(0) == FirstFPRegOp && "Unknown regs live");
- assert(getStackEntry(0) == SecondFPRegOp && "Unknown regs live");
+ assert(getStackEntry(1) == SecondFPRegOp && "Unknown regs live");
StackTop = 0;
return;
}
Added: llvm/trunk/test/CodeGen/X86/fp-stack-2results.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-stack-2results.ll?rev=48632&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fp-stack-2results.ll (added)
+++ llvm/trunk/test/CodeGen/X86/fp-stack-2results.ll Fri Mar 21 00:57:20 2008
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep fldz
+; RUN: llvm-as < %s | llc -march=x86-64 | grep fld1
+
+; This is basically this code on x86-64:
+; _Complex long double test() { return 1.0; }
+define {x86_fp80, x86_fp80} @test() {
+ %A = fpext double 1.0 to x86_fp80
+ %B = fpext double 0.0 to x86_fp80
+ ret x86_fp80 %A, x86_fp80 %B
+}
+
More information about the llvm-commits
mailing list