[all-commits] [llvm/llvm-project] b9c26a: [AVR] Rewrite the function calling convention.

Dylan McKay via All-commits all-commits at lists.llvm.org
Tue Jun 23 02:37:04 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b9c26a9cfe53da7ef96e13ef1aa7fe793b1b5d28
      https://github.com/llvm/llvm-project/commit/b9c26a9cfe53da7ef96e13ef1aa7fe793b1b5d28
  Author: Dylan McKay <me at dylanmckay.io>
  Date:   2020-06-23 (Tue, 23 Jun 2020)

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

  Log Message:
  -----------
  [AVR] Rewrite the function calling convention.

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.




More information about the All-commits mailing list