Re: Merit of callee-saved register
- From: Robert Redelmeier <redelm@xxxxxxxxxxxxxxx>
- Date: Tue, 22 Apr 2008 12:45:32 GMT
Tim Frink <plfriko@xxxxxxxx> wrote in part:
I've a general question about calling conventions and the
use of registers across calls. In a book I found this:
"For a variable whose range of appearance spans many
procedure calls, the use of a callee-saved register is
advantageous, because saving and restoring once at the
procedure entry and exit respectively are cheaper than
saving and restoring around each call."
I'm a native english speaker and I don't understand either.
Cheaper can mean shorter or quicker (cheaper on cycles)
which are often the same for once-thru code.
To me, register preservation is a matter of conventions
without any ideal answer: only the caller knows which regs
need saving, and only the callee knows which registers will
be trampled. Often, no regs need saving.
In x86, the arch is allegedly short of registers so the
usual presumption is all will get trampled. This leads to
caller-save conventions. But note that ESP and EBP usually
are callee-save . Since procedures have non-zero overhead,
they should be reserved for "significant" code that makes
the trampling more likely.
-- Robert
.
- References:
- Merit of callee-saved register
- From: Tim Frink
- Merit of callee-saved register
- Prev by Date: Re: All is right !
- Next by Date: Re: Newbie Alert !!!
- Previous by thread: Merit of callee-saved register
- Next by thread: Re: Merit of callee-saved register
- Index(es):
Relevant Pages
|