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: new register allocator and HARD_REGNO_CALL_PART_CLOBBERED


Daniel Berlin wrote :
> 
> 
> On Thursday, May 1, 2003, at 03:21  PM, Herman ten Brugge wrote:
> 
> > Dale Johannesen wrote :
> >>
> >> On Wednesday, April 30, 2003, at 12:31  PM, Herman ten Brugge wrote:
> >>
> >>> Hello,
> >>>
> >>> I found a problem with the -fnew-ra option of the compiler. I 
> >>> analysed
> >>> the problem and found that the macro HARD_REGNO_CALL_PART_CLOBBERED
> >>> is not used by the new register allocator.
> >>> I think this is also a bit difficult to implement because we now
> >>> have to check the mode for every register that is used during a
> >>> CALL_INSN.
> >>
> >> You can try the following (mail may have screwed up spacing).  It may
> >> result in even worse code than your patch, but maybe it's better than
> >> trying to work around this new-ra problem in individual targets.
> >> (Untested, I do not have a c4x.)
> >
> > I do not think the problem is in df.c.
> It is.
> 
> > The code in df.c walks through the
> > rtl and sets clobbered/used register info.
> Right, and HARD_REGNO_CALL_PART_CLOBBERED says that hard regs are 
> clobbered.
> Notice that the portion of the code modified in df.c is dealing with 
> hard registers that are killed by calls.
> 
> >  We do not yet know what mode
> > the hard registers will get (reg_raw_mode can not be used here). The 
> > mode
> > is assigned in the new-ra pass.
> This has nothnig to do with anything.
> 
> > We run df.c when no hard registers are set yet, only pseudo registers
> > are set.
> This is wrong.
> The code in question in df.c is determining what regs are killed by 
> calls.
> This is *exactly* the right place to do it.
> 
> > HARD_REGNO_CALL_PART_CLOBBERED works only on hard registers,
> > so how should this work? See how HARD_REGNO_CALL_PART_CLOBBERED is
> > used in local_alloc.c and global.c.
> Because they don't use df.c for register info, like new-ra does.
> 

HARD_REGNO_CALL_PART_CLOBBERED should be called at the place where we
create a hard register with a specific mode. Before that we can do
nothing because HARD_REGNO_CALL_PART_CLOBBERED needs the correct mode.

For example the c4x target will only save the integer part of register r4.
So if we need an integer register we can use r4 during a call. If we need
a floating point register we can not use r4 during a call.

The c4x abi specifies that r4,r5 and r8 are saved in integer mode
and r6,r7 are saved in floating point mode.

So where should make the change at the place where we decide in what
mode a register is used. If df.c does that then we must find the correct
place to do that. If not then we have to find the other place where this
is decided. 

The last patch did not work because the mode was not set correctly for
the r4..r7 and r8 register. The mode was always QImode (reg_raw_mode[i])
for some reason. I showed that at least r4 was used as floating point
register so this should have been QFmode.

After having a quick peek at the new-ra code it looks to me that a routine
like get_free_reg should check for HARD_REGNO_CALL_PART_CLOBBERED? The
routine needs more info because it needs to know if a register is
used during a call. This may be stupid suggestion though.

	Herman.


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