This is the mail archive of the 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: Question about DRAP register and reserving hard registers

On Fri, 2015-06-19 at 09:09 -0400, Richard Henderson wrote:
> On 06/16/2015 07:05 PM, Steve Ellcey  wrote:
> >
> > I have a question about the DRAP register (used for dynamic stack alignment)
> > and about reserving/using hard registers in general.  I am trying to understand
> > where, if a drap register is allocated, GCC is told not to use it during
> > general register allocation.  There must be some code somewhere for this
> > but I cannot find it.
> There isn't.  Because the vDRAP register is a pseudo.  The DRAP register is 
> only live from somewhere in the middle of the prologue to the end of the prologue.
> See ix86_get_drap_rtx, wherein we coordinate with the to-be-generated prologue 
> (crtl->drap_reg), allocate the pseudo, and emit the hard-reg-to-pseudo copy at 
> entry_of_function.
> r~

OK, I think I have this part of the code working on MIPS but
crtl->drap_reg is used in the epilogue as well as the prologue even if
it is not 'live' in between.  If I understand the code correctly the x86
prologue pushes the drap register on to the stack so that the epilogue
can pop it off and use it to restore the stack pointer.  Is my
understanding correct?

I also need the drap pointer in the MIPS epilogue but I would like to
avoid having to get it from memory.  Ideally I would like to restore it
from the virtual register that the prologue code / get_drap_rtx code put
it into.  I tried just doing a move from the virtual drap register to
the real one in expand_epilogue but that didn't work because it looks
like you can't access virtual registers from expand_prologue or
expand_epilogue.  I guess that is why the code to copy the hard drap reg
to the virtual drap_reg is done in get_drap_reg and not in
expand_prologue.  I thought about putting code in get_drap_reg to do
this copying but I don't see how to access the end of a function.  The
hard drap reg to virtual drap reg copy is inserted into the beginning of
a function with:

insn = emit_insn_before (seq, NEXT_INSN (entry_of_function ()));

Is there an equivalent method to insert code to the end of a function?
I don't see an 'end_of_function ()' routine anywhere.

Steve Ellcey

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