2012-02-18 20:03:15 +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.
|
2012-02-18 20:03:15 +08:00
|
|
|
//
|
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>
|
2014-08-07 02:45:26 +08:00
|
|
|
: CCIf<!strconcat("static_cast<const X86Subtarget&>"
|
|
|
|
"(State.getMachineFunction().getSubtarget()).", F),
|
|
|
|
A>;
|
2007-02-28 12:51:41 +08:00
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
// Register classes for RegCall
|
|
|
|
class RC_X86_RegCall {
|
|
|
|
list<Register> GPR_8 = [];
|
|
|
|
list<Register> GPR_16 = [];
|
|
|
|
list<Register> GPR_32 = [];
|
|
|
|
list<Register> GPR_64 = [];
|
2016-11-20 19:06:07 +08:00
|
|
|
list<Register> FP_CALL = [FP0];
|
|
|
|
list<Register> FP_RET = [FP0, FP1];
|
2016-10-13 15:53:43 +08:00
|
|
|
list<Register> XMM = [];
|
|
|
|
list<Register> YMM = [];
|
|
|
|
list<Register> ZMM = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegCall register classes for 32 bits
|
|
|
|
def RC_X86_32_RegCall : RC_X86_RegCall {
|
|
|
|
let GPR_8 = [AL, CL, DL, DIL, SIL];
|
|
|
|
let GPR_16 = [AX, CX, DX, DI, SI];
|
|
|
|
let GPR_32 = [EAX, ECX, EDX, EDI, ESI];
|
|
|
|
let GPR_64 = [RAX]; ///< Not actually used, but AssignToReg can't handle []
|
|
|
|
///< \todo Fix AssignToReg to enable empty lists
|
|
|
|
let XMM = [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7];
|
|
|
|
let YMM = [YMM0, YMM1, YMM2, YMM3, YMM4, YMM5, YMM6, YMM7];
|
|
|
|
let ZMM = [ZMM0, ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6, ZMM7];
|
|
|
|
}
|
|
|
|
|
|
|
|
class RC_X86_64_RegCall : RC_X86_RegCall {
|
|
|
|
let XMM = [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
|
|
|
|
XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15];
|
|
|
|
let YMM = [YMM0, YMM1, YMM2, YMM3, YMM4, YMM5, YMM6, YMM7,
|
|
|
|
YMM8, YMM9, YMM10, YMM11, YMM12, YMM13, YMM14, YMM15];
|
|
|
|
let ZMM = [ZMM0, ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6, ZMM7,
|
|
|
|
ZMM8, ZMM9, ZMM10, ZMM11, ZMM12, ZMM13, ZMM14, ZMM15];
|
|
|
|
}
|
|
|
|
|
|
|
|
def RC_X86_64_RegCall_Win : RC_X86_64_RegCall {
|
|
|
|
let GPR_8 = [AL, CL, DL, DIL, SIL, R8B, R9B, R10B, R11B, R12B, R14B, R15B];
|
|
|
|
let GPR_16 = [AX, CX, DX, DI, SI, R8W, R9W, R10W, R11W, R12W, R14W, R15W];
|
|
|
|
let GPR_32 = [EAX, ECX, EDX, EDI, ESI, R8D, R9D, R10D, R11D, R12D, R14D, R15D];
|
|
|
|
let GPR_64 = [RAX, RCX, RDX, RDI, RSI, R8, R9, R10, R11, R12, R14, R15];
|
|
|
|
}
|
|
|
|
|
|
|
|
def RC_X86_64_RegCall_SysV : RC_X86_64_RegCall {
|
|
|
|
let GPR_8 = [AL, CL, DL, DIL, SIL, R8B, R9B, R12B, R13B, R14B, R15B];
|
|
|
|
let GPR_16 = [AX, CX, DX, DI, SI, R8W, R9W, R12W, R13W, R14W, R15W];
|
|
|
|
let GPR_32 = [EAX, ECX, EDX, EDI, ESI, R8D, R9D, R12D, R13D, R14D, R15D];
|
|
|
|
let GPR_64 = [RAX, RCX, RDX, RDI, RSI, R8, R9, R12, R13, R14, R15];
|
|
|
|
}
|
|
|
|
|
|
|
|
// X86-64 Intel regcall calling convention.
|
|
|
|
multiclass X86_RegCall_base<RC_X86_RegCall RC> {
|
|
|
|
def CC_#NAME : CallingConv<[
|
|
|
|
// Handles byval parameters.
|
|
|
|
CCIfSubtarget<"is64Bit()", CCIfByVal<CCPassByVal<8, 8>>>,
|
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
|
|
|
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
|
2016-12-11 22:10:52 +08:00
|
|
|
// Promote v8i1/v16i1/v32i1 arguments to i32.
|
|
|
|
CCIfType<[v8i1, v16i1, v32i1], CCPromoteToType<i32>>,
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
// bool, char, int, enum, long, pointer --> GPR
|
|
|
|
CCIfType<[i32], CCAssignToReg<RC.GPR_32>>,
|
|
|
|
|
|
|
|
// long long, __int64 --> GPR
|
|
|
|
CCIfType<[i64], CCAssignToReg<RC.GPR_64>>,
|
|
|
|
|
2016-11-17 17:59:40 +08:00
|
|
|
// __mmask64 (v64i1) --> GPR64 (for x64) or 2 x GPR32 (for IA32)
|
|
|
|
CCIfType<[v64i1], CCPromoteToType<i64>>,
|
|
|
|
CCIfSubtarget<"is64Bit()", CCIfType<[i64],
|
|
|
|
CCAssignToReg<RC.GPR_64>>>,
|
|
|
|
CCIfSubtarget<"is32Bit()", CCIfType<[i64],
|
|
|
|
CCCustom<"CC_X86_32_RegCall_Assign2Regs">>>,
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
// float, double, float128 --> XMM
|
|
|
|
// In the case of SSE disabled --> save to stack
|
|
|
|
CCIfType<[f32, f64, f128],
|
|
|
|
CCIfSubtarget<"hasSSE1()", CCAssignToReg<RC.XMM>>>,
|
|
|
|
|
2016-11-20 19:06:07 +08:00
|
|
|
// long double --> FP
|
|
|
|
CCIfType<[f80], CCAssignToReg<RC.FP_CALL>>,
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
// __m128, __m128i, __m128d --> XMM
|
|
|
|
// In the case of SSE disabled --> save to stack
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCIfSubtarget<"hasSSE1()", CCAssignToReg<RC.XMM>>>,
|
|
|
|
|
|
|
|
// __m256, __m256i, __m256d --> YMM
|
|
|
|
// In the case of SSE disabled --> save to stack
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
|
|
|
CCIfSubtarget<"hasAVX()", CCAssignToReg<RC.YMM>>>,
|
|
|
|
|
|
|
|
// __m512, __m512i, __m512d --> ZMM
|
|
|
|
// In the case of SSE disabled --> save to stack
|
|
|
|
CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCIfSubtarget<"hasAVX512()",CCAssignToReg<RC.ZMM>>>,
|
|
|
|
|
|
|
|
// If no register was found -> assign to stack
|
|
|
|
|
|
|
|
// In 64 bit, assign 64/32 bit values to 8 byte stack
|
|
|
|
CCIfSubtarget<"is64Bit()", CCIfType<[i32, i64, f32, f64],
|
|
|
|
CCAssignToStack<8, 8>>>,
|
|
|
|
|
|
|
|
// In 32 bit, assign 64/32 bit values to 8/4 byte stack
|
|
|
|
CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
|
2016-11-17 17:59:40 +08:00
|
|
|
CCIfType<[i64, f64], CCAssignToStack<8, 4>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
// MMX type gets 8 byte slot in stack , while alignment depends on target
|
|
|
|
CCIfSubtarget<"is64Bit()", CCIfType<[x86mmx], CCAssignToStack<8, 8>>>,
|
|
|
|
CCIfType<[x86mmx], CCAssignToStack<8, 4>>,
|
|
|
|
|
|
|
|
// float 128 get stack slots whose size and alignment depends
|
|
|
|
// on the subtarget.
|
2016-11-20 19:06:07 +08:00
|
|
|
CCIfType<[f80, f128], CCAssignToStack<0, 0>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
// Vectors get 16-byte stack slots that are 16-byte aligned.
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToStack<16, 16>>,
|
|
|
|
|
|
|
|
// 256-bit vectors get 32-byte stack slots that are 32-byte aligned.
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
|
|
|
CCAssignToStack<32, 32>>,
|
|
|
|
|
|
|
|
// 512-bit vectors get 64-byte stack slots that are 64-byte aligned.
|
|
|
|
CCIfType<[v16i32, v8i64, v16f32, v8f64], CCAssignToStack<64, 64>>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_#NAME : CallingConv<[
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1, v1i1, v8i1 arguments to i8.
|
|
|
|
CCIfType<[i1, v1i1, v8i1], CCPromoteToType<i8>>,
|
2016-12-11 22:10:52 +08:00
|
|
|
|
|
|
|
// Promote v16i1 arguments to i16.
|
|
|
|
CCIfType<[v16i1], CCPromoteToType<i16>>,
|
|
|
|
|
|
|
|
// Promote v32i1 arguments to i32.
|
|
|
|
CCIfType<[v32i1], CCPromoteToType<i32>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
// bool, char, int, enum, long, pointer --> GPR
|
|
|
|
CCIfType<[i8], CCAssignToReg<RC.GPR_8>>,
|
|
|
|
CCIfType<[i16], CCAssignToReg<RC.GPR_16>>,
|
|
|
|
CCIfType<[i32], CCAssignToReg<RC.GPR_32>>,
|
|
|
|
|
|
|
|
// long long, __int64 --> GPR
|
|
|
|
CCIfType<[i64], CCAssignToReg<RC.GPR_64>>,
|
|
|
|
|
2016-11-17 17:59:40 +08:00
|
|
|
// __mmask64 (v64i1) --> GPR64 (for x64) or 2 x GPR32 (for IA32)
|
|
|
|
CCIfType<[v64i1], CCPromoteToType<i64>>,
|
|
|
|
CCIfSubtarget<"is64Bit()", CCIfType<[i64],
|
|
|
|
CCAssignToReg<RC.GPR_64>>>,
|
|
|
|
CCIfSubtarget<"is32Bit()", CCIfType<[i64],
|
|
|
|
CCCustom<"CC_X86_32_RegCall_Assign2Regs">>>,
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
// long double --> FP
|
2016-11-20 19:06:07 +08:00
|
|
|
CCIfType<[f80], CCAssignToReg<RC.FP_RET>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
// float, double, float128 --> XMM
|
|
|
|
CCIfType<[f32, f64, f128],
|
|
|
|
CCIfSubtarget<"hasSSE1()", CCAssignToReg<RC.XMM>>>,
|
|
|
|
|
|
|
|
// __m128, __m128i, __m128d --> XMM
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCIfSubtarget<"hasSSE1()", CCAssignToReg<RC.XMM>>>,
|
|
|
|
|
|
|
|
// __m256, __m256i, __m256d --> YMM
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
|
|
|
CCIfSubtarget<"hasAVX()", CCAssignToReg<RC.YMM>>>,
|
|
|
|
|
|
|
|
// __m512, __m512i, __m512d --> ZMM
|
|
|
|
CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCIfSubtarget<"hasAVX512()", CCAssignToReg<RC.ZMM>>>
|
|
|
|
]>;
|
|
|
|
}
|
|
|
|
|
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<[
|
2009-03-24 09:04:34 +08:00
|
|
|
// Scalar values are returned in AX first, then DX. For i8, the ABI
|
|
|
|
// requires the values to be in AL and AH, however this code uses AL and DL
|
|
|
|
// instead. This is because using AH for the second register conflicts with
|
|
|
|
// the way LLVM does multiple return values -- a return of {i16,i8} would end
|
|
|
|
// up in AX and AH, which overlap. Front-ends wishing to conform to the ABI
|
|
|
|
// for functions that return two i8 values are currently expected to pack the
|
|
|
|
// values into an i16 (which uses AX, and thus AL:AH).
|
2012-05-31 01:50:14 +08:00
|
|
|
//
|
|
|
|
// For code that doesn't care about the ABI, we allow returning more than two
|
|
|
|
// integer values in registers.
|
2017-05-19 20:35:15 +08:00
|
|
|
CCIfType<[v1i1], CCPromoteToType<i8>>,
|
2015-05-14 17:04:45 +08:00
|
|
|
CCIfType<[i1], CCPromoteToType<i8>>,
|
2012-05-31 01:50:14 +08:00
|
|
|
CCIfType<[i8] , CCAssignToReg<[AL, DL, CL]>>,
|
|
|
|
CCIfType<[i16], CCAssignToReg<[AX, DX, CX]>>,
|
|
|
|
CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX]>>,
|
2012-05-31 02:08:02 +08:00
|
|
|
CCIfType<[i64], CCAssignToReg<[RAX, RDX, RCX]>>,
|
2010-08-06 07:35:51 +08:00
|
|
|
|
2015-04-27 23:11:19 +08:00
|
|
|
// Boolean vectors of AVX-512 are returned in SIMD registers.
|
|
|
|
// The call from AVX to AVX-512 function should work,
|
|
|
|
// since the boolean types in AVX/AVX2 are promoted by default.
|
|
|
|
CCIfType<[v2i1], CCPromoteToType<v2i64>>,
|
|
|
|
CCIfType<[v4i1], CCPromoteToType<v4i32>>,
|
|
|
|
CCIfType<[v8i1], CCPromoteToType<v8i16>>,
|
|
|
|
CCIfType<[v16i1], CCPromoteToType<v16i8>>,
|
|
|
|
CCIfType<[v32i1], CCPromoteToType<v32i8>>,
|
|
|
|
CCIfType<[v64i1], CCPromoteToType<v64i8>>,
|
|
|
|
|
2010-08-06 07:35:51 +08:00
|
|
|
// Vector types are returned in XMM0 and XMM1, when they fit. XMM2 and XMM3
|
2008-11-20 15:48:19 +08:00
|
|
|
// 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
|
|
|
|
2010-08-06 07:35:51 +08:00
|
|
|
// 256-bit vectors are returned in YMM0 and XMM1, when they fit. YMM2 and YMM3
|
|
|
|
// can only be used by ABI non-compliant code. This vector type is only
|
|
|
|
// supported while using the AVX target feature.
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
2011-07-02 05:33:28 +08:00
|
|
|
CCAssignToReg<[YMM0,YMM1,YMM2,YMM3]>>,
|
2010-08-06 07:35:51 +08:00
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
// 512-bit vectors are returned in ZMM0 and ZMM1, when they fit. ZMM2 and ZMM3
|
|
|
|
// can only be used by ABI non-compliant code. This vector type is only
|
|
|
|
// supported while using the AVX-512 target feature.
|
2014-07-21 22:54:21 +08:00
|
|
|
CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
2013-07-24 19:02:47 +08:00
|
|
|
CCAssignToReg<[ZMM0,ZMM1,ZMM2,ZMM3]>>,
|
|
|
|
|
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.
|
2011-07-02 05:33:28 +08:00
|
|
|
CCIfType<[x86mmx], CCAssignToReg<[MM0]>>,
|
2007-08-07 05:31:06 +08:00
|
|
|
|
2014-08-02 06:19:41 +08:00
|
|
|
// Long double types are always returned in FP0 (even with SSE).
|
|
|
|
CCIfType<[f80], CCAssignToReg<[FP0, FP1]>>
|
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<[
|
2014-08-02 06:19:41 +08:00
|
|
|
// The X86-32 calling convention returns FP values in FP0, unless marked
|
2008-09-26 04:47:45 +08:00
|
|
|
// 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.
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfInReg<CCIfSubtarget<"hasSSE2()",
|
2008-09-26 04:47:45 +08:00
|
|
|
CCIfType<[f32, f64], CCAssignToReg<[XMM0,XMM1,XMM2]>>>>,
|
2014-08-02 06:19:41 +08:00
|
|
|
CCIfType<[f32,f64], CCAssignToReg<[FP0, FP1]>>,
|
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
|
2009-12-15 11:27:52 +08:00
|
|
|
// SSE2.
|
2007-11-28 03:28:48 +08:00
|
|
|
// 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.
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfType<[f32], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0,XMM1,XMM2]>>>,
|
|
|
|
CCIfType<[f64], CCIfSubtarget<"hasSSE2()", CCAssignToReg<[XMM0,XMM1,XMM2]>>>,
|
2009-12-15 11:27:52 +08:00
|
|
|
|
|
|
|
// For integers, ECX can be used as an extra return register
|
|
|
|
CCIfType<[i8], CCAssignToReg<[AL, DL, CL]>>,
|
|
|
|
CCIfType<[i16], CCAssignToReg<[AX, DX, CX]>>,
|
|
|
|
CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX]>>,
|
|
|
|
|
|
|
|
// Otherwise, it is the same as the common X86 calling convention.
|
2007-02-27 02:17:14 +08:00
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2012-10-24 22:46:16 +08:00
|
|
|
// Intel_OCL_BI return-value convention.
|
|
|
|
def RetCC_Intel_OCL_BI : CallingConv<[
|
|
|
|
// Vector types are returned in XMM0,XMM1,XMMM2 and XMM3.
|
|
|
|
CCIfType<[f32, f64, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2,XMM3]>>,
|
|
|
|
|
|
|
|
// 256-bit FP vectors
|
|
|
|
// No more than 4 registers
|
|
|
|
CCIfType<[v8f32, v4f64, v8i32, v4i64],
|
|
|
|
CCAssignToReg<[YMM0,YMM1,YMM2,YMM3]>>,
|
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
// 512-bit FP vectors
|
|
|
|
CCIfType<[v16f32, v8f64, v16i32, v8i64],
|
|
|
|
CCAssignToReg<[ZMM0,ZMM1,ZMM2,ZMM3]>>,
|
|
|
|
|
2012-10-24 22:46:16 +08:00
|
|
|
// i32, i64 in the standard way
|
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2012-11-16 20:36:39 +08:00
|
|
|
// X86-32 HiPE return-value convention.
|
|
|
|
def RetCC_X86_32_HiPE : CallingConv<[
|
|
|
|
// Promote all types to i32
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// Return: HP, P, VAL1, VAL2
|
|
|
|
CCIfType<[i32], CCAssignToReg<[ESI, EBP, EAX, EDX]>>
|
|
|
|
]>;
|
|
|
|
|
2016-12-21 16:31:45 +08:00
|
|
|
// X86-32 Vectorcall return-value convention.
|
2014-10-28 09:29:26 +08:00
|
|
|
def RetCC_X86_32_VectorCall : CallingConv<[
|
2016-12-21 16:31:45 +08:00
|
|
|
// Floating Point types are returned in XMM0,XMM1,XMMM2 and XMM3.
|
|
|
|
CCIfType<[f32, f64, f128],
|
2014-10-28 09:29:26 +08:00
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2,XMM3]>>,
|
|
|
|
|
|
|
|
// Return integers in the standard way.
|
|
|
|
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]>>,
|
2015-12-15 06:08:36 +08:00
|
|
|
CCIfType<[f128], CCAssignToReg<[XMM0, XMM1]>>,
|
2008-06-25 06:01:44 +08:00
|
|
|
|
2011-07-02 05:33:28 +08:00
|
|
|
// MMX vector types are always returned in XMM0.
|
2010-10-01 07:57:10 +08:00
|
|
|
CCIfType<[x86mmx], CCAssignToReg<[XMM0, XMM1]>>,
|
2016-04-12 05:08:06 +08:00
|
|
|
|
|
|
|
CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,
|
|
|
|
|
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.
|
2011-07-02 05:33:28 +08:00
|
|
|
CCIfType<[x86mmx], CCBitConvertToType<i64>>,
|
2008-04-28 15:40:07 +08:00
|
|
|
|
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>
|
|
|
|
]>;
|
|
|
|
|
2016-12-21 16:31:45 +08:00
|
|
|
// X86-64 vectorcall return-value convention.
|
|
|
|
def RetCC_X86_64_Vectorcall : CallingConv<[
|
|
|
|
// Vectorcall calling convention always returns FP values in XMMs.
|
|
|
|
CCIfType<[f32, f64, f128],
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
|
|
|
|
// Otherwise, everything is the same as Windows X86-64 C CC.
|
|
|
|
CCDelegateTo<RetCC_X86_Win64_C>
|
|
|
|
]>;
|
|
|
|
|
2012-11-16 20:36:39 +08:00
|
|
|
// X86-64 HiPE return-value convention.
|
|
|
|
def RetCC_X86_64_HiPE : CallingConv<[
|
|
|
|
// Promote all types to i64
|
|
|
|
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
|
|
|
|
|
|
|
|
// Return: HP, P, VAL1, VAL2
|
|
|
|
CCIfType<[i64], CCAssignToReg<[R15, RBP, RAX, RDX]>>
|
|
|
|
]>;
|
2008-03-23 04:37:30 +08:00
|
|
|
|
2013-11-01 06:12:01 +08:00
|
|
|
// X86-64 WebKit_JS return-value convention.
|
|
|
|
def RetCC_X86_64_WebKit_JS : CallingConv<[
|
|
|
|
// Promote all types to i64
|
|
|
|
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
|
|
|
|
|
|
|
|
// Return: RAX
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RAX]>>
|
|
|
|
]>;
|
|
|
|
|
2016-04-06 06:41:47 +08:00
|
|
|
def RetCC_X86_64_Swift : CallingConv<[
|
2016-09-10 22:16:55 +08:00
|
|
|
|
|
|
|
CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,
|
|
|
|
|
2016-04-06 06:41:47 +08:00
|
|
|
// For integers, ECX, R8D can be used as extra return registers.
|
2017-05-19 20:35:15 +08:00
|
|
|
CCIfType<[v1i1], CCPromoteToType<i8>>,
|
2016-04-06 06:41:47 +08:00
|
|
|
CCIfType<[i1], CCPromoteToType<i8>>,
|
|
|
|
CCIfType<[i8] , CCAssignToReg<[AL, DL, CL, R8B]>>,
|
|
|
|
CCIfType<[i16], CCAssignToReg<[AX, DX, CX, R8W]>>,
|
|
|
|
CCIfType<[i32], CCAssignToReg<[EAX, EDX, ECX, R8D]>>,
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RAX, RDX, RCX, R8]>>,
|
|
|
|
|
|
|
|
// XMM0, XMM1, XMM2 and XMM3 can be used to return FP values.
|
|
|
|
CCIfType<[f32], CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
CCIfType<[f128], CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
|
|
|
|
// MMX vector types are returned in XMM0, XMM1, XMM2 and XMM3.
|
|
|
|
CCIfType<[x86mmx], CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
CCDelegateTo<RetCC_X86Common>
|
|
|
|
]>;
|
|
|
|
|
2013-11-09 07:28:16 +08:00
|
|
|
// X86-64 AnyReg return-value convention. No explicit register is specified for
|
|
|
|
// the return-value. The register allocator is allowed and expected to choose
|
|
|
|
// any free register.
|
|
|
|
//
|
|
|
|
// This calling convention is currently only supported by the stackmap and
|
|
|
|
// patchpoint intrinsics. All other uses will result in an assert on Debug
|
|
|
|
// builds. On Release builds we fallback to the X86 C calling convention.
|
|
|
|
def RetCC_X86_64_AnyReg : CallingConv<[
|
|
|
|
CCCustom<"CC_X86_AnyReg_Error">
|
|
|
|
]>;
|
|
|
|
|
HHVM calling conventions.
HHVM calling convention, hhvmcc, is used by HHVM JIT for
functions in translated cache. We currently support LLVM back end to
generate code for X86-64 and may support other architectures in the
future.
In HHVM calling convention any GP register could be used to pass and
return values, with the exception of R12 which is reserved for
thread-local area and is callee-saved. Other than R12, we always
pass RBX and RBP as args, which are our virtual machine's stack pointer
and frame pointer respectively.
When we enter translation cache via hhvmcc function, we expect
the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed
to standard ABI alignment. This affects stack object alignment and stack
adjustments for function calls.
One extra calling convention, hhvm_ccc, is used to call C++ helpers from
HHVM's translation cache. It is almost identical to standard C calling
convention with an exception of first argument which is passed in RBP
(before we use RDI, RSI, etc.)
Differential Revision: http://reviews.llvm.org/D12681
llvm-svn: 248832
2015-09-30 06:09:16 +08:00
|
|
|
// X86-64 HHVM return-value convention.
|
|
|
|
def RetCC_X86_64_HHVM: CallingConv<[
|
|
|
|
// Promote all types to i64
|
|
|
|
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
|
|
|
|
|
|
|
|
// Return: could return in any GP register save RSP and R12.
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RBX, RBP, RDI, RSI, RDX, RCX, R8, R9,
|
|
|
|
RAX, R10, R11, R13, R14, R15]>>
|
|
|
|
]>;
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
defm X86_32_RegCall :
|
|
|
|
X86_RegCall_base<RC_X86_32_RegCall>;
|
|
|
|
defm X86_Win64_RegCall :
|
|
|
|
X86_RegCall_base<RC_X86_64_RegCall_Win>;
|
|
|
|
defm X86_SysV64_RegCall :
|
|
|
|
X86_RegCall_base<RC_X86_64_RegCall_SysV>;
|
|
|
|
|
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>>,
|
2012-11-16 20:36:39 +08:00
|
|
|
// If HiPE, use RetCC_X86_32_HiPE.
|
|
|
|
CCIfCC<"CallingConv::HiPE", CCDelegateTo<RetCC_X86_32_HiPE>>,
|
2014-10-28 09:29:26 +08:00
|
|
|
CCIfCC<"CallingConv::X86_VectorCall", CCDelegateTo<RetCC_X86_32_VectorCall>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
CCIfCC<"CallingConv::X86_RegCall", CCDelegateTo<RetCC_X86_32_RegCall>>,
|
2012-11-16 20:36:39 +08:00
|
|
|
|
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<[
|
2012-11-16 20:36:39 +08:00
|
|
|
// HiPE uses RetCC_X86_64_HiPE
|
|
|
|
CCIfCC<"CallingConv::HiPE", CCDelegateTo<RetCC_X86_64_HiPE>>,
|
2013-07-12 14:02:35 +08:00
|
|
|
|
2013-11-01 06:12:01 +08:00
|
|
|
// Handle JavaScript calls.
|
|
|
|
CCIfCC<"CallingConv::WebKit_JS", CCDelegateTo<RetCC_X86_64_WebKit_JS>>,
|
2013-11-09 07:28:16 +08:00
|
|
|
CCIfCC<"CallingConv::AnyReg", CCDelegateTo<RetCC_X86_64_AnyReg>>,
|
2013-11-01 06:12:01 +08:00
|
|
|
|
2016-04-06 06:41:47 +08:00
|
|
|
// Handle Swift calls.
|
|
|
|
CCIfCC<"CallingConv::Swift", CCDelegateTo<RetCC_X86_64_Swift>>,
|
|
|
|
|
2013-07-12 14:02:35 +08:00
|
|
|
// Handle explicit CC selection
|
2017-07-18 04:05:19 +08:00
|
|
|
CCIfCC<"CallingConv::Win64", CCDelegateTo<RetCC_X86_Win64_C>>,
|
2013-07-12 14:02:35 +08:00
|
|
|
CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<RetCC_X86_64_C>>,
|
|
|
|
|
2016-12-21 16:31:45 +08:00
|
|
|
// Handle Vectorcall CC
|
|
|
|
CCIfCC<"CallingConv::X86_VectorCall", CCDelegateTo<RetCC_X86_64_Vectorcall>>,
|
|
|
|
|
HHVM calling conventions.
HHVM calling convention, hhvmcc, is used by HHVM JIT for
functions in translated cache. We currently support LLVM back end to
generate code for X86-64 and may support other architectures in the
future.
In HHVM calling convention any GP register could be used to pass and
return values, with the exception of R12 which is reserved for
thread-local area and is callee-saved. Other than R12, we always
pass RBX and RBP as args, which are our virtual machine's stack pointer
and frame pointer respectively.
When we enter translation cache via hhvmcc function, we expect
the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed
to standard ABI alignment. This affects stack object alignment and stack
adjustments for function calls.
One extra calling convention, hhvm_ccc, is used to call C++ helpers from
HHVM's translation cache. It is almost identical to standard C calling
convention with an exception of first argument which is passed in RBP
(before we use RDI, RSI, etc.)
Differential Revision: http://reviews.llvm.org/D12681
llvm-svn: 248832
2015-09-30 06:09:16 +08:00
|
|
|
// Handle HHVM calls.
|
|
|
|
CCIfCC<"CallingConv::HHVM", CCDelegateTo<RetCC_X86_64_HHVM>>,
|
|
|
|
|
2016-10-13 15:53:43 +08:00
|
|
|
CCIfCC<"CallingConv::X86_RegCall",
|
|
|
|
CCIfSubtarget<"isTargetWin64()",
|
|
|
|
CCDelegateTo<RetCC_X86_Win64_RegCall>>>,
|
|
|
|
CCIfCC<"CallingConv::X86_RegCall", CCDelegateTo<RetCC_X86_SysV64_RegCall>>,
|
|
|
|
|
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<[
|
2012-10-24 22:46:16 +08:00
|
|
|
|
|
|
|
// Check if this is the Intel OpenCL built-ins calling convention
|
|
|
|
CCIfCC<"CallingConv::Intel_OCL_BI", CCDelegateTo<RetCC_Intel_OCL_BI>>,
|
|
|
|
|
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
|
|
|
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2008-01-20 00:42:10 +08:00
|
|
|
|
|
|
|
// The 'nest' parameter, if any, is passed in R10.
|
2014-09-22 21:11:35 +08:00
|
|
|
CCIfNest<CCIfSubtarget<"isTarget64BitILP32()", CCAssignToReg<[R10D]>>>,
|
2008-01-20 00:42:10 +08:00
|
|
|
CCIfNest<CCAssignToReg<[R10]>>,
|
|
|
|
|
2016-04-14 05:43:21 +08:00
|
|
|
// Pass SwiftSelf in a callee saved register.
|
|
|
|
CCIfSwiftSelf<CCIfType<[i64], CCAssignToReg<[R13]>>>,
|
2016-03-30 01:37:21 +08:00
|
|
|
|
2016-04-12 05:08:06 +08:00
|
|
|
// A SwiftError is passed in R12.
|
|
|
|
CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,
|
|
|
|
|
2017-11-29 01:15:09 +08:00
|
|
|
// For Swift Calling Convention, pass sret in %rax.
|
2016-04-27 02:08:06 +08:00
|
|
|
CCIfCC<"CallingConv::Swift",
|
|
|
|
CCIfSRet<CCIfType<[i64], CCAssignToReg<[RAX]>>>>,
|
|
|
|
|
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 ]>>,
|
2008-04-25 15:56:45 +08:00
|
|
|
|
2011-07-02 05:33:28 +08:00
|
|
|
// The first 8 MMX vector arguments are passed in XMM registers on Darwin.
|
2010-10-01 07:57:10 +08:00
|
|
|
CCIfType<[x86mmx],
|
2008-04-25 15:56:45 +08:00
|
|
|
CCIfSubtarget<"isTargetDarwin()",
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfSubtarget<"hasSSE2()",
|
2009-08-03 16:13:24 +08:00
|
|
|
CCPromoteToType<v2i64>>>>,
|
2008-04-25 15:56:45 +08:00
|
|
|
|
2015-05-04 20:40:50 +08:00
|
|
|
// Boolean vectors of AVX-512 are passed in SIMD registers.
|
2015-04-27 23:11:19 +08:00
|
|
|
// The call from AVX to AVX-512 function should work,
|
|
|
|
// since the boolean types in AVX/AVX2 are promoted by default.
|
|
|
|
CCIfType<[v2i1], CCPromoteToType<v2i64>>,
|
|
|
|
CCIfType<[v4i1], CCPromoteToType<v4i32>>,
|
|
|
|
CCIfType<[v8i1], CCPromoteToType<v8i16>>,
|
|
|
|
CCIfType<[v16i1], CCPromoteToType<v16i8>>,
|
|
|
|
CCIfType<[v32i1], CCPromoteToType<v32i8>>,
|
|
|
|
CCIfType<[v64i1], CCPromoteToType<v64i8>>,
|
|
|
|
|
2009-08-03 16:13:24 +08:00
|
|
|
// The first 8 FP/Vector arguments are passed in XMM registers.
|
2015-12-15 06:08:36 +08:00
|
|
|
CCIfType<[f32, f64, f128, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfSubtarget<"hasSSE1()",
|
2009-08-03 16:13:24 +08:00
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>,
|
2010-08-06 07:35:51 +08:00
|
|
|
|
2011-12-01 12:49:21 +08:00
|
|
|
// The first 8 256-bit vector arguments are passed in YMM registers, unless
|
|
|
|
// this is a vararg function.
|
|
|
|
// FIXME: This isn't precisely correct; the x86-64 ABI document says that
|
|
|
|
// fixed arguments to vararg functions are supposed to be passed in
|
|
|
|
// registers. Actually modeling that would be a lot of work, though.
|
|
|
|
CCIfNotVarArg<CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
2018-03-05 08:13:35 +08:00
|
|
|
CCIfSubtarget<"hasAVX()",
|
2011-12-01 12:49:21 +08:00
|
|
|
CCAssignToReg<[YMM0, YMM1, YMM2, YMM3,
|
|
|
|
YMM4, YMM5, YMM6, YMM7]>>>>,
|
2010-08-06 07:35:51 +08:00
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
// The first 8 512-bit vector arguments are passed in ZMM registers.
|
2014-07-21 22:54:21 +08:00
|
|
|
CCIfNotVarArg<CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
2013-07-24 19:02:47 +08:00
|
|
|
CCIfSubtarget<"hasAVX512()",
|
|
|
|
CCAssignToReg<[ZMM0, ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6, ZMM7]>>>>,
|
|
|
|
|
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>>,
|
2010-08-06 07:35:51 +08:00
|
|
|
|
2007-11-11 06:07:15 +08:00
|
|
|
// Long doubles get stack slots whose size and alignment depends on the
|
|
|
|
// subtarget.
|
2015-12-15 06:08:36 +08:00
|
|
|
CCIfType<[f80, f128], 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
|
|
|
|
2010-08-06 07:35:51 +08:00
|
|
|
// 256-bit vectors get 32-byte stack slots that are 32-byte aligned.
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
2013-07-24 19:02:47 +08:00
|
|
|
CCAssignToStack<32, 32>>,
|
|
|
|
|
|
|
|
// 512-bit vectors get 64-byte stack slots that are 64-byte aligned.
|
|
|
|
CCIfType<[v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCAssignToStack<64, 64>>
|
2007-02-27 02:17:14 +08:00
|
|
|
]>;
|
|
|
|
|
HHVM calling conventions.
HHVM calling convention, hhvmcc, is used by HHVM JIT for
functions in translated cache. We currently support LLVM back end to
generate code for X86-64 and may support other architectures in the
future.
In HHVM calling convention any GP register could be used to pass and
return values, with the exception of R12 which is reserved for
thread-local area and is callee-saved. Other than R12, we always
pass RBX and RBP as args, which are our virtual machine's stack pointer
and frame pointer respectively.
When we enter translation cache via hhvmcc function, we expect
the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed
to standard ABI alignment. This affects stack object alignment and stack
adjustments for function calls.
One extra calling convention, hhvm_ccc, is used to call C++ helpers from
HHVM's translation cache. It is almost identical to standard C calling
convention with an exception of first argument which is passed in RBP
(before we use RDI, RSI, etc.)
Differential Revision: http://reviews.llvm.org/D12681
llvm-svn: 248832
2015-09-30 06:09:16 +08:00
|
|
|
// Calling convention for X86-64 HHVM.
|
|
|
|
def CC_X86_64_HHVM : CallingConv<[
|
|
|
|
// Use all/any GP registers for args, except RSP.
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RBX, R12, RBP, R15,
|
|
|
|
RDI, RSI, RDX, RCX, R8, R9,
|
|
|
|
RAX, R10, R11, R13, R14]>>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// Calling convention for helper functions in HHVM.
|
|
|
|
def CC_X86_64_HHVM_C : CallingConv<[
|
|
|
|
// Pass the first argument in RBP.
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RBP]>>,
|
|
|
|
|
|
|
|
// Otherwise it's the same as the regular C calling convention.
|
|
|
|
CCDelegateTo<CC_X86_64_C>
|
|
|
|
]>;
|
|
|
|
|
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
|
|
|
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
2008-04-02 13:23:57 +08:00
|
|
|
// The 'nest' parameter, if any, is passed in R10.
|
|
|
|
CCIfNest<CCAssignToReg<[R10]>>,
|
|
|
|
|
2017-09-21 02:40:59 +08:00
|
|
|
// A SwiftError is passed in R12.
|
|
|
|
CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,
|
|
|
|
|
2009-08-03 16:13:56 +08:00
|
|
|
// 128 bit vectors are passed by pointer
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCPassIndirect<i64>>,
|
|
|
|
|
2012-02-01 18:46:14 +08:00
|
|
|
|
|
|
|
// 256 bit vectors are passed by pointer
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64], CCPassIndirect<i64>>,
|
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
// 512 bit vectors are passed by pointer
|
|
|
|
CCIfType<[v16i32, v16f32, v8f64, v8i64], CCPassIndirect<i64>>,
|
|
|
|
|
2009-08-03 16:13:56 +08:00
|
|
|
// The first 4 MMX vector arguments are passed in GPRs.
|
2011-07-02 05:33:28 +08:00
|
|
|
CCIfType<[x86mmx], CCBitConvertToType<i64>>,
|
2009-08-03 16:13:56 +08:00
|
|
|
|
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]>>,
|
2013-11-01 01:18:07 +08:00
|
|
|
|
2011-03-03 03:29:22 +08:00
|
|
|
// Do not pass the sret argument in RCX, the Win64 thiscall calling
|
2013-11-01 01:18:07 +08:00
|
|
|
// convention requires "this" to be passed in RCX.
|
|
|
|
CCIfCC<"CallingConv::X86_ThisCall",
|
2011-03-03 03:29:22 +08:00
|
|
|
CCIfSRet<CCIfType<[i64], CCAssignToRegWithShadow<[RDX , R8 , R9 ],
|
|
|
|
[XMM1, XMM2, XMM3]>>>>,
|
|
|
|
|
2008-04-02 13:23:57 +08:00
|
|
|
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
|
|
|
|
|
|
|
// Integer/FP values get stored in stack slots that are 8 bytes in size and
|
2009-08-03 16:12:53 +08:00
|
|
|
// 8-byte aligned if there are no more registers to hold them.
|
|
|
|
CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>,
|
2008-03-23 04:37:30 +08:00
|
|
|
|
2008-04-28 06:54:09 +08:00
|
|
|
// Long doubles get stack slots whose size and alignment depends on the
|
|
|
|
// subtarget.
|
2011-07-02 05:33:28 +08:00
|
|
|
CCIfType<[f80], CCAssignToStack<0, 0>>
|
2008-03-23 04:37:30 +08:00
|
|
|
]>;
|
|
|
|
|
2014-10-28 09:29:26 +08:00
|
|
|
def CC_X86_Win64_VectorCall : CallingConv<[
|
2016-12-21 16:31:45 +08:00
|
|
|
CCCustom<"CC_X86_64_VectorCall">,
|
2014-10-28 09:29:26 +08:00
|
|
|
|
|
|
|
// Delegate to fastcall to handle integer types.
|
|
|
|
CCDelegateTo<CC_X86_Win64_C>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
|
2010-03-11 08:22:57 +08:00
|
|
|
def CC_X86_64_GHC : CallingConv<[
|
|
|
|
// Promote i8/i16/i32 arguments to i64.
|
|
|
|
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
|
|
|
|
|
|
|
|
// Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, R5, R6, SpLim
|
|
|
|
CCIfType<[i64],
|
|
|
|
CCAssignToReg<[R13, RBP, R12, RBX, R14, RSI, RDI, R8, R9, R15]>>,
|
|
|
|
|
|
|
|
// Pass in STG registers: F1, F2, F3, F4, D1, D2
|
|
|
|
CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfSubtarget<"hasSSE1()",
|
2017-07-10 00:57:10 +08:00
|
|
|
CCAssignToReg<[XMM1, XMM2, XMM3, XMM4, XMM5, XMM6]>>>,
|
|
|
|
// AVX
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
|
|
|
CCIfSubtarget<"hasAVX()",
|
|
|
|
CCAssignToReg<[YMM1, YMM2, YMM3, YMM4, YMM5, YMM6]>>>,
|
|
|
|
// AVX-512
|
|
|
|
CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCIfSubtarget<"hasAVX512()",
|
|
|
|
CCAssignToReg<[ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6]>>>
|
2010-03-11 08:22:57 +08:00
|
|
|
]>;
|
|
|
|
|
2012-11-16 20:36:39 +08:00
|
|
|
def CC_X86_64_HiPE : CallingConv<[
|
|
|
|
// Promote i8/i16/i32 arguments to i64.
|
|
|
|
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
|
|
|
|
|
|
|
|
// Pass in VM's registers: HP, P, ARG0, ARG1, ARG2, ARG3
|
|
|
|
CCIfType<[i64], CCAssignToReg<[R15, RBP, RSI, RDX, RCX, R8]>>,
|
|
|
|
|
|
|
|
// 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>>
|
|
|
|
]>;
|
|
|
|
|
2013-11-01 06:12:01 +08:00
|
|
|
def CC_X86_64_WebKit_JS : CallingConv<[
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
2013-12-17 03:53:31 +08:00
|
|
|
// Only the first integer argument is passed in register.
|
2013-12-17 06:05:32 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[EAX]>>,
|
|
|
|
CCIfType<[i64], CCAssignToReg<[RAX]>>,
|
|
|
|
|
|
|
|
// The remaining integer arguments are passed on the stack. 32bit integer and
|
|
|
|
// floating-point arguments are aligned to 4 byte and stored in 4 byte slots.
|
|
|
|
// 64bit integer and floating-point arguments are aligned to 8 byte and stored
|
|
|
|
// in 8 byte stack slots.
|
|
|
|
CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
|
|
|
|
CCIfType<[i64, f64], CCAssignToStack<8, 8>>
|
2013-11-01 06:12:01 +08:00
|
|
|
]>;
|
|
|
|
|
2013-11-09 07:28:16 +08:00
|
|
|
// No explicit register is specified for the AnyReg calling convention. The
|
|
|
|
// register allocator may assign the arguments to any free register.
|
|
|
|
//
|
|
|
|
// This calling convention is currently only supported by the stackmap and
|
|
|
|
// patchpoint intrinsics. All other uses will result in an assert on Debug
|
|
|
|
// builds. On Release builds we fallback to the X86 C calling convention.
|
|
|
|
def CC_X86_64_AnyReg : CallingConv<[
|
|
|
|
CCCustom<"CC_X86_AnyReg_Error">
|
|
|
|
]>;
|
|
|
|
|
2007-02-28 13:31:48 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// X86 C Calling Convention
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
[X86] ABI change for x86-32: pass 3 vector arguments in-register instead of 4, except on Darwin.
This changes the ABI used on 32-bit x86 for passing vector arguments.
Historically, clang passes the first 4 vector arguments in-register, and additional vector arguments on the stack, regardless of platform. That is different from the behavior of gcc, icc, and msvc, all of which pass only the first 3 arguments in-register.
The 3-register convention is documented, unofficially, in Agner's calling convention guide, and, officially, in the recently released version 1.0 of the i386 psABI.
Darwin is kept as is because the OS X ABI Function Call Guide explicitly documents the current (4-register) behavior.
This fixes PR21510
Differential revision: http://reviews.llvm.org/D9644
llvm-svn: 237682
2015-05-19 19:06:56 +08:00
|
|
|
/// CC_X86_32_Vector_Common - In all X86-32 calling conventions, extra vector
|
|
|
|
/// values are spilled on the stack.
|
|
|
|
def CC_X86_32_Vector_Common : CallingConv<[
|
|
|
|
// Other SSE vectors get 16-byte stack slots that are 16-byte aligned.
|
|
|
|
CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>,
|
|
|
|
|
|
|
|
// 256-bit AVX vectors get 32-byte stack slots that are 32-byte aligned.
|
|
|
|
CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
|
|
|
CCAssignToStack<32, 32>>,
|
|
|
|
|
|
|
|
// 512-bit AVX 512-bit vectors get 64-byte stack slots that are 64-byte aligned.
|
|
|
|
CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCAssignToStack<64, 64>>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// CC_X86_32_Vector_Standard - The first 3 vector arguments are passed in
|
|
|
|
// vector registers
|
|
|
|
def CC_X86_32_Vector_Standard : CallingConv<[
|
|
|
|
// SSE vector arguments are passed in XMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2]>>>,
|
|
|
|
|
|
|
|
// AVX 256-bit vector arguments are passed in YMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
2018-03-05 08:13:35 +08:00
|
|
|
CCIfSubtarget<"hasAVX()",
|
[X86] ABI change for x86-32: pass 3 vector arguments in-register instead of 4, except on Darwin.
This changes the ABI used on 32-bit x86 for passing vector arguments.
Historically, clang passes the first 4 vector arguments in-register, and additional vector arguments on the stack, regardless of platform. That is different from the behavior of gcc, icc, and msvc, all of which pass only the first 3 arguments in-register.
The 3-register convention is documented, unofficially, in Agner's calling convention guide, and, officially, in the recently released version 1.0 of the i386 psABI.
Darwin is kept as is because the OS X ABI Function Call Guide explicitly documents the current (4-register) behavior.
This fixes PR21510
Differential revision: http://reviews.llvm.org/D9644
llvm-svn: 237682
2015-05-19 19:06:56 +08:00
|
|
|
CCAssignToReg<[YMM0, YMM1, YMM2]>>>>,
|
|
|
|
|
|
|
|
// AVX 512-bit vector arguments are passed in ZMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCAssignToReg<[ZMM0, ZMM1, ZMM2]>>>,
|
|
|
|
|
|
|
|
CCDelegateTo<CC_X86_32_Vector_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// CC_X86_32_Vector_Darwin - The first 4 vector arguments are passed in
|
|
|
|
// vector registers.
|
|
|
|
def CC_X86_32_Vector_Darwin : CallingConv<[
|
|
|
|
// SSE vector arguments are passed in XMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>>,
|
|
|
|
|
|
|
|
// AVX 256-bit vector arguments are passed in YMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v32i8, v16i16, v8i32, v4i64, v8f32, v4f64],
|
2018-03-05 08:13:35 +08:00
|
|
|
CCIfSubtarget<"hasAVX()",
|
[X86] ABI change for x86-32: pass 3 vector arguments in-register instead of 4, except on Darwin.
This changes the ABI used on 32-bit x86 for passing vector arguments.
Historically, clang passes the first 4 vector arguments in-register, and additional vector arguments on the stack, regardless of platform. That is different from the behavior of gcc, icc, and msvc, all of which pass only the first 3 arguments in-register.
The 3-register convention is documented, unofficially, in Agner's calling convention guide, and, officially, in the recently released version 1.0 of the i386 psABI.
Darwin is kept as is because the OS X ABI Function Call Guide explicitly documents the current (4-register) behavior.
This fixes PR21510
Differential revision: http://reviews.llvm.org/D9644
llvm-svn: 237682
2015-05-19 19:06:56 +08:00
|
|
|
CCAssignToReg<[YMM0, YMM1, YMM2, YMM3]>>>>,
|
|
|
|
|
|
|
|
// AVX 512-bit vector arguments are passed in ZMM registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[v64i8, v32i16, v16i32, v8i64, v16f32, v8f64],
|
|
|
|
CCAssignToReg<[ZMM0, ZMM1, ZMM2, ZMM3]>>>,
|
|
|
|
|
|
|
|
CCDelegateTo<CC_X86_32_Vector_Common>
|
|
|
|
]>;
|
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
/// CC_X86_32_Common - In all X86-32 calling conventions, extra integers and FP
|
[X86] ABI change for x86-32: pass 3 vector arguments in-register instead of 4, except on Darwin.
This changes the ABI used on 32-bit x86 for passing vector arguments.
Historically, clang passes the first 4 vector arguments in-register, and additional vector arguments on the stack, regardless of platform. That is different from the behavior of gcc, icc, and msvc, all of which pass only the first 3 arguments in-register.
The 3-register convention is documented, unofficially, in Agner's calling convention guide, and, officially, in the recently released version 1.0 of the i386 psABI.
Darwin is kept as is because the OS X ABI Function Call Guide explicitly documents the current (4-register) behavior.
This fixes PR21510
Differential revision: http://reviews.llvm.org/D9644
llvm-svn: 237682
2015-05-19 19:06:56 +08:00
|
|
|
/// values are spilled on the stack.
|
2007-02-28 14:20:01 +08:00
|
|
|
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],
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfSubtarget<"hasSSE2()",
|
2008-02-06 04:46:33 +08:00
|
|
|
CCAssignToReg<[XMM0,XMM1,XMM2]>>>>>,
|
|
|
|
|
2011-07-02 05:33:28 +08:00
|
|
|
// The first 3 __m64 vector arguments are passed in mmx registers if the
|
|
|
|
// call is not a vararg call.
|
2010-10-01 07:57:10 +08:00
|
|
|
CCIfNotVarArg<CCIfType<[x86mmx],
|
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>>,
|
2013-11-01 01:18:07 +08:00
|
|
|
|
2007-02-28 13:31:48 +08:00
|
|
|
// 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
|
|
|
|
2015-05-04 20:40:50 +08:00
|
|
|
// Boolean vectors of AVX-512 are passed in SIMD registers.
|
|
|
|
// The call from AVX to AVX-512 function should work,
|
|
|
|
// since the boolean types in AVX/AVX2 are promoted by default.
|
|
|
|
CCIfType<[v2i1], CCPromoteToType<v2i64>>,
|
|
|
|
CCIfType<[v4i1], CCPromoteToType<v4i32>>,
|
|
|
|
CCIfType<[v8i1], CCPromoteToType<v8i16>>,
|
|
|
|
CCIfType<[v16i1], CCPromoteToType<v16i8>>,
|
|
|
|
CCIfType<[v32i1], CCPromoteToType<v32i8>>,
|
|
|
|
CCIfType<[v64i1], CCPromoteToType<v64i8>>,
|
|
|
|
|
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.
|
[X86] ABI change for x86-32: pass 3 vector arguments in-register instead of 4, except on Darwin.
This changes the ABI used on 32-bit x86 for passing vector arguments.
Historically, clang passes the first 4 vector arguments in-register, and additional vector arguments on the stack, regardless of platform. That is different from the behavior of gcc, icc, and msvc, all of which pass only the first 3 arguments in-register.
The 3-register convention is documented, unofficially, in Agner's calling convention guide, and, officially, in the recently released version 1.0 of the i386 psABI.
Darwin is kept as is because the OS X ABI Function Call Guide explicitly documents the current (4-register) behavior.
This fixes PR21510
Differential revision: http://reviews.llvm.org/D9644
llvm-svn: 237682
2015-05-19 19:06:56 +08:00
|
|
|
CCIfType<[x86mmx], CCAssignToStack<8, 4>>,
|
|
|
|
|
|
|
|
// Darwin passes vectors in a form that differs from the i386 psABI
|
|
|
|
CCIfSubtarget<"isTargetDarwin()", CCDelegateTo<CC_X86_32_Vector_Darwin>>,
|
|
|
|
|
|
|
|
// Otherwise, drop to 'normal' X86-32 CC
|
|
|
|
CCDelegateTo<CC_X86_32_Vector_Standard>
|
|
|
|
]>;
|
2007-02-28 13:31:48 +08:00
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
def CC_X86_32_C : CallingConv<[
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], 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>
|
|
|
|
]>;
|
|
|
|
|
2015-12-28 22:39:21 +08:00
|
|
|
def CC_X86_32_MCU : CallingConv<[
|
|
|
|
// Handles byval parameters. Note that, like FastCC, we can't rely on
|
|
|
|
// the delegation to CC_X86_32_Common because that happens after code that
|
|
|
|
// puts arguments in registers.
|
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
|
|
|
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2015-12-28 22:39:21 +08:00
|
|
|
|
|
|
|
// If the call is not a vararg call, some arguments may be passed
|
|
|
|
// in integer registers.
|
|
|
|
CCIfNotVarArg<CCIfType<[i32], CCCustom<"CC_X86_32_MCUInReg">>>,
|
|
|
|
|
|
|
|
// Otherwise, same as everything else.
|
|
|
|
CCDelegateTo<CC_X86_32_Common>
|
|
|
|
]>;
|
|
|
|
|
2007-02-28 14:20:01 +08:00
|
|
|
def CC_X86_32_FastCall : CallingConv<[
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], 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
|
2012-10-24 09:58:48 +08:00
|
|
|
CCIfInReg<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
|
|
|
|
2016-12-21 16:31:45 +08:00
|
|
|
def CC_X86_Win32_VectorCall : CallingConv<[
|
|
|
|
// Pass floating point in XMMs
|
|
|
|
CCCustom<"CC_X86_32_VectorCall">,
|
2014-10-28 09:29:26 +08:00
|
|
|
|
|
|
|
// Delegate to fastcall to handle integer types.
|
|
|
|
CCDelegateTo<CC_X86_32_FastCall>
|
|
|
|
]>;
|
|
|
|
|
2013-12-04 04:51:23 +08:00
|
|
|
def CC_X86_32_ThisCall_Common : CallingConv<[
|
|
|
|
// The first integer argument is passed in ECX
|
|
|
|
CCIfType<[i32], CCAssignToReg<[ECX]>>,
|
|
|
|
|
|
|
|
// Otherwise, same as everything else.
|
|
|
|
CCDelegateTo<CC_X86_32_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def CC_X86_32_ThisCall_Mingw : CallingConv<[
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2013-12-04 04:51:23 +08:00
|
|
|
|
|
|
|
CCDelegateTo<CC_X86_32_ThisCall_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def CC_X86_32_ThisCall_Win : CallingConv<[
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2010-05-16 17:08:45 +08:00
|
|
|
|
2013-04-03 19:27:54 +08:00
|
|
|
// Pass sret arguments indirectly through stack.
|
|
|
|
CCIfSRet<CCAssignToStack<4, 4>>,
|
2010-05-16 17:08:45 +08:00
|
|
|
|
2013-12-04 04:51:23 +08:00
|
|
|
CCDelegateTo<CC_X86_32_ThisCall_Common>
|
|
|
|
]>;
|
2010-05-16 17:08:45 +08:00
|
|
|
|
2013-12-04 04:51:23 +08:00
|
|
|
def CC_X86_32_ThisCall : CallingConv<[
|
|
|
|
CCIfSubtarget<"isTargetCygMing()", CCDelegateTo<CC_X86_32_ThisCall_Mingw>>,
|
|
|
|
CCDelegateTo<CC_X86_32_ThisCall_Win>
|
2010-05-16 17:08:45 +08:00
|
|
|
]>;
|
|
|
|
|
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>>,
|
|
|
|
|
2017-05-19 20:35:15 +08:00
|
|
|
// Promote i1/i8/i16/v1i1 arguments to i32.
|
|
|
|
CCIfType<[i1, i8, i16, v1i1], CCPromoteToType<i32>>,
|
2008-09-05 06:59:58 +08:00
|
|
|
|
|
|
|
// 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],
|
2012-01-10 14:54:16 +08:00
|
|
|
CCIfSubtarget<"hasSSE2()",
|
2008-09-06 01:24:07 +08:00
|
|
|
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>
|
|
|
|
]>;
|
2010-03-11 08:22:57 +08:00
|
|
|
|
|
|
|
def CC_X86_32_GHC : CallingConv<[
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// Pass in STG registers: Base, Sp, Hp, R1
|
|
|
|
CCIfType<[i32], CCAssignToReg<[EBX, EBP, EDI, ESI]>>
|
|
|
|
]>;
|
2010-10-31 21:21:44 +08:00
|
|
|
|
2012-11-16 20:36:39 +08:00
|
|
|
def CC_X86_32_HiPE : CallingConv<[
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// Pass in VM's registers: HP, P, ARG0, ARG1, ARG2
|
|
|
|
CCIfType<[i32], CCAssignToReg<[ESI, EBP, EAX, EDX, ECX]>>,
|
|
|
|
|
|
|
|
// Integer/Float values get stored in stack slots that are 4 bytes in
|
|
|
|
// size and 4-byte aligned.
|
|
|
|
CCIfType<[i32, f32], CCAssignToStack<4, 4>>
|
|
|
|
]>;
|
|
|
|
|
2012-11-20 17:37:57 +08:00
|
|
|
// X86-64 Intel OpenCL built-ins calling convention.
|
|
|
|
def CC_Intel_OCL_BI : CallingConv<[
|
|
|
|
|
|
|
|
CCIfType<[i32], CCIfSubtarget<"isTargetWin64()", CCAssignToReg<[ECX, EDX, R8D, R9D]>>>,
|
|
|
|
CCIfType<[i64], CCIfSubtarget<"isTargetWin64()", CCAssignToReg<[RCX, RDX, R8, R9 ]>>>,
|
|
|
|
|
|
|
|
CCIfType<[i32], CCIfSubtarget<"is64Bit()", CCAssignToReg<[EDI, ESI, EDX, ECX]>>>,
|
|
|
|
CCIfType<[i64], CCIfSubtarget<"is64Bit()", CCAssignToReg<[RDI, RSI, RDX, RCX]>>>,
|
|
|
|
|
|
|
|
CCIfType<[i32], CCAssignToStack<4, 4>>,
|
|
|
|
|
|
|
|
// The SSE vector arguments are passed in XMM registers.
|
|
|
|
CCIfType<[f32, f64, v4i32, v2i64, v4f32, v2f64],
|
|
|
|
CCAssignToReg<[XMM0, XMM1, XMM2, XMM3]>>,
|
|
|
|
|
|
|
|
// The 256-bit vector arguments are passed in YMM registers.
|
|
|
|
CCIfType<[v8f32, v4f64, v8i32, v4i64],
|
|
|
|
CCAssignToReg<[YMM0, YMM1, YMM2, YMM3]>>,
|
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
// The 512-bit vector arguments are passed in ZMM registers.
|
|
|
|
CCIfType<[v16f32, v8f64, v16i32, v8i64],
|
|
|
|
CCAssignToReg<[ZMM0, ZMM1, ZMM2, ZMM3]>>,
|
|
|
|
|
2015-02-17 17:20:12 +08:00
|
|
|
// Pass masks in mask registers
|
|
|
|
CCIfType<[v16i1, v8i1], CCAssignToReg<[K1]>>,
|
|
|
|
|
2012-11-20 17:37:57 +08:00
|
|
|
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<CC_X86_Win64_C>>,
|
|
|
|
CCIfSubtarget<"is64Bit()", CCDelegateTo<CC_X86_64_C>>,
|
|
|
|
CCDelegateTo<CC_X86_32_C>
|
|
|
|
]>;
|
|
|
|
|
2015-12-21 22:07:14 +08:00
|
|
|
def CC_X86_32_Intr : CallingConv<[
|
|
|
|
CCAssignToStack<4, 4>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def CC_X86_64_Intr : CallingConv<[
|
|
|
|
CCAssignToStack<8, 8>
|
|
|
|
]>;
|
|
|
|
|
2010-10-31 21:21:44 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// X86 Root Argument Calling Conventions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// This is the root argument convention for the X86-32 backend.
|
|
|
|
def CC_X86_32 : CallingConv<[
|
2016-03-04 01:17:54 +08:00
|
|
|
// X86_INTR calling convention is valid in MCU target and should override the
|
|
|
|
// MCU calling convention. Thus, this should be checked before isTargetMCU().
|
|
|
|
CCIfCC<"CallingConv::X86_INTR", CCDelegateTo<CC_X86_32_Intr>>,
|
2015-12-28 22:39:21 +08:00
|
|
|
CCIfSubtarget<"isTargetMCU()", CCDelegateTo<CC_X86_32_MCU>>,
|
2010-10-31 21:21:44 +08:00
|
|
|
CCIfCC<"CallingConv::X86_FastCall", CCDelegateTo<CC_X86_32_FastCall>>,
|
2016-12-21 16:31:45 +08:00
|
|
|
CCIfCC<"CallingConv::X86_VectorCall", CCDelegateTo<CC_X86_Win32_VectorCall>>,
|
2010-10-31 21:21:44 +08:00
|
|
|
CCIfCC<"CallingConv::X86_ThisCall", CCDelegateTo<CC_X86_32_ThisCall>>,
|
|
|
|
CCIfCC<"CallingConv::Fast", CCDelegateTo<CC_X86_32_FastCC>>,
|
|
|
|
CCIfCC<"CallingConv::GHC", CCDelegateTo<CC_X86_32_GHC>>,
|
2012-11-16 20:36:39 +08:00
|
|
|
CCIfCC<"CallingConv::HiPE", CCDelegateTo<CC_X86_32_HiPE>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
CCIfCC<"CallingConv::X86_RegCall", CCDelegateTo<CC_X86_32_RegCall>>,
|
2010-10-31 21:21:44 +08:00
|
|
|
|
|
|
|
// Otherwise, drop to normal X86-32 CC
|
|
|
|
CCDelegateTo<CC_X86_32_C>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// This is the root argument convention for the X86-64 backend.
|
|
|
|
def CC_X86_64 : CallingConv<[
|
|
|
|
CCIfCC<"CallingConv::GHC", CCDelegateTo<CC_X86_64_GHC>>,
|
2012-11-16 20:36:39 +08:00
|
|
|
CCIfCC<"CallingConv::HiPE", CCDelegateTo<CC_X86_64_HiPE>>,
|
2013-11-01 06:12:01 +08:00
|
|
|
CCIfCC<"CallingConv::WebKit_JS", CCDelegateTo<CC_X86_64_WebKit_JS>>,
|
2013-11-09 07:28:16 +08:00
|
|
|
CCIfCC<"CallingConv::AnyReg", CCDelegateTo<CC_X86_64_AnyReg>>,
|
2017-07-18 04:05:19 +08:00
|
|
|
CCIfCC<"CallingConv::Win64", CCDelegateTo<CC_X86_Win64_C>>,
|
2013-07-12 14:02:35 +08:00
|
|
|
CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<CC_X86_64_C>>,
|
2014-10-28 09:29:26 +08:00
|
|
|
CCIfCC<"CallingConv::X86_VectorCall", CCDelegateTo<CC_X86_Win64_VectorCall>>,
|
HHVM calling conventions.
HHVM calling convention, hhvmcc, is used by HHVM JIT for
functions in translated cache. We currently support LLVM back end to
generate code for X86-64 and may support other architectures in the
future.
In HHVM calling convention any GP register could be used to pass and
return values, with the exception of R12 which is reserved for
thread-local area and is callee-saved. Other than R12, we always
pass RBX and RBP as args, which are our virtual machine's stack pointer
and frame pointer respectively.
When we enter translation cache via hhvmcc function, we expect
the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed
to standard ABI alignment. This affects stack object alignment and stack
adjustments for function calls.
One extra calling convention, hhvm_ccc, is used to call C++ helpers from
HHVM's translation cache. It is almost identical to standard C calling
convention with an exception of first argument which is passed in RBP
(before we use RDI, RSI, etc.)
Differential Revision: http://reviews.llvm.org/D12681
llvm-svn: 248832
2015-09-30 06:09:16 +08:00
|
|
|
CCIfCC<"CallingConv::HHVM", CCDelegateTo<CC_X86_64_HHVM>>,
|
|
|
|
CCIfCC<"CallingConv::HHVM_C", CCDelegateTo<CC_X86_64_HHVM_C>>,
|
2016-10-13 15:53:43 +08:00
|
|
|
CCIfCC<"CallingConv::X86_RegCall",
|
|
|
|
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<CC_X86_Win64_RegCall>>>,
|
|
|
|
CCIfCC<"CallingConv::X86_RegCall", CCDelegateTo<CC_X86_SysV64_RegCall>>,
|
2015-12-21 22:07:14 +08:00
|
|
|
CCIfCC<"CallingConv::X86_INTR", CCDelegateTo<CC_X86_64_Intr>>,
|
2010-10-31 21:21:44 +08:00
|
|
|
|
|
|
|
// Mingw64 and native Win64 use Win64 CC
|
|
|
|
CCIfSubtarget<"isTargetWin64()", CCDelegateTo<CC_X86_Win64_C>>,
|
|
|
|
|
|
|
|
// Otherwise, drop to normal X86-64 CC
|
|
|
|
CCDelegateTo<CC_X86_64_C>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// This is the argument convention used for the entire X86 backend.
|
|
|
|
def CC_X86 : CallingConv<[
|
2012-10-24 22:46:16 +08:00
|
|
|
CCIfCC<"CallingConv::Intel_OCL_BI", CCDelegateTo<CC_Intel_OCL_BI>>,
|
2010-10-31 21:21:44 +08:00
|
|
|
CCIfSubtarget<"is64Bit()", CCDelegateTo<CC_X86_64>>,
|
|
|
|
CCDelegateTo<CC_X86_32>
|
|
|
|
]>;
|
2012-01-18 06:47:01 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Callee-saved Registers.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-05-08 23:07:29 +08:00
|
|
|
def CSR_NoRegs : CalleeSavedRegs<(add)>;
|
2012-01-18 06:47:01 +08:00
|
|
|
|
|
|
|
def CSR_32 : CalleeSavedRegs<(add ESI, EDI, EBX, EBP)>;
|
|
|
|
def CSR_64 : CalleeSavedRegs<(add RBX, R12, R13, R14, R15, RBP)>;
|
|
|
|
|
2016-04-12 05:08:06 +08:00
|
|
|
def CSR_64_SwiftError : CalleeSavedRegs<(sub CSR_64, R12)>;
|
|
|
|
|
2012-01-18 06:47:01 +08:00
|
|
|
def CSR_32EHRet : CalleeSavedRegs<(add EAX, EDX, CSR_32)>;
|
|
|
|
def CSR_64EHRet : CalleeSavedRegs<(add RAX, RDX, CSR_64)>;
|
|
|
|
|
2016-09-30 08:17:49 +08:00
|
|
|
def CSR_Win64_NoSSE : CalleeSavedRegs<(add RBX, RBP, RDI, RSI, R12, R13, R14, R15)>;
|
|
|
|
|
|
|
|
def CSR_Win64 : CalleeSavedRegs<(add CSR_Win64_NoSSE,
|
2012-01-18 06:47:01 +08:00
|
|
|
(sequence "XMM%u", 6, 15))>;
|
2012-10-24 22:46:16 +08:00
|
|
|
|
2017-09-26 06:00:17 +08:00
|
|
|
def CSR_Win64_SwiftError : CalleeSavedRegs<(sub CSR_Win64, R12)>;
|
|
|
|
|
2015-11-12 08:54:04 +08:00
|
|
|
// The function used by Darwin to obtain the address of a thread-local variable
|
|
|
|
// uses rdi to pass a single parameter and rax for the return value. All other
|
|
|
|
// GPRs are preserved.
|
|
|
|
def CSR_64_TLS_Darwin : CalleeSavedRegs<(add CSR_64, RCX, RDX, RSI,
|
|
|
|
R8, R9, R10, R11)>;
|
|
|
|
|
2016-01-12 09:08:46 +08:00
|
|
|
// CSRs that are handled by prologue, epilogue.
|
2016-01-17 00:39:46 +08:00
|
|
|
def CSR_64_CXX_TLS_Darwin_PE : CalleeSavedRegs<(add RBP)>;
|
2016-01-12 09:08:46 +08:00
|
|
|
|
|
|
|
// CSRs that are handled explicitly via copies.
|
2016-01-17 00:39:46 +08:00
|
|
|
def CSR_64_CXX_TLS_Darwin_ViaCopy : CalleeSavedRegs<(sub CSR_64_TLS_Darwin, RBP)>;
|
2016-01-12 09:08:46 +08:00
|
|
|
|
2014-01-18 03:47:03 +08:00
|
|
|
// All GPRs - except r11
|
|
|
|
def CSR_64_RT_MostRegs : CalleeSavedRegs<(add CSR_64, RAX, RCX, RDX, RSI, RDI,
|
|
|
|
R8, R9, R10, RSP)>;
|
|
|
|
|
|
|
|
// All registers - except r11
|
|
|
|
def CSR_64_RT_AllRegs : CalleeSavedRegs<(add CSR_64_RT_MostRegs,
|
|
|
|
(sequence "XMM%u", 0, 15))>;
|
|
|
|
def CSR_64_RT_AllRegs_AVX : CalleeSavedRegs<(add CSR_64_RT_MostRegs,
|
|
|
|
(sequence "YMM%u", 0, 15))>;
|
|
|
|
|
2014-01-11 09:00:27 +08:00
|
|
|
def CSR_64_MostRegs : CalleeSavedRegs<(add RBX, RCX, RDX, RSI, RDI, R8, R9, R10,
|
2013-02-23 03:19:44 +08:00
|
|
|
R11, R12, R13, R14, R15, RBP,
|
|
|
|
(sequence "XMM%u", 0, 15))>;
|
2012-10-24 22:46:16 +08:00
|
|
|
|
2015-12-21 22:07:14 +08:00
|
|
|
def CSR_32_AllRegs : CalleeSavedRegs<(add EAX, EBX, ECX, EDX, EBP, ESI,
|
2016-05-13 03:58:32 +08:00
|
|
|
EDI)>;
|
2015-12-21 22:07:14 +08:00
|
|
|
def CSR_32_AllRegs_SSE : CalleeSavedRegs<(add CSR_32_AllRegs,
|
|
|
|
(sequence "XMM%u", 0, 7))>;
|
2016-05-13 03:58:32 +08:00
|
|
|
def CSR_32_AllRegs_AVX : CalleeSavedRegs<(add CSR_32_AllRegs,
|
|
|
|
(sequence "YMM%u", 0, 7))>;
|
|
|
|
def CSR_32_AllRegs_AVX512 : CalleeSavedRegs<(add CSR_32_AllRegs,
|
|
|
|
(sequence "ZMM%u", 0, 7),
|
|
|
|
(sequence "K%u", 0, 7))>;
|
|
|
|
|
|
|
|
def CSR_64_AllRegs : CalleeSavedRegs<(add CSR_64_MostRegs, RAX)>;
|
2017-02-17 02:25:37 +08:00
|
|
|
def CSR_64_AllRegs_NoSSE : CalleeSavedRegs<(add RAX, RBX, RCX, RDX, RSI, RDI, R8, R9,
|
|
|
|
R10, R11, R12, R13, R14, R15, RBP)>;
|
2016-05-13 03:58:32 +08:00
|
|
|
def CSR_64_AllRegs_AVX : CalleeSavedRegs<(sub (add CSR_64_MostRegs, RAX,
|
2016-05-10 06:37:05 +08:00
|
|
|
(sequence "YMM%u", 0, 15)),
|
2014-01-11 09:00:27 +08:00
|
|
|
(sequence "XMM%u", 0, 15))>;
|
2016-05-13 03:58:32 +08:00
|
|
|
def CSR_64_AllRegs_AVX512 : CalleeSavedRegs<(sub (add CSR_64_MostRegs, RAX,
|
|
|
|
(sequence "ZMM%u", 0, 31),
|
|
|
|
(sequence "K%u", 0, 7)),
|
|
|
|
(sequence "XMM%u", 0, 15))>;
|
2013-12-14 14:52:59 +08:00
|
|
|
|
2012-10-24 22:46:16 +08:00
|
|
|
// Standard C + YMM6-15
|
|
|
|
def CSR_Win64_Intel_OCL_BI_AVX : CalleeSavedRegs<(add RBX, RBP, RDI, RSI, R12,
|
2013-11-01 01:18:07 +08:00
|
|
|
R13, R14, R15,
|
2012-10-24 22:46:16 +08:00
|
|
|
(sequence "YMM%u", 6, 15))>;
|
|
|
|
|
2013-07-24 19:02:47 +08:00
|
|
|
def CSR_Win64_Intel_OCL_BI_AVX512 : CalleeSavedRegs<(add RBX, RBP, RDI, RSI,
|
2013-11-01 01:18:07 +08:00
|
|
|
R12, R13, R14, R15,
|
2013-07-24 19:02:47 +08:00
|
|
|
(sequence "ZMM%u", 6, 21),
|
|
|
|
K4, K5, K6, K7)>;
|
2012-10-24 22:46:16 +08:00
|
|
|
//Standard C + XMM 8-15
|
|
|
|
def CSR_64_Intel_OCL_BI : CalleeSavedRegs<(add CSR_64,
|
|
|
|
(sequence "XMM%u", 8, 15))>;
|
|
|
|
|
|
|
|
//Standard C + YMM 8-15
|
|
|
|
def CSR_64_Intel_OCL_BI_AVX : CalleeSavedRegs<(add CSR_64,
|
|
|
|
(sequence "YMM%u", 8, 15))>;
|
2013-07-24 19:02:47 +08:00
|
|
|
|
2014-03-06 16:15:35 +08:00
|
|
|
def CSR_64_Intel_OCL_BI_AVX512 : CalleeSavedRegs<(add RBX, RDI, RSI, R14, R15,
|
2013-07-24 19:02:47 +08:00
|
|
|
(sequence "ZMM%u", 16, 31),
|
|
|
|
K4, K5, K6, K7)>;
|
HHVM calling conventions.
HHVM calling convention, hhvmcc, is used by HHVM JIT for
functions in translated cache. We currently support LLVM back end to
generate code for X86-64 and may support other architectures in the
future.
In HHVM calling convention any GP register could be used to pass and
return values, with the exception of R12 which is reserved for
thread-local area and is callee-saved. Other than R12, we always
pass RBX and RBP as args, which are our virtual machine's stack pointer
and frame pointer respectively.
When we enter translation cache via hhvmcc function, we expect
the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed
to standard ABI alignment. This affects stack object alignment and stack
adjustments for function calls.
One extra calling convention, hhvm_ccc, is used to call C++ helpers from
HHVM's translation cache. It is almost identical to standard C calling
convention with an exception of first argument which is passed in RBP
(before we use RDI, RSI, etc.)
Differential Revision: http://reviews.llvm.org/D12681
llvm-svn: 248832
2015-09-30 06:09:16 +08:00
|
|
|
|
|
|
|
// Only R12 is preserved for PHP calls in HHVM.
|
|
|
|
def CSR_64_HHVM : CalleeSavedRegs<(add R12)>;
|
2016-10-13 15:53:43 +08:00
|
|
|
|
|
|
|
// Register calling convention preserves few GPR and XMM8-15
|
|
|
|
def CSR_32_RegCall_NoSSE : CalleeSavedRegs<(add ESI, EDI, EBX, EBP, ESP)>;
|
|
|
|
def CSR_32_RegCall : CalleeSavedRegs<(add CSR_32_RegCall_NoSSE,
|
|
|
|
(sequence "XMM%u", 4, 7))>;
|
|
|
|
def CSR_Win64_RegCall_NoSSE : CalleeSavedRegs<(add RBX, RBP, RSP,
|
|
|
|
(sequence "R%u", 10, 15))>;
|
|
|
|
def CSR_Win64_RegCall : CalleeSavedRegs<(add CSR_Win64_RegCall_NoSSE,
|
|
|
|
(sequence "XMM%u", 8, 15))>;
|
|
|
|
def CSR_SysV64_RegCall_NoSSE : CalleeSavedRegs<(add RBX, RBP, RSP,
|
|
|
|
(sequence "R%u", 12, 15))>;
|
|
|
|
def CSR_SysV64_RegCall : CalleeSavedRegs<(add CSR_SysV64_RegCall_NoSSE,
|
|
|
|
(sequence "XMM%u", 8, 15))>;
|
|
|
|
|