From e672af15d6d7000fca2b39981b17403bdd5ec9ed Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Tue, 5 Feb 2008 20:46:33 +0000 Subject: [PATCH] Implement sseregparm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46764 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CallingConv.h | 6 +++++- lib/Target/X86/X86CallingConv.td | 18 ++++++++++++++++-- lib/Target/X86/X86ISelLowering.cpp | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/llvm/CallingConv.h b/include/llvm/CallingConv.h index bb76defc266..13dd0f79e78 100644 --- a/include/llvm/CallingConv.h +++ b/include/llvm/CallingConv.h @@ -57,7 +57,11 @@ namespace CallingConv { /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments /// in ECX:EDX registers, others - via stack. Callee is responsible for /// stack cleaning. - X86_FastCall = 65 + X86_FastCall = 65, + + /// X86_SSEreg - The standard convention except that float and double + /// values are returned in XMM0 if SSE support is available. + X86_SSECall = 66 }; } // End CallingConv namespace diff --git a/lib/Target/X86/X86CallingConv.td b/lib/Target/X86/X86CallingConv.td index 4d674f73ce8..eb88ce3052f 100644 --- a/lib/Target/X86/X86CallingConv.td +++ b/lib/Target/X86/X86CallingConv.td @@ -61,6 +61,15 @@ def RetCC_X86_32_Fast : CallingConv<[ CCDelegateTo ]>; +// X86-32 SSEregparm return-value convention. +def RetCC_X86_32_SSE : CallingConv<[ + // The X86-32 sseregparm calling convention returns FP values in XMM0 if the + // target has SSE2, otherwise it is the C calling convention. + CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0]>>>, + CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0]>>>, + CCDelegateTo +]>; + // X86-64 C return-value convention. def RetCC_X86_64_C : CallingConv<[ // The X86-64 calling convention always returns FP values in XMM0. @@ -69,12 +78,12 @@ def RetCC_X86_64_C : CallingConv<[ CCDelegateTo ]>; - - // This is the root return-value convention for the X86-32 backend. def RetCC_X86_32 : CallingConv<[ // If FastCC, use RetCC_X86_32_Fast. CCIfCC<"CallingConv::Fast", CCDelegateTo>, + // If SSECC, use RetCC_X86_32_SSE. + CCIfCC<"CallingConv::X86_SSECall", CCDelegateTo>, // Otherwise, use RetCC_X86_32_C. CCDelegateTo ]>; @@ -179,6 +188,11 @@ def CC_X86_32_Common : CallingConv<[ // Handles byval parameters. CCIfByVal>, + // The first 3 float or double arguments, if marked 'inreg' and if the call + // is not a vararg call and if SSE2 is available, are passed in SSE registers. + CCIfNotVarArg>>>>, + // Integer/Float values get stored in stack slots that are 4 bytes in // size and 4-byte aligned. CCIfType<[i32, f32], CCAssignToStack<4, 4>>, diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index af993e1627c..091ce1870e1 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -1137,9 +1137,9 @@ X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) { RC = X86::GR32RegisterClass; else if (Is64Bit && RegVT == MVT::i64) RC = X86::GR64RegisterClass; - else if (Is64Bit && RegVT == MVT::f32) + else if (RegVT == MVT::f32) RC = X86::FR32RegisterClass; - else if (Is64Bit && RegVT == MVT::f64) + else if (RegVT == MVT::f64) RC = X86::FR64RegisterClass; else { assert(MVT::isVector(RegVT)); -- 2.34.1