1 //===- MipsCallingConv.td - Calling Conventions for Mips --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // This describes the calling conventions for Mips architecture.
10 //===----------------------------------------------------------------------===//
12 /// CCIfSubtarget - Match if the current subtarget has a feature F.
13 class CCIfSubtarget<string F, CCAction A>:
14 CCIf<!strconcat("State.getTarget().getSubtarget<MipsSubtarget>().", F), A>;
16 //===----------------------------------------------------------------------===//
17 // Mips O32 Calling Convention
18 //===----------------------------------------------------------------------===//
20 // Only the return rules are defined here for O32. The rules for argument
21 // passing are defined in MipsISelLowering.cpp.
22 def RetCC_MipsO32 : CallingConv<[
23 // i32 are returned in registers V0, V1
24 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
26 // f32 are returned in registers F0, F1
27 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
29 // f64 are returned in register D0
30 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
33 //===----------------------------------------------------------------------===//
34 // Mips EABI Calling Convention
35 //===----------------------------------------------------------------------===//
37 def CC_MipsEABI : CallingConv<[
38 // Promote i8/i16 arguments to i32.
39 CCIfType<[i8, i16], CCPromoteToType<i32>>,
41 // Integer arguments are passed in integer registers.
42 CCIfType<[i32], CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3]>>,
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]>>>,
48 CCIfType<[f32], CCIfSubtarget<"isNotSingleFloat()",
49 CCAssignToReg<[F12, F14, F16, F18]>>>,
51 // The first 4 doubl fp arguments are passed in single fp registers.
52 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()",
53 CCAssignToReg<[D6, D7, D8, D9]>>>,
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>>,
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>>>
64 def RetCC_MipsEABI : CallingConv<[
65 // i32 are returned in registers V0, V1
66 CCIfType<[i32], CCAssignToReg<[V0, V1]>>,
68 // f32 are returned in registers F0, F1
69 CCIfType<[f32], CCAssignToReg<[F0, F1]>>,
71 // f64 are returned in register D0
72 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0]>>>
75 //===----------------------------------------------------------------------===//
76 // Mips Calling Convention Dispatch
77 //===----------------------------------------------------------------------===//
79 def CC_Mips : CallingConv<[
80 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<CC_MipsEABI>>
83 def RetCC_Mips : CallingConv<[
84 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<RetCC_MipsEABI>>,
85 CCDelegateTo<RetCC_MipsO32>