This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [MIPS64] Problems when Passing TImode Parameters in EABI



Fu, Chao-Ying wrote:
> Hello,
>
>   I think there is a bug in mips_pass_by_reference when the mips abi
> is EABI to pass TImode parameters.
>
>   


>   The following code is from the mainline GCC "mips.c".
> ---------
> mips_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
>                         enum machine_mode mode, tree type,
>                         bool named ATTRIBUTE_UNUSED)
> {
>   if (mips_abi == ABI_EABI)
>     {
>       int size;
>
>       /* ??? How should SCmode be handled?  */
>       if (type == NULL_TREE || mode == DImode || mode == DFmode)
>         return 0;
>
>       size = int_size_in_bytes (type);
>       return size == -1 || size > UNITS_PER_WORD;
>     }
>   else
>     {
>       /* If we have a variable-sized parameter, we have no choice.  */
>       return targetm.calls.must_pass_in_stack (mode, type);
>     }
> }
> ---------
>   When "type" is NULL_TREE, this function returns "0".  But when "type" is not NULL and
> the size of TImode is bigger than UNITS_PER_WORD, so it returns "1".
> This causes inconsistency in the following test.
>
> # cat timode.c
> typedef int TItype __attribute__ ((mode (TI)));
> TItype test1 (TItype a)
> {
>   return a*a;
> }
>
> # mipsisa64-elf-gcc -S timode.c -O3
>
> ### timiode.s  
> test1:
>         daddiu  $sp,$sp,-8
>         sd      $31,0($sp)
>         ld      $3,8($4) <----- Parameter in stack
>         ld      $2,0($4) <----- Parameter in stack
>         move    $7,$3  <---- Parameter in register
>         move    $4,$2  <---- Parameter in register
>         move    $5,$3  <---- Parameter in register
>         jal     __multi3
>         move    $6,$2  <---- Parameter in register
>
>         ld      $31,0($sp)
>         move    $4,$2
>         move    $2,$4
>         j       $31
>         daddiu  $sp,$sp,8
>
>   Does someone know how to pass TImode parameters in EABI?  Thanks!
>   

Hi Chao-ying

MIPS ABIs do not usually document the behaviour of 128 bit scalars,
since such types are not defined by most language standards, and are
typically only available via compiler-specific extensions. So if TImode
arguments  work correctly on any ABI, then I would guess that it might
be more by luck than design! EABI is one of the more sketchily specified
MIPS ABIs -- the 64-bit variant probably even more so.

You could fix the mips.c back-end to handle TImode consistently for EABI
and post those changes to the appropriate list for comment. But I wonder
if you really need to use EABI, or are only using it because it's the
default for a mipsisa64-elf configuration. If the latter is true, then
you could try using the N32 ABI and see if that works better for you
(i.e. use the --with-abi=n32 argument when configuring your toolchain).
FWIW our own gcc-3.4 mips-sde-elf configurations default to using N32
for 64-bit ISAs, though we've not yet tested that on gcc-4.

Nigel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]