varargs target handling
Jim Wilson
wilson@codesourcery.com
Mon May 11 18:14:00 GMT 2009
Iceman wrote:
> Question. Am I doing it wrong? If yes, what are my best options to tackle this problem?
> If not, how can I implement the logic above in practical terms?
> Thank you,
stdarg (varargs is obsolete by the way) can be done this way. There are
a number of examples you can look at. See for instance the mips and
rs6000 ports.
Alternatively, you can choose to use a simpler ABI for stdarg functions.
You can choose to put all unnamed 64-bit arguments into the 32-bit
registers, then you only have one register set to save and scan through.
This does require that a stdarg function always have a prototype in
scope when you call it, but the C standard has required that since 1989,
so it shouldn't be a problem. Many targets implement stdarg this way.
See for instance the mips and rs6000 ports, which use this scheme for
some ABIs, and the more complicated scheme above for other ABIs.
Jim
More information about the Gcc
mailing list