blob: c05e82d5b570b4d77fda1d5847a516d9b7180600 [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
33 CCIfType<[i32], CCAssignToReg<[V0, V1]>>
34]>;
35
36//===----------------------------------------------------------------------===//
37// Mips EABI Calling Convention
38//===----------------------------------------------------------------------===//
39def CC_MipsEABI : CallingConv<[
40 // Promote i8/i16 arguments to i32.
41 CCIfType<[i8, i16], CCPromoteToType<i32>>,
42
43 // Integer arguments are passed in integer registers.
44 CCIfType<[i32], CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3]>>,
45
46 // Single fp arguments are passed in pairs within 32-bit mode
47 CCIfType<[f32], CCIfSubtarget<"isSingleFloat()",
48 CCAssignToReg<[F12, F13, F14, F15, F16, F17, F18, F19]>>>,
49
50 CCIfType<[f32], CCIfSubtarget<"isNotSingleFloat()",
51 CCAssignToReg<[F12, F14, F16, F18]>>>,
52
53 // The first 4 doubl fp arguments are passed in single fp registers.
54 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()",
55 CCAssignToReg<[D6, D7, D8, D9]>>>,
56
57 // Integer values get stored in stack slots that are 4 bytes in
58 // size and 4-byte aligned.
59 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
60
61 // Integer values get stored in stack slots that are 8 bytes in
62 // size and 8-byte aligned.
63 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToStack<8, 8>>>
64]>;
65
66def RetCC_MipsEABI : CallingConv<[
67 // i32 are returned in registers V0, V1
68 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
69
70 // f32 are returned in registers F0, F1
71 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
72
73 // f64 are returned in register D0
74 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
75]>;
76
77//===----------------------------------------------------------------------===//
78// Mips Calling Convention Dispatch
79//===----------------------------------------------------------------------===//
80
81def CC_Mips : CallingConv<[
82 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<CC_MipsEABI>>,
83 CCDelegateTo<CC_MipsO32>
84]>;
85
86def RetCC_Mips : CallingConv<[
87 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<RetCC_MipsEABI>>,
88 CCDelegateTo<RetCC_MipsO32>
89]>;