[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] calling conventions

Ok, to sum up :

Caller always push arguments into registers whether they are fixed or variable.
It is the responsibility for the callee to get the variable arguments from
registers and push them in stack when using va_start. Finally, that slow copy
only occurs when using va_start. Not so bad. Besides, if we can count upon just
one 'loadm' to do the transfer, well... i don't really see any objection.

For the case of "open", I need some info :

since there are two forms and in C they share the same name, there must be only
one implementation. So "open" implementation has really three arguments. What
happens when we call "open" with two arguments ? put a default value on the
third argument ?

> > 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

First, the compiler must be able to handle recursive-to-iterative translation.
Not a evidence for all compilers.

Second, there is really cases where compiler cannot translate but a programmer
can (because programmer can use an explicit stack to save only necessary data
during iteration).

So recursive function always requires stack operations but as the callee is in
charge to save what must callee-saved, for n recursive calls, we just save n-1
times callee-saved registers instead of n if caller-saved.

Anyway, for performance, one of two choices : having a great compiler able to
translate recursive functions to iterative functions, or translate by ourselves
recursive functions into iterative functions.

To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/