This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: scavanging a reg
- To: law at redhat dot com, David Edelsohn <dje at watson dot ibm dot com>
- Subject: Re: scavanging a reg
- From: Aldy Hernandez <aldyh at redhat dot com>
- Date: 13 Nov 2001 11:42:01 -0500
- Cc: gcc at gcc dot gnu dot org
- References: <28174.1005668752@porcupine.cygnus.com>
On Tue, 2001-11-13 at 11:25, law@redhat.com wrote:
> > i need a GPR at epilogue/prologue time so i can load and save to the
> > VRSAVE register (which can only be moved to and fro GPRs).
> >
> > what's the best route for this? can i iterate through "regs_ever_live"
> > and get one from there? i mean, reload is already done so we won't need
> > any more registers.
> True, but you also can't make a call-saved register live that wasn't live
> before. So you have to find a call-clobbered register.
doh.. i thought about that right after i sent the mail...
how about this?
/* Scavange any non fixed register we can use as scratch at
pro/epilogue time. Pick a register out of the call clobbered set
because no one expects it to hold anything meaningful. */
int
get_scratch_gpr (void)
{
int i;
for (i = GP_ARG_MAX + 1; i <= 32; ++i)
if (! fixed_regs[i] && call_used_regs[i])
return i;
/* If we can't find anything, return r12. */
return 12;
}
although i'm thinking it's prob best to follow David's suggestion and
just use r12 regardless.
is the above ok?
--
Aldy Hernandez E-mail: aldyh@redhat.com
Professional Gypsy
Red Hat, Inc.