Dylan McKay | f061e9b | 2015-12-20 23:17:44 +0000 | [diff] [blame^] | 1 | //===-- 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 | |
| 16 | def 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. |
| 26 | def RetCC_AVR_RT : CallingConv |
| 27 | <[ |
| 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. |
| 39 | def 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 |
| 46 | // multiplication runtime functions. |
| 47 | def ArgCC_AVR_RT_MUL : CallingConv |
| 48 | <[ |
| 49 | CCIfType<[i16], CCAssignToReg<[R27R26,R19R18]>> |
| 50 | ]>; |
| 51 | |
| 52 | // Special argument calling convention for |
| 53 | // division runtime functions. |
| 54 | def ArgCC_AVR_RT_DIV : CallingConv |
| 55 | <[ |
| 56 | CCIfType<[i8], CCAssignToReg<[R24,R22]>>, |
| 57 | CCIfType<[i16], CCAssignToReg<[R25R24, R23R22]>> |
| 58 | ]>; |
| 59 | |
| 60 | //===----------------------------------------------------------------------===// |
| 61 | // Callee-saved register lists. |
| 62 | //===----------------------------------------------------------------------===// |
| 63 | |
| 64 | def CSR_Normal : CalleeSavedRegs<(add R29, R28, (sequence "R%u", 17, 2))>; |
| 65 | def CSR_Interrupts : CalleeSavedRegs<(add (sequence "R%u", 31, 0))>; |