Re: Caller/Callee saved Registers

Peter-Lawrence.Montgomery@cwi.nl (Peter L. Montgomery)
Thu, 24 Mar 1994 09:01:49 GMT

          From comp.compilers

Related articles
[4 earlier articles]
Caller/Callee saved Registers ssimmons@convex.com (1994-03-22)
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)
[19 later articles]
| List of all articles for this month |

Newsgroups: comp.compilers
From: Peter-Lawrence.Montgomery@cwi.nl (Peter L. Montgomery)
Keywords: registers, optimize
Organization: CWI, Amsterdam
References: 94-03-054 94-03-117
Date: Thu, 24 Mar 1994 09:01:49 GMT

pmagun@iiic.ethz.ch (Paul Jakob Magun) writes:
>I'm having some difficulty grasping the key idea behind the division in
>caller/calleesaved registers:


robertsw@agcs.com (Ye Wilde Ryder) writes:
>I've often thought the solution to this problem could easily be solved in
>hardware. A call instruction that indicates which regs need saving in a
>bitmask could be combined with a stack-frame-creation instruction
>(similar to the mc68k family's link instr.) that logically ands this
>bitmask with another bitmask that indicates which regs the routine needs
>to trash. The result of this logical and would be the actual regs that
>need saving. This could all be done in software, but it would be far
>more efficient in hardware.


                Suppose A calls B, which calls C in a loop.


                A needs registers 1 and 2 and 5 saved past the call to B.
                B uses 2 and 3, but needs nothing saved past the call to C.
                C uses 1 and 3 and 4, calls nobody.


Who saves register 1? More precisely, what mask does B pass to C? If
this mask includes registers 1 and 4 and 5 (i.e., all but 2 and 3), then
register 4 is needlessly saved every time C is called, and register 1 is
saved every time through the loop in B rather than once at the start of B.
If the mask passed to C excludes registers 1, 4, 5, then register 1 must
be saved at the start of B; do we also save register 5 there even though
it is never used in B or C?


                It may be possible to achieve this with a smart linker which sees
that C needs register 1 but not 5, and sets up the right mask at the start
of B. But this scheme will not work when the addresses of subroutines
being called are unknown at compile/link time, such as if the reference to
C is


                                          (*Cfunc)(...);
--
                Peter L. Montgomery pmontgom@cwi.nl
--


Post a followup to this message

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