How to use "y" constraint in GCC inline powerpc assembly ?

Christophe Leroy christophe.leroy at c-s.fr
Sat Apr 18 18:28:53 AEST 2020


Hi Segher,

I'd like to use cr instead of gpr to return error condition from 
__get_user().

I saw in GCC doc 
(https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html) that it is 
possible to use "y" as constraint to refer to "Any condition register 
field, cr0…cr7".

I tried the test below, but it fails with "error: impossible register 
constraint in 'asm'"

How does "y" has to be used ?

int test(char *p)
{
	struct {
		int r:1;
	} res = {0};

	asm("crnot %0 * 4 + eq, %0 * 4 + eq": "=&y"(res.r));

	if (res.r)
		return -14;
	return 0;
}

Christophe


More information about the Linuxppc-dev mailing list