blob: 68dbce02706ff6c790b9f39222cef4817f2e2b56 [file] [log] [blame]
Dylan McKayf061e9b2015-12-20 23:17:44 +00001//===-- AVRCallingConv.td - Calling Conventions for AVR ----*- 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 AVR architecture.
10//===----------------------------------------------------------------------===//
11
12//===----------------------------------------------------------------------===//
13// AVR Return Value Calling Convention
14//===----------------------------------------------------------------------===//
15
16def RetCC_AVR : CallingConv
17<[
18 // i8 is returned in R24.
19 CCIfType<[i8], CCAssignToReg<[R24]>>,
20
21 // i16 are returned in R25:R24, R23:R22, R21:R20 and R19:R18.
22 CCIfType<[i16], CCAssignToReg<[R25R24, R23R22, R21R20, R19R18]>>
23]>;
24
25// Special return value calling convention for runtime functions.
Dylan McKay1f69cdb2016-09-28 16:04:40 +000026def RetCC_AVR_BUILTIN : CallingConv
Dylan McKayf061e9b2015-12-20 23:17:44 +000027<[
28 CCIfType<[i8], CCAssignToReg<[R24,R25]>>,
29 CCIfType<[i16], CCAssignToReg<[R23R22, R25R24]>>
30]>;
31
32//===----------------------------------------------------------------------===//
33// AVR Argument Calling Conventions
34//===----------------------------------------------------------------------===//
35
36// The calling conventions are implemented in custom C++ code
37
38// Calling convention for variadic functions.
39def ArgCC_AVR_Vararg : CallingConv
40<[
41 // i16 are always passed through the stack with an alignment of 1.
42 CCAssignToStack<2, 1>
43]>;
44
45// Special argument calling convention for
Dylan McKayf061e9b2015-12-20 23:17:44 +000046// division runtime functions.
Dylan McKay1f69cdb2016-09-28 16:04:40 +000047def ArgCC_AVR_BUILTIN_DIV : CallingConv
Dylan McKayf061e9b2015-12-20 23:17:44 +000048<[
49 CCIfType<[i8], CCAssignToReg<[R24,R22]>>,
50 CCIfType<[i16], CCAssignToReg<[R25R24, R23R22]>>
51]>;
52
53//===----------------------------------------------------------------------===//
54// Callee-saved register lists.
55//===----------------------------------------------------------------------===//
56
57def CSR_Normal : CalleeSavedRegs<(add R29, R28, (sequence "R%u", 17, 2))>;
58def CSR_Interrupts : CalleeSavedRegs<(add (sequence "R%u", 31, 0))>;