blob: b5df78f89a6b90ba52e1556ee65fcc98156b11e6 [file] [log] [blame]
Jia Liuf54f60f2012-02-28 07:46:26 +00001//===-- MipsCallingConv.td - Calling Conventions for Mips --*- tablegen -*-===//
Bruno Cardoso Lopesed874ef2011-03-04 17:51:39 +00002//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Lopesed874ef2011-03-04 17:51:39 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +00009// This describes the calling conventions for Mips architecture.
Akira Hatanakae2489122011-04-15 21:51:11 +000010//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000011
12/// CCIfSubtarget - Match if the current subtarget has a feature F.
Daniel Sanders24b65722014-09-10 12:02:27 +000013class CCIfSubtarget<string F, CCAction A, string Invert = "">
14 : CCIf<!strconcat(Invert,
15 "static_cast<const MipsSubtarget&>"
Eric Christopherb5217502014-08-06 18:45:26 +000016 "(State.getMachineFunction().getSubtarget()).",
17 F),
18 A>;
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000019
Daniel Sanders24b65722014-09-10 12:02:27 +000020// The inverse of CCIfSubtarget
21class CCIfSubtargetNot<string F, CCAction A> : CCIfSubtarget<F, A, "!">;
22
Daniel Sandersc8a040c2014-12-08 15:40:09 +000023/// Match if the original argument (before lowering) was a float.
24/// For example, this is true for i32's that were lowered from soft-float.
25class CCIfOrigArgWasNotFloat<CCAction A>
26 : CCIf<"!static_cast<MipsCCState *>(&State)->WasOriginalArgFloat(ValNo)",
27 A>;
28
29/// Match if the original argument (before lowering) was a 128-bit float (i.e.
30/// long double).
31class CCIfOrigArgWasF128<CCAction A>
32 : CCIf<"static_cast<MipsCCState *>(&State)->WasOriginalArgF128(ValNo)", A>;
33
34/// Match if this specific argument is a vararg.
35/// This is slightly different fro CCIfIsVarArg which matches if any argument is
36/// a vararg.
37class CCIfArgIsVarArg<CCAction A>
38 : CCIf<"!static_cast<MipsCCState *>(&State)->IsCallOperandFixed(ValNo)", A>;
39
Simon Dardis212cccb2017-06-09 14:37:08 +000040/// Match if the return was a floating point vector.
41class CCIfOrigArgWasNotVectorFloat<CCAction A>
42 : CCIf<"!static_cast<MipsCCState *>(&State)"
43 "->WasOriginalRetVectorFloat(ValNo)", A>;
Daniel Sandersc8a040c2014-12-08 15:40:09 +000044
45/// Match if the special calling conv is the specified value.
46class CCIfSpecialCallingConv<string CC, CCAction A>
47 : CCIf<"static_cast<MipsCCState *>(&State)->getSpecialCallingConv() == "
48 "MipsCCState::" # CC, A>;
49
Daniel Sandersb3ca3382014-09-26 10:06:12 +000050// For soft-float, f128 values are returned in A0_64 rather than V1_64.
51def RetCC_F128SoftFloat : CallingConv<[
52 CCAssignToReg<[V0_64, A0_64]>
53]>;
54
55// For hard-float, f128 values are returned as a pair of f64's rather than a
56// pair of i64's.
57def RetCC_F128HardFloat : CallingConv<[
58 CCBitConvertToType<f64>,
Daniel Sandersf3fe49a2014-10-07 09:29:59 +000059
60 // Contrary to the ABI documentation, a struct containing a long double is
61 // returned in $f0, and $f1 instead of the usual $f0, and $f2. This is to
62 // match the de facto ABI as implemented by GCC.
63 CCIfInReg<CCAssignToReg<[D0_64, D1_64]>>,
64
Daniel Sandersb3ca3382014-09-26 10:06:12 +000065 CCAssignToReg<[D0_64, D2_64]>
66]>;
67
68// Handle F128 specially since we can't identify the original type during the
69// tablegen-erated code.
70def RetCC_F128 : CallingConv<[
Eric Christophere8ae3e32015-05-07 23:10:21 +000071 CCIfSubtarget<"useSoftFloat()",
Daniel Sandersb3ca3382014-09-26 10:06:12 +000072 CCIfType<[i64], CCDelegateTo<RetCC_F128SoftFloat>>>,
Eric Christophere8ae3e32015-05-07 23:10:21 +000073 CCIfSubtargetNot<"useSoftFloat()",
Daniel Sandersb3ca3382014-09-26 10:06:12 +000074 CCIfType<[i64], CCDelegateTo<RetCC_F128HardFloat>>>
75]>;
76
Akira Hatanakae2489122011-04-15 21:51:11 +000077//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000078// Mips O32 Calling Convention
Akira Hatanakae2489122011-04-15 21:51:11 +000079//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes35e43c42007-06-06 07:42:06 +000080
Reed Kotlerd5c41962014-11-13 23:37:45 +000081def CC_MipsO32 : CallingConv<[
82 // Promote i8/i16 arguments to i32.
83 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
84
85 // Integer values get stored in stack slots that are 4 bytes in
86 // size and 4-byte aligned.
87 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
88
89 // Integer values get stored in stack slots that are 8 bytes in
90 // size and 8-byte aligned.
91 CCIfType<[f64], CCAssignToStack<8, 8>>
92]>;
93
Bruno Cardoso Lopesed874ef2011-03-04 17:51:39 +000094// Only the return rules are defined here for O32. The rules for argument
Bruno Cardoso Lopes3b7b3012009-03-19 02:12:28 +000095// passing are defined in MipsISelLowering.cpp.
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000096def RetCC_MipsO32 : CallingConv<[
Vasileios Kalintiris1249e742015-04-29 14:17:14 +000097 // Promote i1/i8/i16 return values to i32.
98 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
99
Simon Dardis212cccb2017-06-09 14:37:08 +0000100 // i32 are returned in registers V0, V1, A0, A1, unless the original return
101 // type was a vector of floats.
102 CCIfOrigArgWasNotVectorFloat<CCIfType<[i32],
103 CCAssignToReg<[V0, V1, A0, A1]>>>,
Bruno Cardoso Lopes3e667cf2008-08-03 15:37:43 +0000104
Bruno Cardoso Lopes2f5c8e32010-01-19 12:37:35 +0000105 // f32 are returned in registers F0, F2
106 CCIfType<[f32], CCAssignToReg<[F0, F2]>>,
Bruno Cardoso Lopes3e667cf2008-08-03 15:37:43 +0000107
Zoran Jovanovicf34b4542014-07-10 22:23:30 +0000108 // f64 arguments are returned in D0_64 and D2_64 in FP64bit mode or
Akira Hatanakabfb66242013-08-20 23:38:40 +0000109 // in D0 and D1 in FP32bit mode.
Zoran Jovanovicf34b4542014-07-10 22:23:30 +0000110 CCIfType<[f64], CCIfSubtarget<"isFP64bit()", CCAssignToReg<[D0_64, D2_64]>>>,
Daniel Sanders24b65722014-09-10 12:02:27 +0000111 CCIfType<[f64], CCIfSubtargetNot<"isFP64bit()", CCAssignToReg<[D0, D1]>>>
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000112]>;
113
Daniel Sandersca80f1a2014-11-01 17:38:22 +0000114def CC_MipsO32_FP32 : CustomCallingConv;
115def CC_MipsO32_FP64 : CustomCallingConv;
116
117def CC_MipsO32_FP : CallingConv<[
118 CCIfSubtargetNot<"isFP64bit()", CCDelegateTo<CC_MipsO32_FP32>>,
119 CCIfSubtarget<"isFP64bit()", CCDelegateTo<CC_MipsO32_FP64>>
120]>;
121
Akira Hatanakae2489122011-04-15 21:51:11 +0000122//===----------------------------------------------------------------------===//
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000123// Mips N32/64 Calling Convention
124//===----------------------------------------------------------------------===//
125
Daniel Sandersc43cda82014-11-07 16:54:21 +0000126def CC_MipsN_SoftFloat : CallingConv<[
127 CCAssignToRegWithShadow<[A0, A1, A2, A3,
128 T0, T1, T2, T3],
129 [D12_64, D13_64, D14_64, D15_64,
130 D16_64, D17_64, D18_64, D19_64]>,
131 CCAssignToStack<4, 8>
132]>;
133
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000134def CC_MipsN : CallingConv<[
Petar Jovanovicb592a752015-03-16 15:01:09 +0000135 CCIfType<[i8, i16, i32, i64],
Daniel Sandersc43cda82014-11-07 16:54:21 +0000136 CCIfSubtargetNot<"isLittle()",
137 CCIfInReg<CCPromoteToUpperBitsInType<i64>>>>,
138
139 // All integers (except soft-float integers) are promoted to 64-bit.
Daniel Sandersc8a040c2014-12-08 15:40:09 +0000140 CCIfType<[i8, i16, i32], CCIfOrigArgWasNotFloat<CCPromoteToType<i64>>>,
Daniel Sandersc43cda82014-11-07 16:54:21 +0000141
142 // The only i32's we have left are soft-float arguments.
Eric Christophere8ae3e32015-05-07 23:10:21 +0000143 CCIfSubtarget<"useSoftFloat()", CCIfType<[i32], CCDelegateTo<CC_MipsN_SoftFloat>>>,
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000144
145 // Integer arguments are passed in integer registers.
146 CCIfType<[i64], CCAssignToRegWithShadow<[A0_64, A1_64, A2_64, A3_64,
147 T0_64, T1_64, T2_64, T3_64],
148 [D12_64, D13_64, D14_64, D15_64,
149 D16_64, D17_64, D18_64, D19_64]>>,
150
151 // f32 arguments are passed in single precision FP registers.
152 CCIfType<[f32], CCAssignToRegWithShadow<[F12, F13, F14, F15,
153 F16, F17, F18, F19],
154 [A0_64, A1_64, A2_64, A3_64,
155 T0_64, T1_64, T2_64, T3_64]>>,
156
157 // f64 arguments are passed in double precision FP registers.
158 CCIfType<[f64], CCAssignToRegWithShadow<[D12_64, D13_64, D14_64, D15_64,
159 D16_64, D17_64, D18_64, D19_64],
160 [A0_64, A1_64, A2_64, A3_64,
161 T0_64, T1_64, T2_64, T3_64]>>,
162
163 // All stack parameter slots become 64-bit doublewords and are 8-byte aligned.
Daniel Sandersc43cda82014-11-07 16:54:21 +0000164 CCIfType<[f32], CCAssignToStack<4, 8>>,
Akira Hatanakad608bac2012-02-17 02:20:26 +0000165 CCIfType<[i64, f64], CCAssignToStack<8, 8>>
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000166]>;
167
Akira Hatanaka0b8bc002011-11-14 19:02:54 +0000168// N32/64 variable arguments.
169// All arguments are passed in integer registers.
170def CC_MipsN_VarArg : CallingConv<[
Petar Jovanovic90ec1b12015-02-26 18:35:15 +0000171 CCIfType<[i8, i16, i32, i64],
172 CCIfSubtargetNot<"isLittle()",
173 CCIfInReg<CCPromoteToUpperBitsInType<i64>>>>,
174
Daniel Sandersc43cda82014-11-07 16:54:21 +0000175 // All integers are promoted to 64-bit.
176 CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
Akira Hatanakad608bac2012-02-17 02:20:26 +0000177
Daniel Sandersc43cda82014-11-07 16:54:21 +0000178 CCIfType<[f32], CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3]>>,
Akira Hatanaka0b8bc002011-11-14 19:02:54 +0000179
180 CCIfType<[i64, f64], CCAssignToReg<[A0_64, A1_64, A2_64, A3_64,
181 T0_64, T1_64, T2_64, T3_64]>>,
182
Akira Hatanaka0b8bc002011-11-14 19:02:54 +0000183 // All stack parameter slots become 64-bit doublewords and are 8-byte aligned.
Daniel Sandersc43cda82014-11-07 16:54:21 +0000184 CCIfType<[f32], CCAssignToStack<4, 8>>,
Akira Hatanakad608bac2012-02-17 02:20:26 +0000185 CCIfType<[i64, f64], CCAssignToStack<8, 8>>
Akira Hatanaka0b8bc002011-11-14 19:02:54 +0000186]>;
187
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000188def RetCC_MipsN : CallingConv<[
Daniel Sandersb3ca3382014-09-26 10:06:12 +0000189 // f128 needs to be handled similarly to f32 and f64. However, f128 is not
190 // legal and is lowered to i128 which is further lowered to a pair of i64's.
191 // This presents us with a problem for the calling convention since hard-float
192 // still needs to pass them in FPU registers, and soft-float needs to use $v0,
193 // and $a0 instead of the usual $v0, and $v1. We therefore resort to a
194 // pre-analyze (see PreAnalyzeReturnForF128()) step to pass information on
195 // whether the result was originally an f128 into the tablegen-erated code.
196 //
197 // f128 should only occur for the N64 ABI where long double is 128-bit. On
198 // N32, long double is equivalent to double.
Daniel Sandersc8a040c2014-12-08 15:40:09 +0000199 CCIfType<[i64], CCIfOrigArgWasF128<CCDelegateTo<RetCC_F128>>>,
Daniel Sandersb3ca3382014-09-26 10:06:12 +0000200
Daniel Sandersae275e32014-09-25 12:15:05 +0000201 // Aggregate returns are positioned at the lowest address in the slot for
202 // both little and big-endian targets. When passing in registers, this
203 // requires that big-endian targets shift the value into the upper bits.
204 CCIfSubtarget<"isLittle()",
Daniel Sanders19f01652014-10-24 13:09:19 +0000205 CCIfType<[i8, i16, i32, i64], CCIfInReg<CCPromoteToType<i64>>>>,
Daniel Sandersae275e32014-09-25 12:15:05 +0000206 CCIfSubtargetNot<"isLittle()",
Daniel Sandersf815c132014-10-24 14:46:00 +0000207 CCIfType<[i8, i16, i32, i64],
208 CCIfInReg<CCPromoteToUpperBitsInType<i64>>>>,
Daniel Sandersae275e32014-09-25 12:15:05 +0000209
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000210 // i64 are returned in registers V0_64, V1_64
211 CCIfType<[i64], CCAssignToReg<[V0_64, V1_64]>>,
212
213 // f32 are returned in registers F0, F2
214 CCIfType<[f32], CCAssignToReg<[F0, F2]>>,
215
216 // f64 are returned in registers D0, D2
217 CCIfType<[f64], CCAssignToReg<[D0_64, D2_64]>>
218]>;
219
220//===----------------------------------------------------------------------===//
Akira Hatanakaf0273602012-06-13 18:06:00 +0000221// Mips FastCC Calling Convention
222//===----------------------------------------------------------------------===//
223def CC_MipsO32_FastCC : CallingConv<[
224 // f64 arguments are passed in double-precision floating pointer registers.
Daniel Sanders24b65722014-09-10 12:02:27 +0000225 CCIfType<[f64], CCIfSubtargetNot<"isFP64bit()",
226 CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6,
227 D7, D8, D9]>>>,
Sasa Stankovic86ebfe22014-08-22 09:23:22 +0000228 CCIfType<[f64], CCIfSubtarget<"isFP64bit()", CCIfSubtarget<"useOddSPReg()",
Akira Hatanakabfb66242013-08-20 23:38:40 +0000229 CCAssignToReg<[D0_64, D1_64, D2_64, D3_64,
230 D4_64, D5_64, D6_64, D7_64,
231 D8_64, D9_64, D10_64, D11_64,
232 D12_64, D13_64, D14_64, D15_64,
233 D16_64, D17_64, D18_64,
Sasa Stankovic86ebfe22014-08-22 09:23:22 +0000234 D19_64]>>>>,
235 CCIfType<[f64], CCIfSubtarget<"isFP64bit()", CCIfSubtarget<"noOddSPReg()",
236 CCAssignToReg<[D0_64, D2_64, D4_64, D6_64,
237 D8_64, D10_64, D12_64, D14_64,
238 D16_64, D18_64]>>>>,
Akira Hatanakaf0273602012-06-13 18:06:00 +0000239
240 // Stack parameter slots for f64 are 64-bit doublewords and 8-byte aligned.
241 CCIfType<[f64], CCAssignToStack<8, 8>>
242]>;
243
244def CC_MipsN_FastCC : CallingConv<[
245 // Integer arguments are passed in integer registers.
246 CCIfType<[i64], CCAssignToReg<[A0_64, A1_64, A2_64, A3_64, T0_64, T1_64,
247 T2_64, T3_64, T4_64, T5_64, T6_64, T7_64,
248 T8_64, V1_64]>>,
249
250 // f64 arguments are passed in double-precision floating pointer registers.
251 CCIfType<[f64], CCAssignToReg<[D0_64, D1_64, D2_64, D3_64, D4_64, D5_64,
252 D6_64, D7_64, D8_64, D9_64, D10_64, D11_64,
253 D12_64, D13_64, D14_64, D15_64, D16_64, D17_64,
254 D18_64, D19_64]>>,
255
256 // Stack parameter slots for i64 and f64 are 64-bit doublewords and
257 // 8-byte aligned.
258 CCIfType<[i64, f64], CCAssignToStack<8, 8>>
259]>;
260
261def CC_Mips_FastCC : CallingConv<[
262 // Handles byval parameters.
263 CCIfByVal<CCPassByVal<4, 4>>,
264
265 // Promote i8/i16 arguments to i32.
266 CCIfType<[i8, i16], CCPromoteToType<i32>>,
267
268 // Integer arguments are passed in integer registers. All scratch registers,
269 // except for AT, V0 and T9, are available to be used as argument registers.
Daniel Sanders24b65722014-09-10 12:02:27 +0000270 CCIfType<[i32], CCIfSubtargetNot<"isTargetNaCl()",
Sasa Stankovic4c80bda2014-02-07 17:16:40 +0000271 CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, T6, T7, T8, V1]>>>,
272
273 // In NaCl, T6, T7 and T8 are reserved and not available as argument
274 // registers for fastcc. T6 contains the mask for sandboxing control flow
275 // (indirect jumps and calls). T7 contains the mask for sandboxing memory
276 // accesses (loads and stores). T8 contains the thread pointer.
277 CCIfType<[i32], CCIfSubtarget<"isTargetNaCl()",
278 CCAssignToReg<[A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, V1]>>>,
Akira Hatanakaf0273602012-06-13 18:06:00 +0000279
280 // f32 arguments are passed in single-precision floating pointer registers.
Sasa Stankovicf4a9e3b2014-07-29 14:39:24 +0000281 CCIfType<[f32], CCIfSubtarget<"useOddSPReg()",
282 CCAssignToReg<[F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13,
283 F14, F15, F16, F17, F18, F19]>>>,
284
285 // Don't use odd numbered single-precision registers for -mno-odd-spreg.
286 CCIfType<[f32], CCIfSubtarget<"noOddSPReg()",
287 CCAssignToReg<[F0, F2, F4, F6, F8, F10, F12, F14, F16, F18]>>>,
Akira Hatanakaf0273602012-06-13 18:06:00 +0000288
289 // Stack parameter slots for i32 and f32 are 32-bit words and 4-byte aligned.
290 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
291
Akira Hatanakaf0273602012-06-13 18:06:00 +0000292 CCIfSubtarget<"isABI_O32()", CCDelegateTo<CC_MipsO32_FastCC>>,
293 CCDelegateTo<CC_MipsN_FastCC>
294]>;
295
296//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000297// Mips Calling Convention Dispatch
Akira Hatanakae2489122011-04-15 21:51:11 +0000298//===----------------------------------------------------------------------===//
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000299
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000300def RetCC_Mips : CallingConv<[
Akira Hatanakad6af2c62011-09-23 19:08:15 +0000301 CCIfSubtarget<"isABI_N32()", CCDelegateTo<RetCC_MipsN>>,
302 CCIfSubtarget<"isABI_N64()", CCDelegateTo<RetCC_MipsN>>,
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +0000303 CCDelegateTo<RetCC_MipsO32>
304]>;
Akira Hatanaka5350c242012-03-01 22:27:29 +0000305
Daniel Sanders23e98772014-11-02 16:09:29 +0000306def CC_Mips_ByVal : CallingConv<[
307 CCIfSubtarget<"isABI_O32()", CCIfByVal<CCPassByVal<4, 4>>>,
308 CCIfByVal<CCPassByVal<8, 8>>
309]>;
310
Daniel Sanders41a64c42014-11-07 11:10:48 +0000311def CC_Mips16RetHelper : CallingConv<[
312 CCIfByVal<CCDelegateTo<CC_Mips_ByVal>>,
313
314 // Integer arguments are passed in integer registers.
315 CCIfType<[i32], CCAssignToReg<[V0, V1, A0, A1]>>
316]>;
317
Daniel Sandersca80f1a2014-11-01 17:38:22 +0000318def CC_Mips_FixedArg : CallingConv<[
Daniel Sanders41a64c42014-11-07 11:10:48 +0000319 // Mips16 needs special handling on some functions.
320 CCIf<"State.getCallingConv() != CallingConv::Fast",
Daniel Sandersc8a040c2014-12-08 15:40:09 +0000321 CCIfSpecialCallingConv<"Mips16RetHelperConv",
Daniel Sanders41a64c42014-11-07 11:10:48 +0000322 CCDelegateTo<CC_Mips16RetHelper>>>,
323
Daniel Sanders23e98772014-11-02 16:09:29 +0000324 CCIfByVal<CCDelegateTo<CC_Mips_ByVal>>,
325
326 // f128 needs to be handled similarly to f32 and f64 on hard-float. However,
327 // f128 is not legal and is lowered to i128 which is further lowered to a pair
328 // of i64's.
329 // This presents us with a problem for the calling convention since hard-float
330 // still needs to pass them in FPU registers. We therefore resort to a
331 // pre-analyze (see PreAnalyzeFormalArgsForF128()) step to pass information on
332 // whether the argument was originally an f128 into the tablegen-erated code.
333 //
334 // f128 should only occur for the N64 ABI where long double is 128-bit. On
335 // N32, long double is equivalent to double.
336 CCIfType<[i64],
Eric Christophere8ae3e32015-05-07 23:10:21 +0000337 CCIfSubtargetNot<"useSoftFloat()",
Daniel Sandersc8a040c2014-12-08 15:40:09 +0000338 CCIfOrigArgWasF128<CCBitConvertToType<f64>>>>,
Daniel Sanders23e98772014-11-02 16:09:29 +0000339
Daniel Sandersca80f1a2014-11-01 17:38:22 +0000340 CCIfCC<"CallingConv::Fast", CCDelegateTo<CC_Mips_FastCC>>,
341
Daniel Sandersca80f1a2014-11-01 17:38:22 +0000342 CCIfSubtarget<"isABI_O32()", CCDelegateTo<CC_MipsO32_FP>>,
343 CCDelegateTo<CC_MipsN>
344]>;
345
346def CC_Mips_VarArg : CallingConv<[
Daniel Sanders23e98772014-11-02 16:09:29 +0000347 CCIfByVal<CCDelegateTo<CC_Mips_ByVal>>,
348
Daniel Sandersca80f1a2014-11-01 17:38:22 +0000349 CCIfSubtarget<"isABI_O32()", CCDelegateTo<CC_MipsO32_FP>>,
350 CCDelegateTo<CC_MipsN_VarArg>
351]>;
352
Daniel Sanderscfad1e32014-11-07 11:43:49 +0000353def CC_Mips : CallingConv<[
Daniel Sandersc8a040c2014-12-08 15:40:09 +0000354 CCIfVarArg<CCIfArgIsVarArg<CCDelegateTo<CC_Mips_VarArg>>>,
Daniel Sanderscfad1e32014-11-07 11:43:49 +0000355 CCDelegateTo<CC_Mips_FixedArg>
356]>;
357
Akira Hatanaka5350c242012-03-01 22:27:29 +0000358//===----------------------------------------------------------------------===//
359// Callee-saved register lists.
360//===----------------------------------------------------------------------===//
361
362def CSR_SingleFloatOnly : CalleeSavedRegs<(add (sequence "F%u", 31, 20), RA, FP,
363 (sequence "S%u", 7, 0))>;
364
Zoran Jovanovic255d00d2014-07-10 15:36:12 +0000365def CSR_O32_FPXX : CalleeSavedRegs<(add (sequence "D%u", 15, 10), RA, FP,
366 (sequence "S%u", 7, 0))> {
367 let OtherPreserved = (add (decimate (sequence "F%u", 30, 20), 2));
368}
369
Akira Hatanaka5350c242012-03-01 22:27:29 +0000370def CSR_O32 : CalleeSavedRegs<(add (sequence "D%u", 15, 10), RA, FP,
371 (sequence "S%u", 7, 0))>;
372
Zoran Jovanovicf34b4542014-07-10 22:23:30 +0000373def CSR_O32_FP64 :
374 CalleeSavedRegs<(add (decimate (sequence "D%u_64", 30, 20), 2), RA, FP,
375 (sequence "S%u", 7, 0))>;
Akira Hatanakabfb66242013-08-20 23:38:40 +0000376
Daniel Sanders11c0c062014-04-16 10:23:37 +0000377def CSR_N32 : CalleeSavedRegs<(add D20_64, D22_64, D24_64, D26_64, D28_64,
378 D30_64, RA_64, FP_64, GP_64,
Akira Hatanaka5350c242012-03-01 22:27:29 +0000379 (sequence "S%u_64", 7, 0))>;
380
381def CSR_N64 : CalleeSavedRegs<(add (sequence "D%u_64", 31, 24), RA_64, FP_64,
382 GP_64, (sequence "S%u_64", 7, 0))>;
Reed Kotler783c7942013-05-10 22:25:39 +0000383
Jack Carter59817112013-05-16 20:08:49 +0000384def CSR_Mips16RetHelper :
Reed Kotler5c29d632013-12-15 20:49:30 +0000385 CalleeSavedRegs<(add V0, V1, FP,
386 (sequence "A%u", 3, 0), (sequence "S%u", 7, 0),
387 (sequence "D%u", 15, 10))>;
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +0000388
389def CSR_Interrupt_32R6 : CalleeSavedRegs<(add (sequence "A%u", 3, 0),
390 (sequence "S%u", 7, 0),
391 (sequence "V%u", 1, 0),
392 (sequence "T%u", 9, 0),
393 RA, FP, GP, AT)>;
394
395def CSR_Interrupt_32 : CalleeSavedRegs<(add (sequence "A%u", 3, 0),
396 (sequence "S%u", 7, 0),
397 (sequence "V%u", 1, 0),
398 (sequence "T%u", 9, 0),
399 RA, FP, GP, AT, LO0, HI0)>;
400
401def CSR_Interrupt_64R6 : CalleeSavedRegs<(add (sequence "A%u_64", 3, 0),
402 (sequence "V%u_64", 1, 0),
403 (sequence "S%u_64", 7, 0),
404 (sequence "T%u_64", 9, 0),
405 RA_64, FP_64, GP_64, AT_64)>;
406
407def CSR_Interrupt_64 : CalleeSavedRegs<(add (sequence "A%u_64", 3, 0),
408 (sequence "S%u_64", 7, 0),
409 (sequence "T%u_64", 9, 0),
410 (sequence "V%u_64", 1, 0),
411 RA_64, FP_64, GP_64, AT_64,
412 LO0_64, HI0_64)>;