This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PUSH and POP next to first/last register use
- From: James E Wilson <wilson at specifixinc dot com>
- To: Sami Khawam <S dot Khawam at ee dot ed dot ac dot uk>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 26 Jan 2005 20:03:51 -0800
- Subject: Re: PUSH and POP next to first/last register use
- References: <41F7813C.3080907@ee.ed.ac.uk>
Sami Khawam wrote:
I am using a custom CPU architecture where I would like to place the
PUSH and POP instuctions of a register just before the first time it is
written to and just after the last time it is read, and not in the
prologue / epilogue of a function.
This is called "shrink-wrapping". I would think this works best if you
emit the saves/restores into the prologue/epilogue, and then run a
shrink-wrapping optimization pass that tries to move them inward as far
as you can.
This should be feasible for store/load instructions, but for push/pop
this will be complicated. This will change stack offsets, so it will
interfere with frame pointer elimination. You need to worry about other
things that change the stack, like alloca and Variable Length Array
allocations and deallocations. You will need to worry about the
-fdefer-pop optimization, as that may leave the stack unbalanced for
some sections of code. And of course if you have overlapping register
lifetimes, then the push/pops for those registers will conflict. You
either have to use the union of the register lifetimes for both
registers, or else only shrink-wrap one of them. This all sounds like
more trouble than it is worth for a target that uses push/pop for
register saves and restores.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com