2010-08-18 00:20:04 +08:00
|
|
|
//===- ARMCallingConv.td - Calling Conventions for ARM -----*- tablegen -*-===//
|
2009-04-18 04:35:10 +08:00
|
|
|
//
|
2009-04-18 03:07:39 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2009-04-18 04:35:10 +08:00
|
|
|
//
|
2009-04-18 03:07:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// This describes the calling conventions for ARM architecture.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// CCIfSubtarget - Match if the current subtarget has a feature F.
|
2009-04-18 04:35:10 +08:00
|
|
|
class CCIfSubtarget<string F, CCAction A>:
|
2009-04-18 03:07:39 +08:00
|
|
|
CCIf<!strconcat("State.getTarget().getSubtarget<ARMSubtarget>().", F), A>;
|
|
|
|
|
|
|
|
/// CCIfAlign - Match of the original alignment of the arg
|
|
|
|
class CCIfAlign<string Align, CCAction A>:
|
|
|
|
CCIf<!strconcat("ArgFlags.getOrigAlign() == ", Align), A>;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM APCS Calling Convention
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
def CC_ARM_APCS : CallingConv<[
|
|
|
|
|
2011-03-01 01:17:53 +08:00
|
|
|
// Handles byval parameters.
|
2011-04-21 00:47:52 +08:00
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
2011-03-01 01:17:53 +08:00
|
|
|
|
2009-04-18 03:07:39 +08:00
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
2009-06-23 07:27:02 +08:00
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
// f64 and v2f64 are passed in adjacent GPRs, possibly split onto the stack
|
|
|
|
CCIfType<[f64, v2f64], CCCustom<"CC_ARM_APCS_Custom_f64">>,
|
2009-04-18 03:07:39 +08:00
|
|
|
|
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-04-25 00:55:25 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
2009-04-18 03:07:39 +08:00
|
|
|
|
2009-04-25 00:55:25 +08:00
|
|
|
CCIfType<[i32], CCAssignToStack<4, 4>>,
|
2009-06-23 07:27:02 +08:00
|
|
|
CCIfType<[f64], CCAssignToStack<8, 4>>,
|
|
|
|
CCIfType<[v2f64], CCAssignToStack<16, 4>>
|
2009-04-18 03:07:39 +08:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_ARM_APCS : CallingConv<[
|
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-06-23 07:27:02 +08:00
|
|
|
|
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
CCIfType<[f64, v2f64], CCCustom<"RetCC_ARM_APCS_Custom_f64">>,
|
2009-04-18 03:07:39 +08:00
|
|
|
|
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
|
|
|
CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
|
|
|
|
]>;
|
|
|
|
|
2010-10-23 02:23:05 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM APCS Calling Convention for FastCC (when VFP2 or later is available)
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
def FastCC_ARM_APCS : CallingConv<[
|
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
|
|
|
|
CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
|
|
|
|
S9, S10, S11, S12, S13, S14, S15]>>,
|
|
|
|
CCDelegateTo<CC_ARM_APCS>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetFastCC_ARM_APCS : CallingConv<[
|
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
|
|
|
|
CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
|
|
|
|
S9, S10, S11, S12, S13, S14, S15]>>,
|
|
|
|
CCDelegateTo<RetCC_ARM_APCS>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
|
2009-04-18 03:07:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-09 06:53:56 +08:00
|
|
|
// ARM AAPCS (EABI) Calling Convention, common parts
|
2009-04-18 03:07:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-09 06:53:56 +08:00
|
|
|
|
|
|
|
def CC_ARM_AAPCS_Common : CallingConv<[
|
2009-04-18 03:07:39 +08:00
|
|
|
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// i64/f64 is passed in even pairs of GPRs
|
|
|
|
// i64 is 8-aligned i32 here, so we may need to eat R1 as a pad register
|
2009-05-19 18:02:36 +08:00
|
|
|
// (and the same is true for f64 if VFP is not enabled)
|
2009-04-18 03:07:39 +08:00
|
|
|
CCIfType<[i32], CCIfAlign<"8", CCAssignToRegWithShadow<[R0, R2], [R0, R1]>>>,
|
2009-05-19 18:02:36 +08:00
|
|
|
CCIfType<[i32], CCIf<"State.getNextStackOffset() == 0 &&"
|
|
|
|
"ArgFlags.getOrigAlign() != 8",
|
|
|
|
CCAssignToReg<[R0, R1, R2, R3]>>>,
|
2009-04-18 03:07:39 +08:00
|
|
|
|
2010-08-06 23:35:32 +08:00
|
|
|
CCIfType<[i32], CCIfAlign<"8", CCAssignToStackWithShadow<4, 8, R3>>>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
|
2009-06-23 07:27:02 +08:00
|
|
|
CCIfType<[f64], CCAssignToStack<8, 8>>,
|
|
|
|
CCIfType<[v2f64], CCAssignToStack<16, 8>>
|
2009-04-18 03:07:39 +08:00
|
|
|
]>;
|
|
|
|
|
2009-06-09 06:53:56 +08:00
|
|
|
def RetCC_ARM_AAPCS_Common : CallingConv<[
|
2009-06-09 06:59:50 +08:00
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM AAPCS (EABI) Calling Convention
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_ARM_AAPCS : CallingConv<[
|
2009-06-23 07:27:02 +08:00
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
CCIfType<[f64, v2f64], CCCustom<"CC_ARM_AAPCS_Custom_f64">>,
|
2009-04-18 03:07:39 +08:00
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCDelegateTo<CC_ARM_AAPCS_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_ARM_AAPCS : CallingConv<[
|
2009-06-23 07:27:02 +08:00
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
|
|
|
CCIfType<[f64, v2f64], CCCustom<"RetCC_ARM_AAPCS_Custom_f64">>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
|
|
|
CCDelegateTo<RetCC_ARM_AAPCS_Common>
|
|
|
|
]>;
|
2009-04-18 03:07:39 +08:00
|
|
|
|
2009-06-09 06:53:56 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM AAPCS-VFP (EABI) Calling Convention
|
2010-10-23 02:23:05 +08:00
|
|
|
// Also used for FastCC (when VFP2 or later is available)
|
2009-06-09 06:53:56 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_ARM_AAPCS_VFP : CallingConv<[
|
2009-06-23 07:27:02 +08:00
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
2009-08-06 03:04:42 +08:00
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
|
|
|
|
CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
|
|
|
|
S9, S10, S11, S12, S13, S14, S15]>>,
|
|
|
|
CCDelegateTo<CC_ARM_AAPCS_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_ARM_AAPCS_VFP : CallingConv<[
|
2009-06-23 07:27:02 +08:00
|
|
|
// Handle all vector types as either f64 or v2f64.
|
|
|
|
CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
|
|
|
|
CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
|
|
|
|
|
2009-08-06 03:04:42 +08:00
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
2009-06-09 06:53:56 +08:00
|
|
|
CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
|
|
|
|
CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
|
|
|
|
S9, S10, S11, S12, S13, S14, S15]>>,
|
|
|
|
CCDelegateTo<RetCC_ARM_AAPCS_Common>
|
2009-04-18 03:07:39 +08:00
|
|
|
]>;
|