2007-10-13 05:30:57 +08:00
|
|
|
//===- X86CallingConv.td - Calling Conventions X86 32/64 ---*- tablegen -*-===//
|
2007-02-27 02:17:14 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-02-27 02:17:14 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This describes the calling conventions for the X86-32 and X86-64
|
|
|
|
// architectures.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-02-28 13:30:29 +08:00
|
|
|
/// CCIfSubtarget - Match if the current subtarget has a feature F.
|
|
|
|
class CCIfSubtarget<string F, CCAction A>
|
|
|
|
: CCIf<!strconcat("State.getTarget().getSubtarget<X86Subtarget>().", F), A>;
|
2007-02-28 12:51:41 +08:00
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Return Value Calling Conventions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-02-27 13:51:05 +08:00
|
|
|
// Return-value conventions common to all X86 CC's.
|
2007-02-27 02:17:14 +08:00
|
|
|
def RetCC_X86Common : CallingConv<[
|
|
|
|
// Scalar values are returned in AX first, then DX.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[i8] , CCAssignToReg<[AL]>>,
|
2008-04-10 01:53:38 +08:00
|
|
|
CCIfType<[i16], CCAssignToReg<[AX, DX]>>,
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[EAX, EDX]>>,
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RAX, RDX]>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
|
2008-11-20 15:48:19 +08:00
|
|
|
// Vector types are returned in XMM0 and XMM1, when they fit. XMMM2 and XMM3
|
|
|
|
// can only be used by ABI non-compliant code. If the target doesn't have XMM
|
|
|
|
// registers, it won't have vector types.
|
2007-07-03 00:21:53 +08:00
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2008-11-20 15:48:19 +08:00
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2,XMM3]>>,
|
2007-03-30 08:35:22 +08:00
|
|
|
|
|
|
|
// MMX vector types are always returned in MM0. If the target doesn't have
|
|
|
|
// MM0, it doesn't support these vector types.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32], CCAssignToReg<[MM0]>>,
|
2007-08-07 05:31:06 +08:00
|
|
|
|
|
|
|
// Long double types are always returned in ST0 (even with SSE).
|
2008-03-21 13:57:20 +08:00
|
|
|
CCIfType<[f80], CCAssignToReg<[ST0, ST1]>>
|
2007-02-27 02:17:14 +08:00
|
|
|
]>;
|
|
|
|
|
2007-02-27 13:51:05 +08:00
|
|
|
// X86-32 C return-value convention.
|
2007-02-27 02:17:14 +08:00
|
|
|
def RetCC_X86_32_C : CallingConv<[
|
2008-09-26 04:47:45 +08:00
|
|
|
// The X86-32 calling convention returns FP values in ST0, unless marked
|
|
|
|
// with "inreg" (used here to distinguish one kind of reg from another,
|
|
|
|
// weirdly; this is really the sse-regparm calling convention) in which
|
|
|
|
// case they use XMM0, otherwise it is the same as the common X86 calling
|
|
|
|
// conv.
|
|
|
|
CCIfInReg<CCIfSubtarget<"hasSSE2()",
|
|
|
|
CCIfType<[f32, f64], CCAssignToReg<[XMM0,XMM1,XMM2]>>>>,
|
|
|
|
CCIfType<[f32,f64], CCAssignToReg<[ST0, ST1]>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2007-02-27 13:51:05 +08:00
|
|
|
// X86-32 FastCC return-value convention.
|
2007-02-27 02:17:14 +08:00
|
|
|
def RetCC_X86_32_Fast : CallingConv<[
|
2007-11-28 03:28:48 +08:00
|
|
|
// The X86-32 fastcc returns 1, 2, or 3 FP values in XMM0-2 if the target has
|
|
|
|
// SSE2, otherwise it is the the C calling conventions.
|
|
|
|
// This can happen when a float, 2 x float, or 3 x float vector is split by
|
|
|
|
// target lowering, and is returned in 1-3 sse regs.
|
|
|
|
CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0,XMM1,XMM2]>>>,
|
|
|
|
CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0,XMM1,XMM2]>>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2007-02-27 13:51:05 +08:00
|
|
|
// X86-64 C return-value convention.
|
2007-02-27 02:17:14 +08:00
|
|
|
def RetCC_X86_64_C : CallingConv<[
|
|
|
|
// The X86-64 calling convention always returns FP values in XMM0.
|
2008-04-10 01:54:37 +08:00
|
|
|
CCIfType<[f32], CCAssignToReg<[XMM0, XMM1]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[XMM0, XMM1]>>,
|
2008-06-25 06:01:44 +08:00
|
|
|
|
|
|
|
// MMX vector types are always returned in XMM0.
|
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32], CCAssignToReg<[XMM0, XMM1]>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2008-03-23 04:37:30 +08:00
|
|
|
// X86-Win64 C return-value convention.
|
|
|
|
def RetCC_X86_Win64_C : CallingConv<[
|
2008-03-24 04:32:06 +08:00
|
|
|
// The X86-Win64 calling convention always returns __m64 values in RAX.
|
2008-03-23 04:37:30 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToReg<[RAX]>>,
|
|
|
|
|
2008-04-28 15:40:07 +08:00
|
|
|
// And FP in XMM0 only.
|
|
|
|
CCIfType<[f32], CCAssignToReg<[XMM0]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[XMM0]>>,
|
|
|
|
|
2008-03-24 04:32:06 +08:00
|
|
|
// Otherwise, everything is the same as 'normal' X86-64 C CC.
|
2008-03-23 04:37:30 +08:00
|
|
|
CCDelegateTo<RetCC_X86_64_C>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
|
2007-02-27 13:51:05 +08:00
|
|
|
// This is the root return-value convention for the X86-32 backend.
|
|
|
|
def RetCC_X86_32 : CallingConv<[
|
|
|
|
// If FastCC, use RetCC_X86_32_Fast.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfCC<"CallingConv::Fast", CCDelegateTo<RetCC_X86_32_Fast>>,
|
2007-02-27 13:51:05 +08:00
|
|
|
// Otherwise, use RetCC_X86_32_C.
|
|
|
|
CCDelegateTo<RetCC_X86_32_C>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// This is the root return-value convention for the X86-64 backend.
|
|
|
|
def RetCC_X86_64 : CallingConv<[
|
2008-03-23 04:37:30 +08:00
|
|
|
// Mingw64 and native Win64 use Win64 CC
|
2008-03-23 04:57:27 +08:00
|
|
|
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<RetCC_X86_Win64_C>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
|
|
|
// Otherwise, drop to normal X86-64 CC
|
2007-02-27 13:51:05 +08:00
|
|
|
CCDelegateTo<RetCC_X86_64_C>
|
|
|
|
]>;
|
|
|
|
|
2007-02-27 14:59:52 +08:00
|
|
|
// This is the return-value convention used for the entire X86 backend.
|
|
|
|
def RetCC_X86 : CallingConv<[
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfSubtarget<"is64Bit()", CCDelegateTo<RetCC_X86_64>>,
|
2007-02-27 14:59:52 +08:00
|
|
|
CCDelegateTo<RetCC_X86_32>
|
|
|
|
]>;
|
2007-02-27 13:51:05 +08:00
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-02-28 13:30:29 +08:00
|
|
|
// X86-64 Argument Calling Conventions
|
2007-02-27 02:17:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_X86_64_C : CallingConv<[
|
2008-01-15 11:15:41 +08:00
|
|
|
// Handles byval parameters.
|
2008-01-15 11:34:58 +08:00
|
|
|
CCIfByVal<CCPassByVal<8, 8>>,
|
2008-01-15 11:15:41 +08:00
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
// Promote i8/i16 arguments to i32.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
2008-01-20 00:42:10 +08:00
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in R10.
|
|
|
|
CCIfNest<CCAssignToReg<[R10]>>,
|
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
// The first 6 integer arguments are passed in integer registers.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D, R9D]>>,
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8 , R9 ]>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
|
|
|
|
// The first 8 FP/Vector arguments are passed in XMM registers.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>,
|
|
|
|
|
|
|
|
// The first 8 MMX (except for v1i64) vector arguments are passed in XMM
|
|
|
|
// registers on Darwin.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v2f32],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCIfSubtarget<"isTargetDarwin()",
|
|
|
|
CCIfSubtarget<"hasSSE2()",
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>>,
|
|
|
|
|
|
|
|
// The first 8 v1i64 vector arguments are passed in GPRs on Darwin.
|
|
|
|
CCIfType<[v1i64],
|
|
|
|
CCIfSubtarget<"isTargetDarwin()",
|
|
|
|
CCAssignToReg<[RDI, RSI, RDX, RCX, R8]>>>,
|
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
// Integer/FP values get stored in stack slots that are 8 bytes in size and
|
|
|
|
// 8-byte aligned if there are no more registers to hold them.
|
2007-02-28 13:30:29 +08:00
|
|
|
CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>,
|
2007-02-27 02:17:14 +08:00
|
|
|
|
2007-11-11 06:07:15 +08:00
|
|
|
// Long doubles get stack slots whose size and alignment depends on the
|
|
|
|
// subtarget.
|
2007-11-14 16:29:13 +08:00
|
|
|
CCIfType<[f80], CCAssignToStack<0, 0>>,
|
2007-11-11 06:07:15 +08:00
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
// Vectors get 16-byte stack slots that are 16-byte aligned.
|
2007-11-11 06:07:15 +08:00
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>,
|
2007-03-30 08:35:22 +08:00
|
|
|
|
|
|
|
// __m64 vectors get 8-byte stack slots that are 8-byte aligned.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32], CCAssignToStack<8, 8>>
|
2007-02-27 02:17:14 +08:00
|
|
|
]>;
|
|
|
|
|
2008-03-23 04:37:30 +08:00
|
|
|
// Calling convention used on Win64
|
|
|
|
def CC_X86_Win64_C : CallingConv<[
|
2008-03-24 04:32:06 +08:00
|
|
|
// FIXME: Handle byval stuff.
|
2008-04-02 13:23:57 +08:00
|
|
|
// FIXME: Handle varargs.
|
2008-03-23 04:37:30 +08:00
|
|
|
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
2008-04-02 13:23:57 +08:00
|
|
|
// The 'nest' parameter, if any, is passed in R10.
|
|
|
|
CCIfNest<CCAssignToReg<[R10]>>,
|
|
|
|
|
2008-03-23 04:37:30 +08:00
|
|
|
// The first 4 integer arguments are passed in integer registers.
|
2008-04-02 13:23:57 +08:00
|
|
|
CCIfType<[i32], CCAssignToRegWithShadow<[ECX , EDX , R8D , R9D ],
|
|
|
|
[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
CCIfType<[i64], CCAssignToRegWithShadow<[RCX , RDX , R8 , R9 ],
|
|
|
|
[XMM0, XMM1, XMM2, XMM3]>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
|
|
|
// The first 4 FP/Vector arguments are passed in XMM registers.
|
|
|
|
CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2008-04-02 13:23:57 +08:00
|
|
|
CCAssignToRegWithShadow<[XMM0, XMM1, XMM2, XMM3],
|
|
|
|
[RCX , RDX , R8 , R9 ]>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
|
|
|
// The first 4 MMX vector arguments are passed in GPRs.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32],
|
2008-04-02 13:23:57 +08:00
|
|
|
CCAssignToRegWithShadow<[RCX , RDX , R8 , R9 ],
|
|
|
|
[XMM0, XMM1, XMM2, XMM3]>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
|
|
|
// Integer/FP values get stored in stack slots that are 8 bytes in size and
|
|
|
|
// 16-byte aligned if there are no more registers to hold them.
|
|
|
|
CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 16>>,
|
|
|
|
|
2008-04-28 06:54:09 +08:00
|
|
|
// Long doubles get stack slots whose size and alignment depends on the
|
|
|
|
// subtarget.
|
|
|
|
CCIfType<[f80], CCAssignToStack<0, 0>>,
|
|
|
|
|
2008-03-23 04:37:30 +08:00
|
|
|
// Vectors get 16-byte stack slots that are 16-byte aligned.
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>,
|
|
|
|
|
|
|
|
// __m64 vectors get 8-byte stack slots that are 16-byte aligned.
|
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 16>>
|
|
|
|
]>;
|
|
|
|
|
2007-10-13 05:30:57 +08:00
|
|
|
// Tail call convention (fast): One register is reserved for target address,
|
2007-10-12 03:40:01 +08:00
|
|
|
// namely R9
|
|
|
|
def CC_X86_64_TailCall : CallingConv<[
|
2008-01-15 11:15:41 +08:00
|
|
|
// Handles byval parameters.
|
2008-01-15 11:34:58 +08:00
|
|
|
CCIfByVal<CCPassByVal<8, 8>>,
|
2008-01-15 11:15:41 +08:00
|
|
|
|
2007-10-12 03:40:01 +08:00
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
2008-01-20 00:42:10 +08:00
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in R10.
|
|
|
|
CCIfNest<CCAssignToReg<[R10]>>,
|
|
|
|
|
2007-10-12 03:40:01 +08:00
|
|
|
// The first 6 integer arguments are passed in integer registers.
|
|
|
|
CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D]>>,
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8]>>,
|
|
|
|
|
|
|
|
// The first 8 FP/Vector arguments are passed in XMM registers.
|
|
|
|
CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>,
|
|
|
|
|
|
|
|
// The first 8 MMX (except for v1i64) vector arguments are passed in XMM
|
|
|
|
// registers on Darwin.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v2f32],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCIfSubtarget<"isTargetDarwin()",
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>,
|
|
|
|
|
|
|
|
// The first 8 v1i64 vector arguments are passed in GPRs on Darwin.
|
|
|
|
CCIfType<[v1i64],
|
|
|
|
CCIfSubtarget<"isTargetDarwin()",
|
|
|
|
CCAssignToReg<[RDI, RSI, RDX, RCX, R8]>>>,
|
|
|
|
|
2007-10-12 03:40:01 +08:00
|
|
|
// Integer/FP values get stored in stack slots that are 8 bytes in size and
|
|
|
|
// 8-byte aligned if there are no more registers to hold them.
|
|
|
|
CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>,
|
|
|
|
|
|
|
|
// Vectors get 16-byte stack slots that are 16-byte aligned.
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>,
|
|
|
|
|
|
|
|
// __m64 vectors get 8-byte stack slots that are 8-byte aligned.
|
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 8>>
|
|
|
|
]>;
|
|
|
|
|
2007-02-27 02:17:14 +08:00
|
|
|
|
2007-02-28 13:31:48 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// X86 C Calling Convention
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
/// CC_X86_32_Common - In all X86-32 calling conventions, extra integers and FP
|
|
|
|
/// values are spilled on the stack, and the first 4 vector values go in XMM
|
|
|
|
/// regs.
|
|
|
|
def CC_X86_32_Common : CallingConv<[
|
2008-01-15 11:15:41 +08:00
|
|
|
// Handles byval parameters.
|
2008-01-15 11:34:58 +08:00
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
2008-01-15 11:15:41 +08:00
|
|
|
|
2008-02-06 04:46:33 +08:00
|
|
|
// 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.
|
2008-04-25 15:56:45 +08:00
|
|
|
CCIfNotVarArg<CCIfInReg<CCIfType<[f32,f64],
|
|
|
|
CCIfSubtarget<"hasSSE2()",
|
2008-02-06 04:46:33 +08:00
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2]>>>>>,
|
|
|
|
|
2008-04-25 15:56:45 +08:00
|
|
|
// The first 3 __m64 (except for v1i64) vector arguments are passed in mmx
|
|
|
|
// registers if the call is not a vararg call.
|
2008-06-25 06:01:44 +08:00
|
|
|
CCIfNotVarArg<CCIfType<[v8i8, v4i16, v2i32, v2f32],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCAssignToReg<[MM0, MM1, MM2]>>>,
|
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
// Integer/Float values get stored in stack slots that are 4 bytes in
|
2007-02-28 13:31:48 +08:00
|
|
|
// size and 4-byte aligned.
|
|
|
|
CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
|
|
|
|
|
|
|
|
// Doubles get 8-byte slots that are 4-byte aligned.
|
|
|
|
CCIfType<[f64], CCAssignToStack<8, 4>>,
|
2007-08-07 05:31:06 +08:00
|
|
|
|
2008-01-08 00:36:38 +08:00
|
|
|
// Long doubles get slots whose size depends on the subtarget.
|
|
|
|
CCIfType<[f80], CCAssignToStack<0, 4>>,
|
2007-08-07 05:31:06 +08:00
|
|
|
|
2008-02-23 01:47:28 +08:00
|
|
|
// The first 4 SSE vector arguments are passed in XMM registers.
|
2008-01-23 07:26:53 +08:00
|
|
|
CCIfNotVarArg<CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>>,
|
2007-02-28 13:31:48 +08:00
|
|
|
|
2008-02-23 01:47:28 +08:00
|
|
|
// Other SSE vectors get 16-byte stack slots that are 16-byte aligned.
|
2007-03-30 08:35:22 +08:00
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>,
|
|
|
|
|
2008-02-23 01:47:28 +08:00
|
|
|
// __m64 vectors get 8-byte stack slots that are 4-byte aligned. They are
|
2007-03-30 08:35:22 +08:00
|
|
|
// passed in the parameter area.
|
2008-04-25 15:56:45 +08:00
|
|
|
CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 4>>]>;
|
2007-02-28 13:31:48 +08:00
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
def CC_X86_32_C : CallingConv<[
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
2007-07-28 04:02:49 +08:00
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in ECX.
|
|
|
|
CCIfNest<CCAssignToReg<[ECX]>>,
|
|
|
|
|
2007-06-19 08:13:10 +08:00
|
|
|
// The first 3 integer arguments, if marked 'inreg' and if the call is not
|
|
|
|
// a vararg call, are passed in integer registers.
|
|
|
|
CCIfNotVarArg<CCIfInReg<CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX]>>>>,
|
2007-07-28 04:02:49 +08:00
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
// Otherwise, same as everything else.
|
|
|
|
CCDelegateTo<CC_X86_32_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def CC_X86_32_FastCall : CallingConv<[
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
2007-07-28 04:02:49 +08:00
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in EAX.
|
|
|
|
CCIfNest<CCAssignToReg<[EAX]>>,
|
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
// The first 2 integer arguments are passed in ECX/EDX
|
2007-03-01 02:35:11 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[ECX, EDX]>>,
|
2007-07-28 04:02:49 +08:00
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
// Otherwise, same as everything else.
|
|
|
|
CCDelegateTo<CC_X86_32_Common>
|
|
|
|
]>;
|
2008-09-05 06:59:58 +08:00
|
|
|
|
|
|
|
def CC_X86_32_FastCC : CallingConv<[
|
2008-12-03 09:28:04 +08:00
|
|
|
// Handles byval parameters. Note that we can't rely on the delegation
|
|
|
|
// to CC_X86_32_Common for this because that happens after code that
|
2008-12-03 09:39:44 +08:00
|
|
|
// puts arguments in registers.
|
2008-12-03 09:28:04 +08:00
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
|
|
|
|
2008-09-05 06:59:58 +08:00
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in EAX.
|
|
|
|
CCIfNest<CCAssignToReg<[EAX]>>,
|
|
|
|
|
|
|
|
// The first 2 integer arguments are passed in ECX/EDX
|
|
|
|
CCIfType<[i32], CCAssignToReg<[ECX, EDX]>>,
|
|
|
|
|
2008-09-06 01:24:07 +08:00
|
|
|
// The first 3 float or double arguments, if the call is not a vararg
|
|
|
|
// call and if SSE2 is available, are passed in SSE registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[f32,f64],
|
|
|
|
CCIfSubtarget<"hasSSE2()",
|
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2]>>>>,
|
|
|
|
|
2008-09-05 06:59:58 +08:00
|
|
|
// Doubles get 8-byte slots that are 8-byte aligned.
|
|
|
|
CCIfType<[f64], CCAssignToStack<8, 8>>,
|
|
|
|
|
|
|
|
// Otherwise, same as everything else.
|
|
|
|
CCDelegateTo<CC_X86_32_Common>
|
|
|
|
]>;
|