This is the mail archive of the gcc-patches@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]

Re: Reload patch version 3


> Date: Mon, 31 Aug 1998 12:48:16 +0200
> From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>

> >> Additionally your patch seems to fix Geoff's pet bug ;-) asm("" : : :
> >> "cc"), which now compiles just fine (also part of the configure tests of
> >> glibc-2.0.95).
> >
> >Could you explain quickly why this wouldn't work before?
> 
> Explain? Not really, but there was a discussion of the problem on the egcs
> list back in ~Jan-March98. Check the archive for messages from Geoff
> Keating or ask him directly.
> The error issued by the compiler is:
> test8.c: In function `foo':
> test8.c:5: fixed or forbidden register 68 (0) was spilled for class CR0_REGS.
> This may be due to a compiler bug or to impossible asm
> statements or clauses.
> 
> I think (!) it has something to do with the multiple condition code
> registers (cr0-cr7, 4 bit each, combined into one 32bit reg, dunno if cc
> means cr0 or the whole 32bit reg) available on PPC.

It's caused by having a register which is alone in its class, and
naming that register in the asm statement, and then having the RTL
trying to allocate a register from the class.

CR0_REGS contains only the register 'cr0' (also known as 'cc').  It's
not specific to that class, there are other classes that do the same
thing on ppc like LINK_REGS and COUNT_REGS.  

I think the reason for the restriction is that reload doesn't reliably
allocate pseudos to a register if the register is also named
explicitly somewhere else.  I don't have an example of this; does
anyone?

Some ports work around this by defining the macro
'SMALL_REGISTER_CLASSES', but that reduces the quality of the
generated code, and it's not worth it to fix this small bug.

It's probably wrong to think of cr0-cr7 as 'combined into one 32-bit
reg'.  In most ppc implementations, they are really 8 different 4-bit
registers, and they get allocated to rename registers and suchlike
separately.

The full test case on PPC is

int tester(int x) { 
  asm ("" : : : "cc");    /* This names 'cr0' explicitly.  */
  return x & 123;         /* This requires a CR0_REGS register.  */
}

If it compiles, the test passes.

-- 
Geoffrey Keating <geoffk@ozemail.com.au>


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