This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PUSH and POP next to first/last register use


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]