public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* [ASM] [PowerPC] floating-point registers mnemonics
@ 2011-01-14 14:07 qdii
  2011-01-14 17:13 ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: qdii @ 2011-01-14 14:07 UTC (permalink / raw)
  To: gcc-help


Good afternoon,
This is my first post here, so feel free to make any kind of remarks :)
I've been trying to use a temporary floating-point register in inline asm,
but nothing seems to work.
On the code below, I'm storing the result of the product in a temporary
variable (fra).

inline void MTH_Vec3Scale(register MTH_tt_Vector3 *D,register const
MTH_tt_Vector3 *A, register f32 f)
{
    register       f32  fra;
    asm     (       "lfs   %3,   0(%0)              \n"        // FRA <- *A
                    "\t    fmul   %3,   %3,     %2  \n"       // FRT <- FRA
* FRC
                    "\t    stfs   %3,   0(%1)       \n"         // *dest =
FRT

                    "\t    lfs    %3,   4(%0)       \n"      
                    "\t    fmul   %3,   %3,     %2  \n"        
                    "\t    stfs   %3,   4(%1)       \n"        

                    "\t    lfs    %3,   8(%0)       \n"       
                    "\t    fmul   %3,   %3,     %2  \n"        
                    "\t    stfs   %3,   8(%1)       \n"        
        /* outputs: */ :
        /* inputs : */ :"b"(A),"b"(D),"f"(f),"f"(fra)
        /* clobbers:*/ :"memory");
}

What I would like to do is to use a floating-point register directly, f11
for instance, to store the results:
lfs   %3,   0(%0)        
would be come
lfs    f11,  0(%0)
for instance.
I would add "f11" to the list of clobber registers.  But it won't let me,
complaining that "f11" is unknown register. "fr11" doesn't work either. I
have given it many tries ...

If anyone had some more documentation about PowerPC 's asm with gcc I'd love
to hear about it.

Thanks!

But every time I do that, I end up with the error : "unknown register f11"
-- 
View this message in context: http://old.nabble.com/-ASM---PowerPC--floating-point-registers-mnemonics-tp30671952p30671952.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ASM] [PowerPC] floating-point registers mnemonics
  2011-01-14 14:07 [ASM] [PowerPC] floating-point registers mnemonics qdii
@ 2011-01-14 17:13 ` Segher Boessenkool
  2011-01-14 18:31   ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2011-01-14 17:13 UTC (permalink / raw)
  To: qdii; +Cc: gcc-help

> On the code below, I'm storing the result of the product in a temporary
> variable (fra).
>
> inline void MTH_Vec3Scale(register MTH_tt_Vector3 *D,register const
> MTH_tt_Vector3 *A, register f32 f)
> {
>     register       f32  fra;
>     asm     (       "lfs   %3,   0(%0)              \n"        // FRA <-
> *A
>                     "\t    fmul   %3,   %3,     %2  \n"       // FRT <-
> FRA
> * FRC
>                     "\t    stfs   %3,   0(%1)       \n"         // *dest =
> FRT
>
>                     "\t    lfs    %3,   4(%0)       \n"
>                     "\t    fmul   %3,   %3,     %2  \n"
>                     "\t    stfs   %3,   4(%1)       \n"
>
>                     "\t    lfs    %3,   8(%0)       \n"
>                     "\t    fmul   %3,   %3,     %2  \n"
>                     "\t    stfs   %3,   8(%1)       \n"
>         /* outputs: */ :
>         /* inputs : */ :"b"(A),"b"(D),"f"(f),"f"(fra)
>         /* clobbers:*/ :"memory");
> }

You write to "fra" (and never read it), so you should list it in
outputs instead of in inputs:

         /* outputs: */ :"=f"(fra)
         /* inputs : */ :"b"(A),"b"(D),"f"(f)
         /* clobbers:*/ :"memory");

(and change all the %0..%3, or use named asm parameters).

> What I would like to do is to use a floating-point register directly, f11
> for instance, to store the results:
> lfs   %3,   0(%0)
> would be come
> lfs    f11,  0(%0)
> for instance.
> I would add "f11" to the list of clobber registers.  But it won't let me,
> complaining that "f11" is unknown register. "fr11" doesn't work either. I
> have given it many tries ...

I don't know, sorry.  One thing you could do is write the whole routine
in asm (in a .s or .S file); it's much easier for bigger code (but you
have to take care of the ABI yourself, usually not a problem since you're
only dealing with leaf fucntions without stack frame).


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ASM] [PowerPC] floating-point registers mnemonics
  2011-01-14 17:13 ` Segher Boessenkool
@ 2011-01-14 18:31   ` Andrew Haley
  2011-01-14 21:29     ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Haley @ 2011-01-14 18:31 UTC (permalink / raw)
  To: gcc-help

On 01/14/2011 05:13 PM, Segher Boessenkool wrote:
>> On the code below, I'm storing the result of the product in a temporary
>> variable (fra).
>>
>> inline void MTH_Vec3Scale(register MTH_tt_Vector3 *D,register const
>> MTH_tt_Vector3 *A, register f32 f)
>> {
>>      register       f32  fra;
>>      asm     (       "lfs   %3,   0(%0)              \n"        // FRA<-
>> *A
>>                      "\t    fmul   %3,   %3,     %2  \n"       // FRT<-
>> FRA
>> * FRC
>>                      "\t    stfs   %3,   0(%1)       \n"         // *dest =
>> FRT
>>
>>                      "\t    lfs    %3,   4(%0)       \n"
>>                      "\t    fmul   %3,   %3,     %2  \n"
>>                      "\t    stfs   %3,   4(%1)       \n"
>>
>>                      "\t    lfs    %3,   8(%0)       \n"
>>                      "\t    fmul   %3,   %3,     %2  \n"
>>                      "\t    stfs   %3,   8(%1)       \n"
>>          /* outputs: */ :
>>          /* inputs : */ :"b"(A),"b"(D),"f"(f),"f"(fra)
>>          /* clobbers:*/ :"memory");
>> }
>
> You write to "fra" (and never read it), so you should list it in
> outputs instead of in inputs:
>
>           /* outputs: */ :"=f"(fra)

Make that an earlyclobber: "=&f"

Andrew.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ASM] [PowerPC] floating-point registers mnemonics
  2011-01-14 18:31   ` Andrew Haley
@ 2011-01-14 21:29     ` Segher Boessenkool
  0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2011-01-14 21:29 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

>> You write to "fra" (and never read it), so you should list it in
>> outputs instead of in inputs:
>>
>>           /* outputs: */ :"=f"(fra)
>
> Make that an earlyclobber: "=&f"

Yes of course, thanks.  Another reason to not write big inline asm
blobs :-)


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-14 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-14 14:07 [ASM] [PowerPC] floating-point registers mnemonics qdii
2011-01-14 17:13 ` Segher Boessenkool
2011-01-14 18:31   ` Andrew Haley
2011-01-14 21:29     ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).