asm clobbers, !SMALL_REGISTER_CLASSES patch.

Geoffrey KEATING geoffk@discus.anu.edu.au
Sat Feb 14 20:23:00 GMT 1998


> Date: Fri, 13 Feb 1998 10:29:56 -0800
> From: Richard Henderson <rth@dot.cygnus.com>

> 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));

Funny you should mention that.  I have such a patch attached; I did it
as a warmup to see how I should do the rewriting patch.  It uses the syntax

	: "=y" : "r"(foo));

That is, you just omit the expression.

My problem is that I can't find a compelling use for it.  Usually, you
only have one register that is best; on PPC, typically this is cr0
(for loops and suchlike) or cr7 (because it occupies the least
significant bits when you put the ccr in an integer register).

Thus I'm not terribly interested in it, unless someone else can find
an actual use for it.  I would rather spend the effort on important
things, like making sure that the released GNU C library doesn't crash
the released GNU C compiler :-).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: egcs-asm-1.diff
Type: text/x-diff
Size: 7012 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/19980214/ebb3c537/attachment.bin>


More information about the Gcc mailing list