blob: 01fe92e6b73cfc090bcd162f67dca956248f23a8 [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 Lopes972f5892007-06-06 07:42:06 +000019
Bruno Cardoso Lopesb53db4f2009-03-19 02:12:28 +000020// Only the return rules are defined here for O32. The rules for argument
21// passing are defined in MipsISelLowering.cpp.
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000022def RetCC_MipsO32 : CallingConv<[
23 // i32 are returned in registers V0, V1
Bruno Cardoso Lopes64cf1602008-08-03 15:37:43 +000024 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
25
26 // f32 are returned in registers F0, F1
27 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
28
29 // f64 are returned in register D0
30 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000031]>;
32
33//===----------------------------------------------------------------------===//
34// Mips EABI Calling Convention
35//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesb53db4f2009-03-19 02:12:28 +000036
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000037def CC_MipsEABI : CallingConv<[
38 // Promote i8/i16 arguments to i32.
39 CCIfType<[i8, i16], CCPromoteToType<i32>>,
40
41 // Integer arguments are passed in integer registers.
42 CCIfType<[i32], CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3]>>,
43
44 // Single fp arguments are passed in pairs within 32-bit mode
45 CCIfType<[f32], CCIfSubtarget<"isSingleFloat()",
46 CCAssignToReg<[F12, F13, F14, F15, F16, F17, F18, F19]>>>,
47
48 CCIfType<[f32], CCIfSubtarget<"isNotSingleFloat()",
49 CCAssignToReg<[F12, F14, F16, F18]>>>,
50
51 // The first 4 doubl fp arguments are passed in single fp registers.
52 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()",
53 CCAssignToReg<[D6, D7, D8, D9]>>>,
54
55 // Integer values get stored in stack slots that are 4 bytes in
56 // size and 4-byte aligned.
57 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
58
59 // Integer values get stored in stack slots that are 8 bytes in
60 // size and 8-byte aligned.
61 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToStack<8, 8>>>
62]>;
63
64def RetCC_MipsEABI : CallingConv<[
65 // i32 are returned in registers V0, V1
66 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
67
68 // f32 are returned in registers F0, F1
69 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
70
71 // f64 are returned in register D0
72 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
73]>;
74
75//===----------------------------------------------------------------------===//
76// Mips Calling Convention Dispatch
77//===----------------------------------------------------------------------===//
78
79def CC_Mips : CallingConv<[
Bruno Cardoso Lopesb53db4f2009-03-19 02:12:28 +000080 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<CC_MipsEABI>>
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000081]>;
82
83def RetCC_Mips : CallingConv<[
84 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<RetCC_MipsEABI>>,
85 CCDelegateTo<RetCC_MipsO32>
86]>;