https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102024

--- Comment #28 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #27)
> (In reply to Jakub Jelinek from comment #23)
> 
> > struct A { double a; int : 0; double b; };
> 
> For MIPS I've done some experiment with this and the result (with N64 ABI)
> is:
> 
> With GCC trunk, G++ trunk, and GCC 11.2: argument passed via FPR $f12 and
> GPR $5,
> returned via GPR $2 and $3

Ah, indeed.
The
              for (; field; field = DECL_CHAIN (field))
                if (TREE_CODE (field) == FIELD_DECL
                    && int_bit_position (field) >= bitpos)
                  break;
loop will simply stop on the first field with bitpos equal or greater than
bitpos, so the zero sized bit-fields (and generally any other zero sized fields
like struct S {} s; in GNU C) will be treated as being part of the next slot.
So in struct B { int : 0; double a, b; }; it will go into GPR and FPR,
while struct C { double a; int : 0; double b; }; into FPR and GPR, and
struct D { double a, b; int : 0; } into FPR & FPR.

> With G++ 11.2: argument passed via FPR $f12 and $f13, returned via FPR $f0
> and $f2
> 
> So I guess we need -Wpsabi for both mips_function_arg and
> mips_fpr_return_fields.

Is there somebody who can clarify the MIPS ABI intent?
Also, what does LLVM do?

Reply via email to