[ASM] [PowerPC] floating-point registers mnemonics
Segher Boessenkool
segher@kernel.crashing.org
Fri Jan 14 17:13:00 GMT 2011
> 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
More information about the Gcc-help
mailing list