xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/AVR/AVRCallingConv.td (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric//===-- AVRCallingConv.td - Calling Conventions for AVR ----*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric// This describes the calling conventions for AVR architecture.
95ffd83dbSDimitry Andric// Normal functions use a special calling convention, solved in code.
100b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
110b57cec5SDimitry Andric
120b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric// AVR Return Value Calling Convention
140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
150b57cec5SDimitry Andric
160b57cec5SDimitry Andric// Special return value calling convention for runtime functions.
17349cc55cSDimitry Andricdef RetCC_AVR_BUILTIN : CallingConv<[
180b57cec5SDimitry Andric  CCIfType<[i8], CCAssignToReg<[R24, R25]>>,
190b57cec5SDimitry Andric  CCIfType<[i16], CCAssignToReg<[R23R22, R25R24]>>
200b57cec5SDimitry Andric]>;
210b57cec5SDimitry Andric
220b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
230b57cec5SDimitry Andric// AVR Argument Calling Conventions
240b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
250b57cec5SDimitry Andric
260b57cec5SDimitry Andric// The calling conventions are implemented in custom C++ code
270b57cec5SDimitry Andric
280b57cec5SDimitry Andric// Calling convention for variadic functions.
29349cc55cSDimitry Andricdef ArgCC_AVR_Vararg : CallingConv<[
302a66634dSDimitry Andric  // i8 are always passed through the stack with a byte slot and byte alignment.
312a66634dSDimitry Andric  CCIfType<[i8], CCAssignToStack<1, 1>>,
320b57cec5SDimitry Andric  // i16 are always passed through the stack with an alignment of 1.
330b57cec5SDimitry Andric  CCAssignToStack<2, 1>
340b57cec5SDimitry Andric]>;
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
370b57cec5SDimitry Andric// Callee-saved register lists.
380b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
390b57cec5SDimitry Andric
400b57cec5SDimitry Andricdef CSR_Normal : CalleeSavedRegs<(add R29, R28, (sequence "R%u", 17, 2))>;
41*81ad6265SDimitry Andricdef CSR_NormalTiny : CalleeSavedRegs<(add R29, R28, R19, R18)>;
4204eeddc0SDimitry Andricdef CSR_Interrupts : CalleeSavedRegs<(add(sequence "R%u", 31, 2))>;
43*81ad6265SDimitry Andricdef CSR_InterruptsTiny : CalleeSavedRegs<(add(sequence "R%u", 31, 18))>;
44