MipsCallingConv.td revision 208954
1//===- MipsCallingConv.td - Calling Conventions for Mips --------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 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//===----------------------------------------------------------------------===// 17// Mips O32 Calling Convention 18//===----------------------------------------------------------------------===// 19 20// Only the return rules are defined here for O32. The rules for argument 21// passing are defined in MipsISelLowering.cpp. 22def RetCC_MipsO32 : CallingConv<[ 23 // i32 are returned in registers V0, V1 24 CCIfType<[i32], CCAssignToReg<[V0, V1]>>, 25 26 // f32 are returned in registers F0, F2 27 CCIfType<[f32], CCAssignToReg<[F0, F2]>>, 28 29 // f64 are returned in register D0, D1 30 CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D0, D1]>>> 31]>; 32 33//===----------------------------------------------------------------------===// 34// Mips EABI Calling Convention 35//===----------------------------------------------------------------------===// 36 37def 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<[ 80 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<CC_MipsEABI>> 81]>; 82 83def RetCC_Mips : CallingConv<[ 84 CCIfSubtarget<"isABI_EABI()", CCDelegateTo<RetCC_MipsEABI>>, 85 CCDelegateTo<RetCC_MipsO32> 86]>; 87