arguments in registers

Davidsen davidsen at steinmetz.UUCP
Thu May 15 03:11:37 AEST 1986


In article <109 at ima.UUCP> johnl at ima.UUCP (John R. Levine) writes:
>In article <1205 at umcp-cs.UUCP> chris at maryland.UUCP (Chris Torek) writes:
>>In article <155 at cbmvax.cbm.UUCP> grr at cbmvax.UUCP (George Robbins) writes:
>>>[Passing arguments in registers] would be fine if C had nested
>>>procedures or inlines or something, but a disaster otherwise.
>>

The original "B" compiler for the GECOS operating system passed the first
two arguments in registers and it worked fine. There are no inherent
limitations, and it makes the code run much faster.

Someone doing software metrics told me that 90% of the procedure calls in
UNIX source code use <3 arguments, and running over about 50k lines of
code by people at our site it looks as if that's true, even more so if you
eliminate printf, which hopefully isn't called as often as the internal
routines.

There are three cases of action if the first N arguments are passed in
registers:
 a) the values are never stored in memory and the procedure runs faster.
 b) the values are stored in memory when needed to preserve them during a
procedure call, or when the registers are required for inline code.
 c) the compiler just stores the value in memory (stack of course) and
goes on as if the calling program had done it.

Note that in the worst case, the code to save the values has been moved
from the calling routines to the called routine, making the code smaller,
if not faster.

In 1972 I produced a language called IMP from the original B, and it ran
on the GE 600 series and the INtel 8080 (and could cross compile in either
direction). If it can be done on an 8080, it can be done anywhere. The
code was smaller and faster than that produced by any C compiler I've ever
seen for the 8080, due in part to the frequent occurence of case (a)
above, where the values were never stored.
-- 
	-bill davidsen

	seismo!rochester!steinmetz!--\
       /                               \
ihnp4!              unirot ------------->---> crdos1!davidsen
       \                               /
        chinet! ---------------------/        (davidsen at ge-crd.ARPA)

"Stupidity, like virtue, is its own reward"



More information about the Comp.lang.c mailing list