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