1//=- SystemZCallingConv.td - Calling conventions for SystemZ -*- tablegen -*-=//
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 the SystemZ ABI.
10//===----------------------------------------------------------------------===//
11
12class CCIfExtend<CCAction A>
13  : CCIf<"ArgFlags.isSExt() || ArgFlags.isZExt()", A>;
14
15//===----------------------------------------------------------------------===//
16// z/Linux return value calling convention
17//===----------------------------------------------------------------------===//
18def RetCC_SystemZ : CallingConv<[
19  // Promote i32 to i64 if it has an explicit extension type.
20  CCIfType<[i32], CCIfExtend<CCPromoteToType<i64>>>,
21
22  // ABI-compliant code returns 64-bit integers in R2.  Make the other
23  // call-clobbered argument registers available for code that doesn't
24  // care about the ABI.  (R6 is an argument register too, but is
25  // call-saved and therefore not suitable for return values.)
26  CCIfType<[i32], CCAssignToReg<[R2L, R3L, R4L, R5L]>>,
27  CCIfType<[i64], CCAssignToReg<[R2D, R3D, R4D, R5D]>>,
28
29  // ABI-complaint code returns float and double in F0.  Make the
30  // other floating-point argument registers available for code that
31  // doesn't care about the ABI.  All floating-point argument registers
32  // are call-clobbered, so we can use all of them here.
33  CCIfType<[f32], CCAssignToReg<[F0S, F2S, F4S, F6S]>>,
34  CCIfType<[f64], CCAssignToReg<[F0D, F2D, F4D, F6D]>>
35
36  // ABI-compliant code returns long double by reference, but that conversion
37  // is left to higher-level code.  Perhaps we could add an f128 definition
38  // here for code that doesn't care about the ABI?
39]>;
40
41//===----------------------------------------------------------------------===//
42// z/Linux argument calling conventions
43//===----------------------------------------------------------------------===//
44def CC_SystemZ : CallingConv<[
45  // Promote i32 to i64 if it has an explicit extension type.
46  // The convention is that true integer arguments that are smaller
47  // than 64 bits should be marked as extended, but structures that
48  // are smaller than 64 bits shouldn't.
49  CCIfType<[i32], CCIfExtend<CCPromoteToType<i64>>>,
50
51  // Force long double values to the stack and pass i64 pointers to them.
52  CCIfType<[f128], CCPassIndirect<i64>>,
53
54  // The first 5 integer arguments are passed in R2-R6.  Note that R6
55  // is call-saved.
56  CCIfType<[i32], CCAssignToReg<[R2L, R3L, R4L, R5L, R6L]>>,
57  CCIfType<[i64], CCAssignToReg<[R2D, R3D, R4D, R5D, R6D]>>,
58
59  // The first 4 float and double arguments are passed in even registers F0-F6.
60  CCIfType<[f32], CCAssignToReg<[F0S, F2S, F4S, F6S]>>,
61  CCIfType<[f64], CCAssignToReg<[F0D, F2D, F4D, F6D]>>,
62
63  // Other arguments are passed in 8-byte-aligned 8-byte stack slots.
64  CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>
65]>;
66
67//===----------------------------------------------------------------------===//
68// z/Linux callee-saved registers
69//===----------------------------------------------------------------------===//
70def CSR_SystemZ : CalleeSavedRegs<(add (sequence "R%dD", 6, 15),
71                                       (sequence "F%dD", 8, 15))>;
72