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: scavanging a reg


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.


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