This is the mail archive of the
mailing list for the GCC project.
Re: Question about DRAP register and reserving hard registers
- From: Richard Henderson <rth at redhat dot com>
- To: sellcey at imgtec dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 29 Jun 2015 11:10:09 +0100
- Subject: Re: Question about DRAP register and reserving hard registers
- Authentication-results: sourceware.org; auth=none
- References: <163e6dcd-b157-47a1-aed3-01eb1b287851 at BAMAIL02 dot ba dot imgtec dot org> <5584148A dot 7040602 at redhat dot com> <1435011263 dot 3099 dot 65 dot camel at ubuntu-sellcey>
On 06/22/2015 11:14 PM, Steve Ellcey wrote:
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
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
Yes. Although that saved copy is also used by unwind info.
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.
Because, while generating initial rtl for a function, the beginning of a
function has already been emitted, while the end of the function hasn't.
You'd need to hook into expand_function_end, right at the bottom, before the
call to use_return_register.