2012-02-18 12:03:15 +00:00
|
|
|
//===-- ARMCallingConv.td - Calling Conventions for ARM ----*- tablegen -*-===//
|
2009-04-17 20:35:10 +00:00
|
|
|
//
|
2009-04-17 19:07:39 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2009-04-17 20:35:10 +00:00
|
|
|
//
|
2009-04-17 19:07:39 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// This describes the calling conventions for ARM architecture.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// 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-02-28 17:17:53 +00:00
|
|
|
// Handles byval parameters.
|
2011-04-20 16:47:52 +00:00
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
2011-02-28 17:17:53 +00:00
|
|
|
|
2011-11-05 00:02:56 +00:00
|
|
|
CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
|
2009-04-17 19:07:39 +00:00
|
|
|
|
2009-06-22 23:27:02 +00: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-17 19:07:39 +00:00
|
|
|
|
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-04-24 16:55:25 +00:00
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
2009-04-17 19:07:39 +00:00
|
|
|
|
2009-04-24 16:55:25 +00:00
|
|
|
CCIfType<[i32], CCAssignToStack<4, 4>>,
|
2009-06-22 23:27:02 +00:00
|
|
|
CCIfType<[f64], CCAssignToStack<8, 4>>,
|
|
|
|
CCIfType<[v2f64], CCAssignToStack<16, 4>>
|
2009-04-17 19:07:39 +00:00
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_ARM_APCS : CallingConv<[
|
2011-11-08 00:03:32 +00:00
|
|
|
CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
|
2009-04-17 19:07:39 +00:00
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-06-22 23:27:02 +00: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-17 19:07:39 +00:00
|
|
|
|
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
|
|
|
CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
|
|
|
|
]>;
|
|
|
|
|
2010-10-22 18:23:05 +00: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]>>,
|
2014-02-11 23:49:31 +00:00
|
|
|
|
2014-03-04 22:56:57 +00:00
|
|
|
// CPRCs may be allocated to co-processor registers or the stack - they
|
2014-02-11 23:49:31 +00:00
|
|
|
// may never be allocated to core registers.
|
|
|
|
CCIfType<[f32], CCAssignToStackWithShadow<4, 4, [Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[f64], CCAssignToStackWithShadow<8, 4, [Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[v2f64], CCAssignToStackWithShadow<16, 4, [Q0, Q1, Q2, Q3]>>,
|
|
|
|
|
2010-10-22 18:23:05 +00:00
|
|
|
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>
|
|
|
|
]>;
|
|
|
|
|
2012-08-03 00:05:53 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM APCS Calling Convention for GHC
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_ARM_APCS_GHC : 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<[Q4, Q5]>>,
|
|
|
|
CCIfType<[f64], CCAssignToReg<[D8, D9, D10, D11]>>,
|
|
|
|
CCIfType<[f32], CCAssignToReg<[S16, S17, S18, S19, S20, S21, S22, S23]>>,
|
|
|
|
|
|
|
|
// Promote i8/i16 arguments to i32.
|
|
|
|
CCIfType<[i8, i16], CCPromoteToType<i32>>,
|
|
|
|
|
|
|
|
// Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, SpLim
|
|
|
|
CCIfType<[i32], CCAssignToReg<[R4, R5, R6, R7, R8, R9, R10, R11]>>
|
|
|
|
]>;
|
2010-10-22 18:23:05 +00:00
|
|
|
|
2009-04-17 19:07:39 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-08 22:53:56 +00:00
|
|
|
// ARM AAPCS (EABI) Calling Convention, common parts
|
2009-04-17 19:07:39 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-08 22:53:56 +00:00
|
|
|
|
|
|
|
def CC_ARM_AAPCS_Common : CallingConv<[
|
2009-04-17 19:07:39 +00:00
|
|
|
|
2011-11-07 21:43:40 +00:00
|
|
|
CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
|
2009-04-17 19:07:39 +00:00
|
|
|
|
|
|
|
// 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 10:02:36 +00:00
|
|
|
// (and the same is true for f64 if VFP is not enabled)
|
2009-04-17 19:07:39 +00:00
|
|
|
CCIfType<[i32], CCIfAlign<"8", CCAssignToRegWithShadow<[R0, R2], [R0, R1]>>>,
|
2013-04-22 13:06:52 +00:00
|
|
|
CCIfType<[i32], CCIf<"ArgFlags.getOrigAlign() != 8",
|
2009-05-19 10:02:36 +00:00
|
|
|
CCAssignToReg<[R0, R1, R2, R3]>>>,
|
2009-04-17 19:07:39 +00:00
|
|
|
|
2014-02-07 11:19:53 +00:00
|
|
|
CCIfType<[i32], CCIfAlign<"8", CCAssignToStackWithShadow<4, 8, [R0, R1, R2, R3]>>>,
|
|
|
|
CCIfType<[i32], CCAssignToStackWithShadow<4, 4, [R0, R1, R2, R3]>>,
|
|
|
|
CCIfType<[f32], CCAssignToStackWithShadow<4, 4, [Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[f64], CCAssignToStackWithShadow<8, 8, [Q0, Q1, Q2, Q3]>>,
|
|
|
|
CCIfType<[v2f64], CCAssignToStackWithShadow<16, 8, [Q0, Q1, Q2, Q3]>>
|
2009-04-17 19:07:39 +00:00
|
|
|
]>;
|
|
|
|
|
2009-06-08 22:53:56 +00:00
|
|
|
def RetCC_ARM_AAPCS_Common : CallingConv<[
|
2011-11-08 00:03:32 +00:00
|
|
|
CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
|
2009-06-08 22:59:50 +00:00
|
|
|
CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
|
2009-06-08 22:53:56 +00:00
|
|
|
CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM AAPCS (EABI) Calling Convention
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_ARM_AAPCS : CallingConv<[
|
2012-08-10 20:39:38 +00:00
|
|
|
// Handles byval parameters.
|
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
|
|
|
|
2009-06-22 23:27:02 +00: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-17 19:07:39 +00:00
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
2009-06-08 22:53:56 +00:00
|
|
|
CCDelegateTo<CC_ARM_AAPCS_Common>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
def RetCC_ARM_AAPCS : CallingConv<[
|
2009-06-22 23:27:02 +00: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-08 22:53:56 +00:00
|
|
|
CCIfType<[f32], CCBitConvertToType<i32>>,
|
|
|
|
CCDelegateTo<RetCC_ARM_AAPCS_Common>
|
|
|
|
]>;
|
2009-04-17 19:07:39 +00:00
|
|
|
|
2009-06-08 22:53:56 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ARM AAPCS-VFP (EABI) Calling Convention
|
2010-10-22 18:23:05 +00:00
|
|
|
// Also used for FastCC (when VFP2 or later is available)
|
2009-06-08 22:53:56 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def CC_ARM_AAPCS_VFP : CallingConv<[
|
2012-08-13 21:22:50 +00:00
|
|
|
// Handles byval parameters.
|
|
|
|
CCIfByVal<CCPassByVal<4, 4>>,
|
|
|
|
|
2009-06-22 23:27:02 +00: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>>,
|
|
|
|
|
2014-05-09 14:01:47 +00:00
|
|
|
// HFAs are passed in a contiguous block of registers, or on the stack
|
2015-02-24 17:22:34 +00:00
|
|
|
CCIfConsecutiveRegs<CCCustom<"CC_ARM_AAPCS_Custom_Aggregate">>,
|
2014-05-09 14:01:47 +00:00
|
|
|
|
2009-08-05 19:04:42 +00:00
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
2009-06-08 22:53:56 +00: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-22 23:27:02 +00: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-05 19:04:42 +00:00
|
|
|
CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
|
2009-06-08 22:53:56 +00: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-17 19:07:39 +00:00
|
|
|
]>;
|
2012-01-17 23:09:00 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Callee-saved register lists.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-11-06 23:05:24 +00:00
|
|
|
def CSR_NoRegs : CalleeSavedRegs<(add)>;
|
|
|
|
|
2012-01-17 23:09:00 +00:00
|
|
|
def CSR_AAPCS : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7, R6, R5, R4,
|
|
|
|
(sequence "D%u", 15, 8))>;
|
|
|
|
|
2013-04-20 05:14:40 +00:00
|
|
|
// Constructors and destructors return 'this' in the ARM C++ ABI; since 'this'
|
|
|
|
// and the pointer return value are both passed in R0 in these cases, this can
|
|
|
|
// be partially modelled by treating R0 as a callee-saved register
|
|
|
|
// Only the resulting RegMask is used; the SaveList is ignored
|
|
|
|
def CSR_AAPCS_ThisReturn : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7, R6,
|
|
|
|
R5, R4, (sequence "D%u", 15, 8),
|
|
|
|
R0)>;
|
|
|
|
|
2012-01-17 23:09:00 +00:00
|
|
|
// iOS ABI deviates from ARM standard ABI. R9 is not a callee-saved register.
|
|
|
|
// Also save R7-R4 first to match the stack frame fixed spill areas.
|
|
|
|
def CSR_iOS : CalleeSavedRegs<(add LR, R7, R6, R5, R4, (sub CSR_AAPCS, R9))>;
|
2012-08-03 00:05:53 +00:00
|
|
|
|
2013-04-20 05:14:40 +00:00
|
|
|
def CSR_iOS_ThisReturn : CalleeSavedRegs<(add LR, R7, R6, R5, R4,
|
2013-10-01 14:33:28 +00:00
|
|
|
(sub CSR_AAPCS_ThisReturn, R9))>;
|
|
|
|
|
|
|
|
// The "interrupt" attribute is used to generate code that is acceptable in
|
|
|
|
// exception-handlers of various kinds. It makes us use a different return
|
|
|
|
// instruction (handled elsewhere) and affects which registers we must return to
|
|
|
|
// our "caller" in the same state as we receive them.
|
|
|
|
|
|
|
|
// For most interrupts, all registers except SP and LR are shared with
|
|
|
|
// user-space. We mark LR to be saved anyway, since this is what the ARM backend
|
|
|
|
// generally does rather than tracking its liveness as a normal register.
|
|
|
|
def CSR_GenericInt : CalleeSavedRegs<(add LR, (sequence "R%u", 12, 0))>;
|
|
|
|
|
|
|
|
// The fast interrupt handlers have more private state and get their own copies
|
|
|
|
// of R8-R12, in addition to SP and LR. As before, mark LR for saving too.
|
|
|
|
|
|
|
|
// FIXME: we mark R11 as callee-saved since it's often the frame-pointer, and
|
|
|
|
// current frame lowering expects to encounter it while processing callee-saved
|
|
|
|
// registers.
|
|
|
|
def CSR_FIQ : CalleeSavedRegs<(add LR, R11, (sequence "R%u", 7, 0))>;
|
|
|
|
|
|
|
|
|