diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4166,6 +4166,7 @@ def mno_x87 : Flag<["-"], "mno-x87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def mno_80387 : Flag<["-"], "mno-80387">, Alias; +def mno_fp_ret_in_387 : Flag<["-"], "mno-fp-ret-in-387">, Alias; def mmmx : Flag<["-"], "mmmx">, Group; def mno_mmx : Flag<["-"], "mno-mmx">, Group; def m3dnow : Flag<["-"], "m3dnow">, Group; diff --git a/clang/test/Driver/x86-target-features.c b/clang/test/Driver/x86-target-features.c --- a/clang/test/Driver/x86-target-features.c +++ b/clang/test/Driver/x86-target-features.c @@ -2,6 +2,7 @@ // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-x87 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -m80387 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=X87 %s // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-80387 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-fp-ret-in-387 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s // X87: "-target-feature" "+x87" // NO-X87: "-target-feature" "-x87" diff --git a/llvm/lib/Target/X86/X86CallingConv.td b/llvm/lib/Target/X86/X86CallingConv.td --- a/llvm/lib/Target/X86/X86CallingConv.td +++ b/llvm/lib/Target/X86/X86CallingConv.td @@ -273,6 +273,10 @@ // conv. CCIfInReg>>>, + CCIfNotSubtarget<"hasX87()", + CCIfType<[f32], CCAssignToReg<[AX, DX, CX]>>>, + CCIfNotSubtarget<"hasX87()", + CCIfType<[f64], CCAssignToReg<[EAX, EDX, ECX]>>>, CCIfType<[f32,f64], CCAssignToReg<[FP0, FP1]>>, CCIfType<[f16], CCAssignToReg<[XMM0,XMM1,XMM2]>>, CCDelegateTo diff --git a/llvm/test/CodeGen/X86/no-x87.ll b/llvm/test/CodeGen/X86/no-x87.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/no-x87.ll @@ -0,0 +1,17 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefix=X87 +; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s -check-prefix=NOX87 + +define float @foo(float %a, float %b) nounwind { +; X87-LABEL: foo: +; X87: # %bb.0: # %entry +; X87-NEXT: flds {{[0-9]+}}(%esp) +; X87-NEXT: retl +; +; NOX87-LABEL: foo: +; NOX87: # %bb.0: # %entry +; NOX87-NEXT: movl {{[0-9]+}}(%esp), %eax +; NOX87-NEXT: retl +entry: + ret float %b +}