This is the mail archive of the 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: commutative asm operands

On Wed, Aug 07, 2002 at 01:16:40AM +0200, Roman Zippel wrote:
> >   asm ("addc %0, %1, %2" : "=r" (a) : "%0" (c), "r" (a));
> >   asm ("addc %0, %1, %2" : "=r,r" (a) : "0,r" (c), "r,0" (a));
> While thinking more about it, I think it's not really correct to exchange
> the constraint, reload should only try to exchange the operands, e.g.
> 	asm("add %0,%2" : "=r" (a) : "%0" (b), "g" (c));
> has to work as well.


> An example like is mentioned in the docs, the first and second
> operand must be the same, otherwise you'll break some machines.

How do you mean?  If they're not the same, then reload must
rearrange them so that they are the same.  E.g.

	op0 = a = r1
	op1 = b = r3
	op2 = c = mem

one solution is 

	// don't swap
	(set r1 r3)
	(set r1 (asm_operands [r1 mem]))

another is

	// swap
	(set r1 mem)
	(set r1 (asm_operands [r1 r3]))

The one reload can't fix is if you have a matching constraint
with a memory operand, and the memories aren't the same.
Matching with a register should always work though.


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