* How to use "y" constraint in GCC inline powerpc assembly ?
@ 2020-04-18 8:28 Christophe Leroy
2020-04-18 21:39 ` Segher Boessenkool
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2020-04-18 8:28 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev@lists.ozlabs.org
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to use "y" constraint in GCC inline powerpc assembly ?
2020-04-18 8:28 How to use "y" constraint in GCC inline powerpc assembly ? Christophe Leroy
@ 2020-04-18 21:39 ` Segher Boessenkool
0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2020-04-18 21:39 UTC (permalink / raw)
To: Christophe Leroy; +Cc: linuxppc-dev@lists.ozlabs.org
Hi!
On Sat, Apr 18, 2020 at 08:28:53AM +0000, Christophe Leroy wrote:
> 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 ?
The same as "x". You cannot really use these constraints in asm, it's
internal only. I'll remove it from the inline asm documentation. Thanks!
(You should put the cr fields you use in an inline asm in its clobber
list, i.e. "cr0" or "cr7").
Segher
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-18 21:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-18 8:28 How to use "y" constraint in GCC inline powerpc assembly ? Christophe Leroy
2020-04-18 21:39 ` Segher Boessenkool
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.