Re: Patch to remove undefined C code

From: Richard Henderson (rth@twiddle.net)
Date: Tue Oct 17 2000 - 17:52:36 EST


> [Matti Aarnio]
> > > That depends mainly on question: Does your stack grow up or down ?

Actually a combination -- which direction do arguments grow in relation
to stack growth direction, and do you have a stack push instruction.

> [Ben Pfaff]
> > No it doesn't. It depends mainly on whether the ABI for the machine
> > says that arguments are pushed onto the stack in left-to-right or
> > right-to-left order. You could do either on x86, for instance, and
> > it has nothing to do with whether the x86 stack grows up or down.

No, that's only true if your target supports stack pushes.

For instance, gcc on x86/linux will evaluate arguments right-to-left,
since it hopes to push arguments to the stack in that order. But
gcc on sparc will evaluate arguments mostly left-to-right, even though
the arguments are stored on the stack in the same layout as x86.

And actually it's more complicated than that, since I believe that
on most RISC we'll evaluate the arguments that wind up on the stack
first, left-to-right, then the arguments that wind up in registers,
left-to-right.

On Tue, Oct 17, 2000 at 07:42:31AM +0000, Peter Samuelson wrote:
> So, if you choose left-to-right, how do you implement varargs? Keep in
> mind that prototypes are optional. I bet anything your solution is
> slower and more complex than right-to-left, as all known compilers do.

Speak ye little of "all known compilers".

It is possible to implement varargs however you like. Up, down, or
sideways, every direction is used by some target somewhere.

r~
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:12 EST