Re: [OT] caller-save/callee-save register styles

From: Jeff Garzik
Date: Mon Sep 08 2003 - 09:24:36 EST


On Sun, Sep 07, 2003 at 11:54:59PM +0530, Nagendra Singh Tomar wrote:
> I would like to know various people's experiences about the caller-save
> and callee-save style of preserving register values across procedure
> calls. I feel that the ABI specification should specify that but I was
> unable to figure that out in the ELF-ABI specification.

The i386 ELF ABI spec _does_ specify that.


> What I have personally seen is only callee-save style in which the
> modified registers are PUSHed on the stack on entering the function and
> POPed on leaving the function. That means the caller can assume that all
> the regsiter values will be same just before and after the 'call'
> instruction.

The caller assumes nothing; the caller is _guaranteed_ the register
rules described in the i386 ELF ABI.

Compiler writers will sometimes simply avoid registers they must save
and restore across function calls. That allows them to avoid push'ing
and pop'ing outside of calling another function.

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/