I found that clang's implementation of regparm doesn't match gcc's
when the argument is a struct. Clang just skips the struct, gcc splits
it in 32 bit chunks that are passed in registers. Not too different
from the x86-64 abi.

In a bit more detail, it looks like gcc does the following:

* Arguments of type float, double, {float} and {double} are classified as
Float, and every other argument type is classified as Integer.
* Float arguments are passed on the stack and don't consume registers.
* If an integer argument fits completely in the remaining registers, it is
passed in registers, otherwise it goes to the stack.
* Integer arguments consume registers even if they don't fit, so once an
argument goes to the stack every other argument goes to the stack.
* A struct return is still done indirectly, but the pointer is passed
as the first argument in registers.

This patch implements this. Note that it depends on the patch I just
posted to the llvm list.

Cheers,
Rafael

Attachment: t.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to