HP-UX IA64 structure passing patch

Jim Wilson wilson@cygnus.com
Wed Nov 28 17:59:00 GMT 2001


In article < 200111282104.NAA05717@hpsje.cup.hp.com > you write:
>This patch changes how small structures are passed for HP-UX on the IA64
>platform.  This system does not use "standard" big-endian parameter
>passing for small structures passed in registers.  Instead, structures
>are left-aligned, unlike integral values which are right aligned as one
>would expect.

The argument/return stuff is a mess.  The Irix6 N32/N64 ABIs have a similar
convention, and I never managed to get it right when I worked on that target
5 years or so ago.  I suspect I would have more luck nowadays, but this is
still going to be a little tricky.

A few things you may not have considered...
1) What about varargs/stdarg functions?  Do they know that sub-word structures
   are left-aligned?  You probably need to modify the ia64_va_arg function
   in the config/ia64/ia64.c file.
2) What about structures on the stack?  If there are 8 or more words of
   arguments before the sub-word structure, it will end up being passed on the
   stack.  Presumably this also needs to be left aligned, but I doubt that
   your patch handles this.  There is a macro FUNCTION_ARG_PADDING that you
   can set to control this.  See the config/mips/abi64.h file for instance.
   There may be some other macros you need to set to get this right.

There is a possible alternative solution to your patch.  Instead of modifying
the existing argument/return code, you can use a PARALLEL.  This takes you into
the emit_group_{load,store} code, which by default does left alignment for big
endian targets and right-alignment for little endian targets.  We should not
assume that this is correct, but at least it is the assumption that you need.
So if you modify FUNCTION_ARG and FUNCTION_VALUE to use a PARALLEL for
subword structures, then you should get the right alignment without needing
to modify any machine independent code.  You still need to fix the other two
things I mentioned above though.

Long term, I think the argument/return stuff needs a rewrite.  Currently
we have lots of different macros that control argument passing/return, which
all interact in different confusing ways.  It might be better to have the
middle end pass all of the arguments to target dependent code, and have the
target dependent code pass back a structure detailing where they all go.
This is essentially what the PARALLEL stuff does now, except it only
handles one argument at a time, and it doesn't support all possible arguments.
For instance, there is no way to specify aligment for sub-word structures.

Jim



More information about the Gcc-patches mailing list