Re: Caller/Callee saved Registers

pdp8@ai.mit.edu (John McClain)
Thu, 24 Mar 1994 14:58:11 GMT

          From comp.compilers

Related articles
[5 earlier articles]
Re: Caller/Callee saved Registers paulb@travis.csd.harris.com (1994-03-22)
Re: Caller/Callee saved Registers cliffc@noel.cs.rice.edu (1994-03-22)
Re: Caller/Callee saved Registers alk@et.msc.edu (1994-03-23)
Re: Caller/Callee saved Registers bart@cs.uoregon.edu (1994-03-23)
Re: Caller/Callee saved Registers robertsw@agcs.com (1994-03-23)
Re: Caller/Callee saved Registers Peter-Lawrence.Montgomery@cwi.nl (1994-03-24)
Re: Caller/Callee saved Registers pdp8@ai.mit.edu (1994-03-24)
Re: Caller/Callee saved Registers ghiya@flo.cs.mcgill.ca (1994-03-24)
Re: Caller/Callee saved Registers paulb@travis.csd.harris.com (1994-03-24)
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-24)
Re: Caller/Callee saved Registers bart@cs.uoregon.edu (1994-03-25)
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-25)
Re: Caller/Callee saved Registers pardo@cs.washington.edu (1994-03-25)
[18 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: pdp8@ai.mit.edu (John McClain)
Keywords: registers, optimize
Organization: MIT AI Lab
References: 94-03-054 94-03-106
Date: Thu, 24 Mar 1994 14:58:11 GMT

bart@cs.uoregon.edu (Barton Christopher Massey) writes:


      One additional point about caller vs. callee save which I'm surprised no
      one has mentioned: callee-save makes it rather more difficult to implement
      tail-call optimization. Recall that full tail-call (as opposed to mere
      self tail-recursion) optimization avoids saving any state (including a
      return address) whenever the last instruction in a procedure is a call
      to another procedure.


Callee-save does not make tail-call optimization more difficult. The
procedure making the tail-call needs to first get rid of everything it put
on the stack (in the process restoring any of the callee-save registers it
used.) This is what makes it a properly tail recursive call. The called
procedure can do anything with the stack it wants. Would you say an
implementation was not properly tail recursive if some procedure that was
tail-called temporarily spilled some registers to the stack? The
situation with callee save registers is analogous.


      This is a very valuable optimization for recursive programs...


It does not mater so much for recursive programs, if they are
tail-recursive then for most people, most of the time it is just as easy
to use/read a for/while/until loop. The lack of tail-call optimization
really hurts if you want to use a continuation passing style of
programming.


John W.F. McClain
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.