Re: Caller/Callee saved Registers

bart@cs.uoregon.edu (Barton C. Massey)
Tue, 29 Mar 1994 10:24:26 GMT

          From comp.compilers

Related articles
[21 earlier articles]
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-26)
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-26)
Re: Caller/Callee saved Registers anton@mips.complang.tuwien.ac.at (1994-03-28)
Re: Caller/Callee saved Registers zsh@cs.princeton.edu (1994-03-27)
Re: Caller/Callee saved Registers pardo@cs.washington.edu (1994-03-28)
Re: Caller/Callee saved Registers pardo@cs.washington.edu (1994-03-29)
Re: Caller/Callee saved Registers bart@cs.uoregon.edu (1994-03-29)
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-29)
Re: Caller/Callee saved Registers hbaker@netcom.com (1994-03-29)
Re: Caller/Callee saved Registers pardo@cs.washington.edu (1994-03-31)
Re: Caller/Callee saved Registers conway@munta.cs.mu.OZ.AU (1994-04-02)
Re: Caller/Callee saved Registers nandu@cs.clemson.edu (1994-04-21)
Re: Caller/Callee saved Registers preston@noel.cs.rice.edu (1994-04-22)
[2 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: bart@cs.uoregon.edu (Barton C. Massey)
Keywords: registers, design
Organization: University of Oregon Computer and Information Sciences Dept.
References: 94-03-054 94-03-159
Date: Tue, 29 Mar 1994 10:24:26 GMT

bart@cs.uoregon.edu (Barton Christopher Massey) writes:
|> I'll admit I glossed over the fact that in many situations callee-saves
|> still allows tail-call. I think it is a necessary condition, though, that
|> any registers passed as arguments to the tail-called procedure needn't be
|> saved by the tail-caller. A program which violates the condition is
|>
|> # callee-saves, args in r0..rn
|> # all non-arg registers must be preserved
|> f: # 1 arg
|> push r1
|> add r0,1,r1
|> call g # 2 args
|> pop r1
|> ret


Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> 2) The arguments are callee-saved: Then you need not save and restore
> r1 around g, because g does that. Again, no pop r1 and you can
> optimize the tail call.


Huh??? Let's take it slowly here:


(1) In any general callee-saves convention the value in
r1 when f exits should be the same as the value in r1
when f is entered (after all, the caller of f may be
using r1).


(2) If r1 is being used to pass an argument to g, then
the value in r1 when g is entered will in general need
to be different than the value in r1 when f is entered.


(3) g does not in general have access to the value which
was in r1 when f was entered, so g can't put it back.
Presumably, when g is exited, r1 will contain one of
two things -- either garbage, or the value in r1 when g
was entered.


(4) Thus, f, and f alone, must restore the value of r1 .
This must happen after the call to g, but before f
exits.


(5) Given (4), that "pop" instruction (or some analogue)
must remain firmly planted where it is, and tail-calling
g is thus impossible.


Am I missing something?


Bart Massey
bart@cs.uoregon.edu
--


Post a followup to this message

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