z constraint in powerpc inline assembly ?
Christophe Leroy
christophe.leroy at c-s.fr
Thu Jan 16 17:11:36 AEDT 2020
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
More information about the Linuxppc-dev
mailing list