[PATCH] D68524: [AVR] Rewrite the function calling convention.

Rodrigo Rivas Costa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 16:19:23 PDT 2019


rodrigorc created this revision.
rodrigorc added a reviewer: dylanmckay.
rodrigorc added a project: LLVM.
Herald added subscribers: llvm-commits, Jim.

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).


Repository:
  rL LLVM

https://reviews.llvm.org/D68524

Files:
  lib/Target/AVR/AVRCallingConv.td
  lib/Target/AVR/AVRISelLowering.cpp
  lib/Target/AVR/AVRISelLowering.h
  lib/Target/AVR/AVRInstrInfo.cpp
  lib/Target/AVR/AVRRegisterInfo.td
  test/CodeGen/AVR/calling-conv/c/basic_aggr.ll
  test/CodeGen/AVR/calling-conv/c/call.ll
  test/CodeGen/AVR/calling-conv/c/call_aggr.ll
  test/CodeGen/AVR/calling-conv/c/return_aggr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68524.223333.patch
Type: text/x-patch
Size: 30401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/3b1641ce/attachment.bin>


More information about the llvm-commits mailing list