Can a C function return TWO integers in registers on MIPS?

David Daney ddaney@avtrex.com
Sun Aug 31 00:57:00 GMT 2008


Pan ruochen wrote:
> Hi All,
> 
> I'm writing code in C language for MIPS execption handler.
> There is a function which returns two integers. For optimizing
> the performance, I want gcc to generate code where these two integers
> are returned in registers v0 & v1, instead of in memory.
> Can gcc do this?
> 

For the n32 and n64 ABIs, structures that fit in 16 bytes or less are 
returned in V0 and V1 (or f0 and f2 if the struct contains only two 
floating point elements).

For o32 all structs are returned in memory allocated by the caller.

As the other poster mentioned, there are GCC options that change the ABI 
that might help you, but you must be careful as the code will not 
interact well with ABI conforming code.

David Daney



More information about the Gcc-help mailing list