linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* z constraint in powerpc inline assembly ?
@ 2020-01-16  6:11 Christophe Leroy
  2020-01-16  8:06 ` Gabriel Paubert
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Christophe Leroy @ 2020-01-16  6:11 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Hi Segher,

I'm trying to see if we could enhance TCP checksum calculations by 
splitting inline assembly blocks to give GCC the opportunity to mix it 
with other stuff, but I'm getting difficulties with the carry.

As far as I can read in the documentation, the z constraint represents 
'‘XER[CA]’ carry bit (part of the XER register)'

I've tried the following, but I get errors. Can you help ?

unsigned long cksum(unsigned long a, unsigned long b, unsigned long c)
{
	unsigned long sum;
	unsigned long carry;

	asm("addc %0, %2, %3" : "=r"(sum), "=z"(carry) : "r"(a), "r"(b));
	asm("adde %0, %0, %2" : "+r"(sum), "+z"(carry) : "r"(c));
	asm("addze %0, %0" : "+r"(sum) : "z"(carry));

	return sum;
}



csum.c: In function 'cksum':
csum.c:6:2: error: inconsistent operand constraints in an 'asm'
   asm("addc %0, %2, %3" : "=r"(sum), "=z"(carry) : "r"(a), "r"(b));
   ^
csum.c:7:2: error: inconsistent operand constraints in an 'asm'
   asm("adde %0, %0, %2" : "+r"(sum), "+z"(carry) : "r"(c));
   ^
csum.c:8:2: error: inconsistent operand constraints in an 'asm'
   asm("addze %0, %0" : "+r"(sum) : "z"(carry));
   ^

Thanks
Christophe


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-01-16 19:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16  6:11 z constraint in powerpc inline assembly ? Christophe Leroy
2020-01-16  8:06 ` Gabriel Paubert
2020-01-16 13:57   ` Segher Boessenkool
2020-01-16 17:42     ` [PosibleSpam] " Gabriel Paubert
2020-01-16 14:01 ` Segher Boessenkool
2020-01-16 15:54 ` David Laight
2020-01-16 16:21   ` Segher Boessenkool
2020-01-16 16:52     ` David Laight
2020-01-16 17:10     ` Christophe Leroy
2020-01-16 17:20       ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).