[PATCH] D40023: [RISCV] Implement ABI lowering

David Majnemer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 23 00:57:33 PST 2017


majnemer added a comment.

In https://reviews.llvm.org/D40023#933466, @asb wrote:

> In https://reviews.llvm.org/D40023#933464, @majnemer wrote:
>
> > So how does something like the following work:
> >
> >   union U { float f; int i; };
> >   void f(union U u);
> >   
> >
> > The flattening described in https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#hardware-floating-point-calling-convention makes sense for arrays and structs but I couldn't find where unions were described.
>
>
> You're right that's not currently described - I have an issue tracking this here: https://github.com/riscv/riscv-elf-psabi-doc/issues/24. Last time I tried to check gcc behaviour it seemed that such cases would be passed according to the integer calling convention, but I'd be happier if one of the GCC devs would confirm.


Should we have a test which tries to make sure our behavior matches GCC's? ISTM that floats in unions are always in GPRs (at least according to abicop).

How are empty unions/arrays handled? Like a function which takes no args? abicop seemed upset when I asked it:

  >>> m.call([Union()])
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "~/majnemer/abicop/rvcc.py", line 186, in __init__
      self.alignment = max(m.alignment for m in members)
  ValueError: max() arg is an empty sequence

It'd also be good to have a test for bool and tests for bitfields. Am I correct that struct S { int x : 2; int y : 2; }; would get passed in two GPRs which were sign extended from 2 to 32?


https://reviews.llvm.org/D40023





More information about the cfe-commits mailing list