blob: 6cd786eed4d55a203ff5377ff6f0f25b010da616 [file] [log] [blame]
Bob Wilson1f595bb2009-04-17 19:07:39 +00001//===- ARMCallingConv.td - Calling Conventions for ARM ----------*- C++ -*-===//
Bob Wilsondee46d72009-04-17 20:35:10 +00002//
Bob Wilson1f595bb2009-04-17 19:07:39 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilsondee46d72009-04-17 20:35:10 +00007//
Bob Wilson1f595bb2009-04-17 19:07:39 +00008//===----------------------------------------------------------------------===//
9// This describes the calling conventions for ARM architecture.
10//===----------------------------------------------------------------------===//
11
12/// CCIfSubtarget - Match if the current subtarget has a feature F.
Bob Wilsondee46d72009-04-17 20:35:10 +000013class CCIfSubtarget<string F, CCAction A>:
Bob Wilson1f595bb2009-04-17 19:07:39 +000014 CCIf<!strconcat("State.getTarget().getSubtarget<ARMSubtarget>().", F), A>;
15
16/// CCIfAlign - Match of the original alignment of the arg
17class CCIfAlign<string Align, CCAction A>:
18 CCIf<!strconcat("ArgFlags.getOrigAlign() == ", Align), A>;
19
20//===----------------------------------------------------------------------===//
21// ARM APCS Calling Convention
22//===----------------------------------------------------------------------===//
23def CC_ARM_APCS : CallingConv<[
24
25 CCIfType<[i8, i16], CCPromoteToType<i32>>,
26
27 // f64 is passed in pairs of GPRs, possibly split onto the stack
28 CCIfType<[f64], CCCustom<"CC_ARM_APCS_Custom_f64">>,
29
30 CCIfType<[f32], CCBitConvertToType<i32>>,
Bob Wilson1c2c4622009-04-24 16:55:25 +000031 CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
Bob Wilson1f595bb2009-04-17 19:07:39 +000032
Bob Wilson1c2c4622009-04-24 16:55:25 +000033 CCIfType<[i32], CCAssignToStack<4, 4>>,
Bob Wilson1f595bb2009-04-17 19:07:39 +000034 CCIfType<[f64], CCAssignToStack<8, 4>>
35]>;
36
37def RetCC_ARM_APCS : CallingConv<[
38 CCIfType<[f32], CCBitConvertToType<i32>>,
39 CCIfType<[f64], CCCustom<"RetCC_ARM_APCS_Custom_f64">>,
40
41 CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
42 CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
43]>;
44
45//===----------------------------------------------------------------------===//
46// ARM AAPCS (EABI) Calling Convention
47//===----------------------------------------------------------------------===//
48def CC_ARM_AAPCS : CallingConv<[
49
50 CCIfType<[i8, i16], CCPromoteToType<i32>>,
51
52 // i64/f64 is passed in even pairs of GPRs
53 // i64 is 8-aligned i32 here, so we may need to eat R1 as a pad register
Bob Wilson04746ea2009-05-19 10:02:36 +000054 // (and the same is true for f64 if VFP is not enabled)
Bob Wilson1f595bb2009-04-17 19:07:39 +000055 CCIfType<[i32], CCIfAlign<"8", CCAssignToRegWithShadow<[R0, R2], [R0, R1]>>>,
56 CCIfType<[f64], CCCustom<"CC_ARM_AAPCS_Custom_f64">>,
57
58 CCIfType<[f32], CCBitConvertToType<i32>>,
Bob Wilson04746ea2009-05-19 10:02:36 +000059 CCIfType<[i32], CCIf<"State.getNextStackOffset() == 0 &&"
60 "ArgFlags.getOrigAlign() != 8",
61 CCAssignToReg<[R0, R1, R2, R3]>>>,
Bob Wilson1f595bb2009-04-17 19:07:39 +000062
Bob Wilson1c2c4622009-04-24 16:55:25 +000063 CCIfType<[i32], CCAssignToStack<4, 4>>,
Bob Wilson1f595bb2009-04-17 19:07:39 +000064 CCIfType<[f64], CCAssignToStack<8, 8>>
65]>;
66
67def RetCC_ARM_AAPCS : CallingConv<[
68 CCIfType<[f32], CCBitConvertToType<i32>>,
69 CCIfType<[f64], CCCustom<"RetCC_ARM_AAPCS_Custom_f64">>,
70
71 CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
72 CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
73]>;
74
75//===----------------------------------------------------------------------===//
76// ARM Calling Convention Dispatch
77//===----------------------------------------------------------------------===//
78
79def CC_ARM : CallingConv<[
80 CCIfSubtarget<"isAAPCS_ABI()", CCDelegateTo<CC_ARM_AAPCS>>,
81 CCDelegateTo<CC_ARM_APCS>
82]>;
83
84def RetCC_ARM : CallingConv<[
85 CCIfSubtarget<"isAAPCS_ABI()", CCDelegateTo<RetCC_ARM_AAPCS>>,
86 CCDelegateTo<RetCC_ARM_APCS>
87]>;