[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [f-cpu] calling conventions
On Thu, Jun 06, 2002 at 07:23:52PM -0600, Ben Franchuk wrote:
> Michael Riepe wrote:
>
> > Varargs calls may be rare compared to the total number of system calls,
> > but they're present in almost any C program. That does not mean that we
> > have to find an efficient way to do varargs functions. As I said before,
> > I want the `regular' (fixed-args) functions to be as fast as possible.
>
> Recursive function calls require stack operations too. Other than inline
> macros to hint at function call parameters fixed arg functions still are
> better using off the stack in my view.
Not really. First of all, a lot of recursive function calls can be
automatically translated to iterative code. A `tail-recursive' call like
int
blah(int x, int y) {
...
return blah(x + 1, y - 1);
}
will be translated to a simple loop:
int
blah(int x, int y) {
for (;;) {
...
x++;
y--;
}
}
The rest of the recursive calls will have to save the arguments that
are still in use *after* the call. That is,
int
blah(int x, int y) {
...
x = blah(y - 1, x + 1);
...
}
will have to keep a copy of `y' somewhere (but not of `x').
A function that calls any other function will *always* have to save
its arguments somewhere else if it needs them after the call (because
the argument registers are call-clobbered).
--
Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
"All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu in the body. http://f-cpu.seul.org/