public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* scavanging a reg
@ 2001-11-01 21:49 Aldy Hernandez
  2001-11-01 22:41 ` law
  2001-11-01 23:27 ` David Edelsohn
  0 siblings, 2 replies; 7+ messages in thread
From: Aldy Hernandez @ 2001-11-01 21:49 UTC (permalink / raw)
  To: gcc

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.

thanks.

-- 
Aldy Hernandez			E-mail: aldyh@redhat.com
Professional Gypsy
Red Hat, Inc.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 21:49 scavanging a reg Aldy Hernandez
@ 2001-11-01 22:41 ` law
  2001-11-01 23:50   ` Aldy Hernandez
  2001-11-01 23:27 ` David Edelsohn
  1 sibling, 1 reply; 7+ messages in thread
From: law @ 2001-11-01 22:41 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc

  > 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.  

You don't necessarily have to look at regs_ever_live.  You just need to find
a call-clobbered register that you can use in the prologue -- that usually
means any call-clobbered register that is not used for arguments, return
pointers, or other special purpose uses.

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 21:49 scavanging a reg Aldy Hernandez
  2001-11-01 22:41 ` law
@ 2001-11-01 23:27 ` David Edelsohn
  1 sibling, 0 replies; 7+ messages in thread
From: David Edelsohn @ 2001-11-01 23:27 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc

>>>>> Aldy Hernandez writes:

Aldy> i need a GPR at epilogue/prologue time so i can load and save to the
Aldy> VRSAVE register (which can only be moved to and fro GPRs).

Aldy> what's the best route for this?  can i iterate through "regs_ever_live"
Aldy> and get one from there?  i mean, reload is already done so we won't need
Aldy> any more registers.

	I don't know what dependency ordering your have, but can you use
GPR12 which the prologue and epilogue already uses as an intermediate for
saving the condition register?  If you use r12, you need to be careful not
to trample the CR information for any of the ABI codepaths.

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 22:41 ` law
@ 2001-11-01 23:50   ` Aldy Hernandez
  2001-11-02  6:43     ` law
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Aldy Hernandez @ 2001-11-01 23:50 UTC (permalink / raw)
  To: law, David Edelsohn; +Cc: gcc

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 23:50   ` Aldy Hernandez
@ 2001-11-02  6:43     ` law
  2001-11-02  6:46     ` David Edelsohn
  2001-11-02 13:38     ` Richard Henderson
  2 siblings, 0 replies; 7+ messages in thread
From: law @ 2001-11-02  6:43 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: David Edelsohn, gcc

> 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 nee
> d
> >   > 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?
Either-or should be OK.  

jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 23:50   ` Aldy Hernandez
  2001-11-02  6:43     ` law
@ 2001-11-02  6:46     ` David Edelsohn
  2001-11-02 13:38     ` Richard Henderson
  2 siblings, 0 replies; 7+ messages in thread
From: David Edelsohn @ 2001-11-02  6:46 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc

>>>>> Aldy Hernandez writes:

Aldy> although i'm thinking it's prob best to follow David's suggestion and
Aldy> just use r12 regardless.

	I would prefer that you simply try to use GPR11 and GPR12.  GPR11
is the static chain / environment pointer for recursive functions.

	GPR12 is conveniently available for this type of purpose -- not
used for arguments and not saved.

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scavanging a reg
  2001-11-01 23:50   ` Aldy Hernandez
  2001-11-02  6:43     ` law
  2001-11-02  6:46     ` David Edelsohn
@ 2001-11-02 13:38     ` Richard Henderson
  2 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2001-11-02 13:38 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: law, David Edelsohn, gcc

On Tue, Nov 13, 2001 at 11:42:01AM -0500, Aldy Hernandez wrote:
>       for (i = GP_ARG_MAX + 1; i <= 32; ++i)
>         if (! fixed_regs[i] && call_used_regs[i])
>           return i;

Only do this if you need a lot of them.  And if you do need a lot
of them, you'll get better scheduling if you cycle through them.

See next_scratch_gr_reg in ia64.c if you really need this.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-11-14 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01 21:49 scavanging a reg Aldy Hernandez
2001-11-01 22:41 ` law
2001-11-01 23:50   ` Aldy Hernandez
2001-11-02  6:43     ` law
2001-11-02  6:46     ` David Edelsohn
2001-11-02 13:38     ` Richard Henderson
2001-11-01 23:27 ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).