asm clobbers, !SMALL_REGISTER_CLASSES patch.

Richard Henderson rth@cygnus.com
Fri Feb 13 10:58:00 GMT 1998


On Fri, Feb 13, 1998 at 12:47:00PM -0500, David Edelsohn wrote:
> 	SCRATCH only has a mode, but RTL match_scratch includes both a
> mode and a register class constraint.

Yes, but match_scratch at present can only be used in patterns
fed to genrecog and the like.  But I see no reason why we
couldn't support something like that.  Certainly it would match
what we're trying to describe much better.  It should only 
involve changes to the asm expander and reload, no?

I was thinking along the same lines last night about scratches
and allocating temps from classes that are not describable from 
C, like CCmode registers and whatnot.

PowerPC, Sparc64, and others have multiple CC registers.  It
comes to pass that while writing some inline assembly, you need
one.  At present you can only just pick one at random and 
clobber it.

What if we provide a way to allocate scratches explicitly?  My
thought here is to put something special in the () part of the
output section (whether we turn it into a clobber is immaterial;
we need a parameter number for the asm string).  I considered
using something like __scratch__, but it'd be nice to avoid a
new keyword.  Using auto instead appeals to me.

So you could then do

	asm ("cmpwi %0,%1,123\n\t"
	     "beq %0,1f\n\t"
	     "blah\n"
	     "1:"
	  : "=y"(auto) : "r"(foo));

which might expand to

	cmpwi  cr3,r4,123
	beq   cr3,1f
	blah
1:

although this is a bad example cause you could do the cmp+branch
thing in C around the blah.  And doesn't ppc have separate fp and
int cc regs (4 each)?  They don't seem to be given different
register classes...


r~



More information about the Gcc mailing list