xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/AVR/AVRCallingConv.td (revision 716fd348e01c5f2ba125f878a634a753436c2994)
1//===-- AVRCallingConv.td - Calling Conventions for AVR ----*- 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// This describes the calling conventions for AVR architecture.
9// Normal functions use a special calling convention, solved in code.
10//===----------------------------------------------------------------------===//
11
12//===----------------------------------------------------------------------===//
13// AVR Return Value Calling Convention
14//===----------------------------------------------------------------------===//
15
16// Special return value calling convention for runtime functions.
17def RetCC_AVR_BUILTIN : CallingConv<[
18  CCIfType<[i8], CCAssignToReg<[R24, R25]>>,
19  CCIfType<[i16], CCAssignToReg<[R23R22, R25R24]>>
20]>;
21
22//===----------------------------------------------------------------------===//
23// AVR Argument Calling Conventions
24//===----------------------------------------------------------------------===//
25
26// The calling conventions are implemented in custom C++ code
27
28// Calling convention for variadic functions.
29def ArgCC_AVR_Vararg : CallingConv<[
30  // i16 are always passed through the stack with an alignment of 1.
31  CCAssignToStack<2, 1>
32]>;
33
34//===----------------------------------------------------------------------===//
35// Callee-saved register lists.
36//===----------------------------------------------------------------------===//
37
38def CSR_Normal : CalleeSavedRegs<(add R29, R28, (sequence "R%u", 17, 2))>;
39def CSR_Interrupts : CalleeSavedRegs<(add(sequence "R%u", 31, 2))>;
40