1//===- LanaiCallingConv.td - Calling Conventions Lanai -------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This describes the calling conventions for the Lanai architectures.
10//
11//===----------------------------------------------------------------------===//
12
13//===----------------------------------------------------------------------===//
14// Return Value Calling Conventions
15//===----------------------------------------------------------------------===//
16
17// Lanai 32-bit C Calling convention.
18def CC_Lanai32 : CallingConv<[
19  // Promote i8/i16 args to i32
20  CCIfType<[i8, i16], CCPromoteToType<i32>>,
21
22  // Put argument in registers if marked 'inreg' and not a vararg call.
23  CCIfNotVarArg<CCIfInReg<CCIfType<[i32],
24                                   CCAssignToReg<[R6, R7, R18, R19]>>>>,
25
26  // Otherwise they are assigned to the stack in 4-byte aligned units.
27  CCAssignToStack<4, 4>
28]>;
29
30// Lanai 32-bit Fast Calling convention.
31def CC_Lanai32_Fast : CallingConv<[
32  // Promote i8/i16 args to i32
33  CCIfType<[ i8, i16 ], CCPromoteToType<i32>>,
34
35  // Put arguments in registers.
36  CCIfNotVarArg<CCIfType<[i32], CCAssignToReg<[ R6, R7, R18, R19 ]>>>,
37
38  // Otherwise they are assigned to the stack in 4-byte aligned units.
39  CCAssignToStack<4, 4>
40]>;
41
42// Lanai 32-bit C return-value convention.
43def RetCC_Lanai32 : CallingConv<[
44  // Specify two registers to allow returning 64-bit results that have already
45  // been lowered to 2 32-bit values.
46  CCIfType<[i32], CCAssignToReg<[RV, R9]>>
47]>;
48
49def CSR: CalleeSavedRegs<(add)>;
50