mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
d82ee5e9f8
Summary: The previous version relied on the standard calling convention using std::reverse() to try to force the AVR ABI. But this only works for simple cases, it fails for example with aggregate types. This patch rewrites the calling convention with custom C++ code, that implements the ABI defined in https://gcc.gnu.org/wiki/avr-gcc. To do that it adds a few 16-bit pseudo registers for unaligned argument passing, such as R24R23. For example this function: define void @fun({ i8, i16 } %a) will pass %a.0 in R22 and %a.1 in R24R23. There are no instructions that can use these pseudo registers, so a new register class, DREGSMOVW, is defined to make them apart. Also the ArgCC_AVR_BUILTIN_DIV is no longer necessary, as it is identical to the C++ behavior (actually the clobber list is more strict for __div* functions, but that is currently unimplemented). Reviewers: dylanmckay Subscribers: Gaelan, Sh4rK, indirect, jwagen, efriedma, dsprenkels, hiraditya, Jim, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68524 Patch by Rodrigo Rivas Costa.
42 lines
1.7 KiB
TableGen
42 lines
1.7 KiB
TableGen
//===-- AVRCallingConv.td - Calling Conventions for AVR ----*- tablegen -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// This describes the calling conventions for AVR architecture.
|
|
// Normal functions use a special calling convention, solved in code.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// AVR Return Value Calling Convention
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Special return value calling convention for runtime functions.
|
|
def RetCC_AVR_BUILTIN : CallingConv
|
|
<[
|
|
CCIfType<[i8], CCAssignToReg<[R24,R25]>>,
|
|
CCIfType<[i16], CCAssignToReg<[R23R22, R25R24]>>
|
|
]>;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// AVR Argument Calling Conventions
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// The calling conventions are implemented in custom C++ code
|
|
|
|
// Calling convention for variadic functions.
|
|
def ArgCC_AVR_Vararg : CallingConv
|
|
<[
|
|
// i16 are always passed through the stack with an alignment of 1.
|
|
CCAssignToStack<2, 1>
|
|
]>;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// Callee-saved register lists.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
def CSR_Normal : CalleeSavedRegs<(add R29, R28, (sequence "R%u", 17, 2))>;
|
|
def CSR_Interrupts : CalleeSavedRegs<(add (sequence "R%u", 31, 0))>;
|