This is the mail archive of the gcc@gcc.gnu.org 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]

Re: inline asm for powerpc question


aldyh@redhat.com (Aldy Hernandez) writes:

> a customer is having problems with some inline asms.  they have the
> following code that is supposed to clobber %r4:
> 
> unsigned inline flying_carpet( ) {
>   unsigned tmp ;
>   asm (" mfmsr %0;"
>       " rlwinm %%r4,%0,0,17,15;"
>       " mtmsr %%r4"
>        : "=r" (tmp) /* outputs */
>        : /* no inputs */
>        : "%r4" /* trashes r4 */);	<-- clobber %r4 please
>    return (int) tmp;
> }
> 
> however, gcc doesn't respect that and expects %r4 to be live across the
> asm:
> 
>         lwz %r0,0(%r4)		<-- use of %r4
>         cmpwi %cr0,%r0,-1
>         bc 12,2,.L7
>          mfmsr %r29; rlwinm %r4,%r29,0,17,15; mtmsr %r4
> .L8:
>         lwz %r0,0(%r4)		<-- use of r4 (boo hiss!)
> 
> is this actually a bug, or should they be using "asm volatile" (cuz that
> for sure fixes the problem)?

That seems to be a bug.  Most likely, the '%' is confusing GCC.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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