Path: utzoo!attcan!uunet!samsung!brutus.cs.uiuc.edu!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ron Guilmette) Newsgroups: comp.sys.m88k Subject: Register Allocation (was Re: Info about 88open & standards) Message-ID: <1989Nov16.212149.9770@paris.ics.uci.edu> Date: 17 Nov 89 05:21:49 GMT References: <1948@psueea.UUCP> <1989Nov14.175806.23483@paris.ics.uci.edu> <5063@tekcrl.LABS.TEK.COM> <2631@yogi.oakhill.UUCP> Reply-To: Ron Guilmette Organization: University of California, Irvine - Dept of ICS Lines: 62 In article <2631@yogi.oakhill.UUCP> marvin@yogi.UUCP (Marvin Denman) writes: > >In article pfeiffer@nmsu.edu (Joe Pfeiffer) writes: >> >>This is probably getting a bit far afield, but I'm very puzzled by >>this statement. It has always been my impression that it doesn't much >>matter whether the registers are preserved by the caller or the >>callee, just so somebody does it. Why is there a greater burden on >>the compiler writer if it's the callee? >> >>-Joe Pfeiffer. > > >The answer probably lies in the fact that many leaf calls will not require >enough registers that they need to save anything if they know which registers >are guaranteed to be "dead". Of course, but the leaf routines never do know which ones are dead, do they? >These [leaf routines] are by frequency a large percentage of >calls so they should not be penalized. Using the current standard a leaf >routine can use all of the temporary set of registers plus all of the >parameter passing registers without any saving. Why should the caller save >"all" of his live registers when only a small fraction will be used? My original question was "Why should the caller save *any* of his live registers when he has absolutely no knowledge of whether or not *any* of them will be used (i.e. clobbered) in the called routine?" I don't think that I have yet seen a good answer to this question. >The converse argument is why should the callee be required to save dead >registers? What if there are *never* any dead registers? Consider this. Given the typical program (which uses at least 30 or more "values" throughout its execution lifetime) it may be possible to use *all* available registers for at least *some* productive purpose at *all* points throughout a program. Even without having global data-flow information, at the very least you could decide to keep several simple global variables in registers, and the odds are very good that you would get at least some performance increase as a result of doing this. On the other hand, if you *do* have good global data flow analysis, then there is no doubt whatsoever that you should be able to use all registers for "live" values at all points throughout a program. Thus, you should always have registers filled with live values (in any case). Thus, you should always have a "pure" caller-saves convention. QED >The current scheme is a fairly efficient compromise between the two, that will >do in the absence of global register allocation. Ah, ha! So if I understand you correctly, you are saying that this parameter passing convention was intentionally designed to be a "compromise" which would not make stupid compilers look too bad (even at the expense of decreasing performance in the presence of a good modern compiler with data-flow analysis). Is that correct? // rfg