This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm for powerpc question
- To: aldyh at redhat dot com (Aldy Hernandez)
- Subject: Re: inline asm for powerpc question
- From: Geoff Keating <geoffk at geoffk dot org>
- Date: 05 Jun 2001 10:31:54 -0700
- CC: gcc at gcc dot gnu dot org
- References: <991761446.2753.26.camel.cygnus.gcc@culebra.cygnus.com>
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>