This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about DRAP register and reserving hard registers
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Tue, 7 Jul 2015 15:47:33 -0700
- 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> <55911981 dot 2070901 at redhat dot com>
- Reply-to: <sellcey at imgtec dot com>
On Mon, 2015-06-29 at 11:10 +0100, Richard Henderson wrote:
> > 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.
>
>
> r~
I ran into an interesting issue while doing this. Right now the expand
pass calls construct_exit_block (which calls expand_function_end) before
it calls expand_stack_alignment. That means that crtl->drap_reg, etc
are not yet set up when in expand_function_end. I moved the
expand_stack_alignment call up before construct_exit_block to fix that.
I hope moving it up doesn't break anything.
Steve Ellcey
sellcey@imgtec.com