blob: 034a8d16ca3068818d18aa78c67f7dec62579e28 [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===- MipsCallingConv.td - Calling Conventions for Mips --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
8//===----------------------------------------------------------------------===//
9// This describes the calling conventions for Mips architecture.
10//===----------------------------------------------------------------------===//
11
12/// CCIfSubtarget - Match if the current subtarget has a feature F.
13class CCIfSubtarget<string F, CCAction A>:
14 CCIf<!strconcat("State.getTarget().getSubtarget<MipsSubtarget>().", F), A>;
15
16//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000017// Mips O32 Calling Convention
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000018//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000019def CC_MipsO32 : CallingConv<[
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000020 // Promote i8/i16 arguments to i32.
21 CCIfType<[i8, i16], CCPromoteToType<i32>>,
22
23 // The first 4 integer arguments are passed in integer registers.
24 CCIfType<[i32], CCAssignToReg<[A0, A1, A2, A3]>>,
25
26 // Integer values get stored in stack slots that are 4 bytes in
27 // size and 4-byte aligned.
28 CCIfType<[i32], CCAssignToStack<4, 4>>
29]>;
30
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000031def RetCC_MipsO32 : CallingConv<[
32 // i32 are returned in registers V0, V1
Bruno Cardoso Lopes64cf1602008-08-03 15:37:43 +000033 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
34
35 // f32 are returned in registers F0, F1
36 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
37
38 // f64 are returned in register D0
39 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000040]>;
41
42//===----------------------------------------------------------------------===//
43// Mips EABI Calling Convention
44//===----------------------------------------------------------------------===//
45def CC_MipsEABI : CallingConv<[
46 // Promote i8/i16 arguments to i32.
47 CCIfType<[i8, i16], CCPromoteToType<i32>>,
48
49 // Integer arguments are passed in integer registers.
50 CCIfType<[i32], CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3]>>,
51
52 // Single fp arguments are passed in pairs within 32-bit mode
53 CCIfType<[f32], CCIfSubtarget<"isSingleFloat()",
54 CCAssignToReg<[F12, F13, F14, F15, F16, F17, F18, F19]>>>,
55
56 CCIfType<[f32], CCIfSubtarget<"isNotSingleFloat()",
57 CCAssignToReg<[F12, F14, F16, F18]>>>,
58
59 // The first 4 doubl fp arguments are passed in single fp registers.
60 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()",
61 CCAssignToReg<[D6, D7, D8, D9]>>>,
62
63 // Integer values get stored in stack slots that are 4 bytes in
64 // size and 4-byte aligned.
65 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
66
67 // Integer values get stored in stack slots that are 8 bytes in
68 // size and 8-byte aligned.
69 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToStack<8, 8>>>
70]>;
71
72def RetCC_MipsEABI : CallingConv<[
73 // i32 are returned in registers V0, V1
74 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
75
76 // f32 are returned in registers F0, F1
77 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
78
79 // f64 are returned in register D0
80 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
81]>;
82
83//===----------------------------------------------------------------------===//
84// Mips Calling Convention Dispatch
85//===----------------------------------------------------------------------===//
86
87def CC_Mips : CallingConv<[
88 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<CC_MipsEABI>>,
89 CCDelegateTo<CC_MipsO32>
90]>;
91
92def RetCC_Mips : CallingConv<[
93 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<RetCC_MipsEABI>>,
94 CCDelegateTo<RetCC_MipsO32>
95]>;