Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!rutgers!iuvax!pur-ee!hankd From: hankd@pur-ee.UUCP (Hank Dietz) Newsgroups: comp.arch Subject: Re: register save/restore Summary: Save what you need, restore when you need . Message-ID: <9663@pur-ee.UUCP> Date: 4 Nov 88 17:29:26 GMT References: <3300037@m.cs.uiuc.edu> <5938@killer.DALLAS.TX.US> <1009@l.cc.purdue.edu> Organization: Purdue University Engineering Computer Network Lines: 24 In article <1009@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: > In article <7580@aw.sei.cmu.edu>, firth@sei.cmu.edu (Robert Firth) writes: ...[stuff ommitted]... > > Which is better - caller saves or callee saves? > > > > > > A. Is this the right question? > > It is, if library subroutines are to be used. A compiler cannot change > the procedure to be followed in this case. ...[much more stuff ommitted]... This is actually a prime argument for caller saves. The reason is simple: the compiler optimizations, if constrained to be performed without changing the code of the called (library) routine, can only be applied in the caller. Hence, you want to do as much of the call processing as possible in the caller, because that's the only way you have a shot at optimizing it. It turns out that this is actually near optimal, because even though the compiler can't change the code inside called (library) routines, the compiler can access summary information specifying things like which registers are actually used in the called routine... essentially the "right" way to do it. -hankd@ee.ecn.purdue.edu