Path: utzoo!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcsun!tuvie!mike From: mike@vlsivie.tuwien.ac.at (Michael K. Gschwind) Newsgroups: comp.arch Subject: Re: register save Message-ID: <2376@tuvie.UUCP> Date: 13 Mar 91 08:33:20 GMT References: <1991Mar11.192116.1974@dgbt.doc.ca> Sender: news@tuvie.UUCP Organization: Vienna University of Technology Lines: 38 In article <1991Mar11.192116.1974@dgbt.doc.ca> don@dgbt.doc.ca (Donald McLachlan) writes: > > The idea of saving the return address in a register, rather than >on the stack sounds nice to me, but ... It is nice AND saves a lot of cycles ... > > This requires that the calling function knows that the called >function is a leaf function, not very practical from a high level language >point of view as far as I can tell. Simply not true. As you yourself explain later. > A further optimisation I could see for this is any function that >performs a call could save the "return register" on the stack once at >invocation, and restore it prior to returning. (gee isn't this what is done >now:-) Exactly. > > Now that all the mechanics are out of the way (the way I see them) >only one question remains. HOW MUCH DOES THIS ACTUALLY SAVE??? >I interpret this as ... What is the ratio of calls to "leaf functions" >versus calls to "non-leaf functions"? Dynamically, about 50% of all functions called are leaf-functions. Assuming you save 2 memory accesses AND 2 stack manipulations, this is a quite interesting optimization. Also, the CALL instruction becomes much simpler. Just move the PC to some register and some register to the PC. - No stack handling involved. Everything is much smoother (and simpler to design - read my thesis ;-) bye, mike Michael K. Gschwind, Dept. of VLSI-Design, Vienna University of Technology mike@vlsivie.tuwien.ac.at 1-2-3-4 kick the lawsuits out the door mike@vlsivie.uucp 5-6-7-8 innovate don't litigate e182202@awituw01.bitnet 9-A-B-C interfaces should be free Voice: (++43).1.58801 8144 D-E-F-O look and feel has got to go! Fax: (++43).1.569697