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

Re: [f-cpu] calling conventions



--- Select French Language

Tricheur tu as utilisé Babelfish :) ça se voit à la traduction... tu aurais
quand même pu le relire et modifier quelque partie où vraiment la traduction
est incompréhensible pour un anglais :).

--- Select English Language

It smells Babelfish here :)

----- Original Message -----
From: Thomas Lavergne <thomas.lavergne@laposte.net>
To: f-cpu anglais <f-cpu@seul.org>
Sent: Thursday, June 06, 2002 12:15 AM
Subject: [f-cpu] calling conventions


this is a (bad) translation of a mail I have posted on the french mailing list.

I have just finished reading the new handbook, and overall I have found what I
think, no big news but a versiopn stable (I hope) of the ISA.  There remain
some shells but it is inevitable and will be to correct with the wire of time.

On the other hand when I am at the chapter on the recomandations of
programation for the calling convention I have questions about the intentions
of the people who have choose it.

15 registers on the whole right for the passages of the parameters?  13 for the
donnee 1 for the stack of parameters and 1 for the number of parameters.

After read this section I have made a small script for scann all my source file
and see the average number of parameter used and I obtained approximately 3
parameters (a little more or a little less according to the languages) what I
want to say that there is ten unused register in each functions.

Moreover there is a stack of register for each calls, which want to say that
for calling a function we need 3 stages:
 1/ put the 13 parameters in the registers r1-r13
 2/ push all the registers in r14 and put their number in r15
 3/ make a jmp on the function (address of return in r60)
At my opinion the 2nd stages is very ugly, need to store all the parameters in
memory will impose many accesses in memory which are penalisant, or which will
be found to cache memory and replace more useful donnee in it.

What I propose has the place : first an observation, as well the caller
function as the function to call know at the compile time the number of
parameters.
That is to say N the number of parameters:
 * if n inferior to 13
     r1         : number of parameters
     r2-r(n+1)  : parameters
     r(n+2)-r31 : temporari registers
 * Si n est superieur a 13
     r1         : number of parameters
     r2-r14     : parameters
     r15        : pointer over the parameters list
     r16-r31    : temporari registers

This has the advantage of optimizing the number of register to use according to
the number of parameters, a function which uses 3 parameters will mobilize 4
register for the parameters and will have 27 temporary registers.  In the best
cases, a function which does not have parameters, only one register is to
mobilize and 30 others are available.  In the worst cases, it is has to say
more than 13 parameters, this calling convention is similar to the proposal of
the handbook with only an inversion of register.

In all the cases the register r1 is used (by the number of parameters), it is
thus available to store the value of return of the function.  The number of
parameters was present, same if it is known of the two functions, in order to
be able to possibly make checks.

In the case of more than 13 parameters I don't know if it is useful to put all
the parameters in the list pointed by r15. Indeed to have all the parameters
lists some in very practical, for the function such as [printf] in C or
[format] in Pascal, but I am not sure time to gain in these function is a
superior than time wasted to put in memory parameters which are already in the
registers.

Otherwise, the registers r32 with r59 are register has to preserve and it is to
the called to save them.  It is a good thing because it save only those which
it use. But how save does ?  With my opinion there are 2 methods : use the SRB
or a store, for the SRB I don't know if it is possible of chain about thirty
call of function with as much [srb_save] ? For the second solution I think that
it was interresting to have a register pointing on a memory area reserved for
this save.


This some personal reflexion, I think that is not because we have 64 register
we can waste them.

Thanls

Tom

--
Thomas Lavergne                       "Le vrai rêveur est celui qui rêve
                                       de l'impossible."  (Elsa Triolet)
thomas.lavergne@laposte.net
d-12@laposte.net    ICQ:#137121910     http://assoc.wanadoo.fr/thallium/


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

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