Re: powerpc-eabi-gcc no implicit FPU usage

2010-01-16 Thread David Edelsohn
On Fri, Jan 15, 2010 at 6:42 PM, Robert Grimm  wrote:
> Greetings all,
>
> I'm working with the powerpc-eabi architecture (specifically, the MPC563 
> processor).  For some time we have been using GCC 3.4.3 and I noticed gcc 
> generating code that makes use of the floating point registers for 64-bit 
> integer loads and whatnot... which we don't want it to do as there are times 
> when we disable the FPU.  I'm aware of the -msoft-float option but we didn't 
> want to use that as we only wanted it to not use FP registers in certain 
> functions and not entire files.  I was under the impression that a newer GCC 
> wouldn't do this based on some old mailing posts I've read.  I've just tried 
> out GCC 4.4.2 and notice that the FP registers are still being used even 
> though there is no explicit FPU usage going on in this particular part of the 
> code.
>
> Is there a way to get GCC to only use the FPU when we explicitly want to use 
> it (i.e. when we use doubles/floats)?  Is -msoft-float my only option here?  
> Is there any sort of #pragma that could do the same thing as -msoft-float (I 
> didn't see one)?

Recent versions of GCC greatly decrease the use of FPRs for
non-floating point code, but do not prevent it.

To absolutely prevent use of FPRs, one must use -msoft-float.  The
hard-float and soft-float ABIs are incompatible and one cannot mix
object files.

GCC is a compiler, not an assembler.  It tries to optimize programs,
not read programmers' minds.  If the person invoking the compiler does
not deny the resource to the compiler, it will try to use it when
profitable, which is what it should do.

David


Re: powerpc-eabi-gcc no implicit FPU usage

2010-01-16 Thread Martin Guy
On 1/16/10, David Edelsohn  wrote:
>  > Is there a way to get GCC to only use the FPU when we explicitly want to 
> use it (i.e. when we use doubles/floats)?  Is -msoft-float my only option 
> here?  Is there any sort of #pragma that could do the same thing as 
> -msoft-float (I didn't see one)?
>
>  To absolutely prevent use of FPRs, one must use -msoft-float.  The
>  hard-float and soft-float ABIs are incompatible and one cannot mix
>  object files.

There is a third option -mfloat-abi=softfp which stipulates that FP
instructions can be used within functions but the parameter and return
values are passed using the same conventions as soft float. soft and
softfp-compiled files can be linked together, allowing you to mix code
using FP instructions and not with source file granularity.

I dunno if that affects the use of FP registers to load /store 64-bit
integer values as you originally described, but may be the closest you
can get without modifying GCC to insert new #pragmas.

M


GCC 4.4.3 Release Candidate available from gcc.gnu.org

2010-01-16 Thread Jakub Jelinek
The first release candidate for GCC 4.4.3 is available from

  ftp://gcc.gnu.org/pub/gcc/snapshots/4.4.3-RC-20100116

and shortly its mirrors.  It has been generated from SVN revision 155960.

I have so far bootstrapped and tested the release candidate on
x86_64-linux and i686-linux.  Please test it and report any issues to
bugzilla.

The branch is now frozen and all checkins until after the final release
of GCC 4.4.3 require explicit RM approval.

If all goes well, I'd like to release 4.4.3 next week.


Re: powerpc-eabi-gcc no implicit FPU usage

2010-01-16 Thread Robert Grimm
Thanks to all who have responded so far.  Thanks to Martin for the 
-mfloat-abi=softfp option as that could be useful to us.

On Jan 16, 2010, at 6:23 AM, David Edelsohn wrote:

> On Fri, Jan 15, 2010 at 6:42 PM, Robert Grimm  wrote:
>> Greetings all,
>> 
>> I'm working with the powerpc-eabi architecture (specifically, the MPC563 
>> processor).  For some time we have been using GCC 3.4.3 and I noticed gcc 
>> generating code that makes use of the floating point registers for 64-bit 
>> integer loads and whatnot... which we don't want it to do as there are times 
>> when we disable the FPU.  I'm aware of the -msoft-float option but we didn't 
>> want to use that as we only wanted it to not use FP registers in certain 
>> functions and not entire files.  I was under the impression that a newer GCC 
>> wouldn't do this based on some old mailing posts I've read.  I've just tried 
>> out GCC 4.4.2 and notice that the FP registers are still being used even 
>> though there is no explicit FPU usage going on in this particular part of 
>> the code.
>> 
>> Is there a way to get GCC to only use the FPU when we explicitly want to use 
>> it (i.e. when we use doubles/floats)?  Is -msoft-float my only option here?  
>> Is there any sort of #pragma that could do the same thing as -msoft-float (I 
>> didn't see one)?
> 
> Recent versions of GCC greatly decrease the use of FPRs for
> non-floating point code, but do not prevent it.
> 
> To absolutely prevent use of FPRs, one must use -msoft-float.  The
> hard-float and soft-float ABIs are incompatible and one cannot mix
> object files.
> 

I get why one cannot mix hard/soft object files if you have functions whose 
interfaces use floats/doubles/uint64_ts, but what about those that don't.  In 
other words, if I had one hard-float object file that depends on a soft-float 
object file but no floats, doubles or 64-bit values are passed in between, is 
that okay?  One thing we've tried is to compile only certain libraries as 
soft-float as long as those libraries don't contain any float/double/64-bit 
interfaces.  It seems to work but now I'm wondering if we're playing with fire 
and that we've just been lucky.

> GCC is a compiler, not an assembler.  It tries to optimize programs,
> not read programmers' minds.  If the person invoking the compiler does
> not deny the resource to the compiler, it will try to use it when
> profitable, which is what it should do.
> 
> David

I'm not asking it to read my mind.  I'm asking for a 
"-fonly-use-the-FPU-when-you-see-a-float-or-a-double-and-not-when-you-see-a-uint64_t"
 flag.  This would be very useful for those of us, as Joel Sherill pointed out, 
leave the FPU disabled at times and use uint64_t's inside interrupt service 
routines.

Actually, I saw some old posts that talked about a -fno-implicit-fp option 
which seemed to be just what I want.  Any reason why that was abandoned or not 
considered?

Thanks again to all for your help,
Rob


Re: powerpc-eabi-gcc no implicit FPU usage

2010-01-16 Thread Paul Brook
> >  > Is there a way to get GCC to only use the FPU when we explicitly want
> >  > to use it (i.e. when we use doubles/floats)?  Is -msoft-float my only
> >  > option here?  Is there any sort of #pragma that could do the same
> >  > thing as -msoft-float (I didn't see one)?
> >
> >  To absolutely prevent use of FPRs, one must use -msoft-float.  The
> >  hard-float and soft-float ABIs are incompatible and one cannot mix
> >  object files.
> 
> There is a third option -mfloat-abi=softfp which stipulates that FP
> instructions can be used within functions but the parameter and return
> values are passed using the same conventions as soft float. soft and
> softfp-compiled files can be linked together, allowing you to mix code
> using FP instructions and not with source file granularity.

That's completely the opposite. mfloat-abi=softfp tells gcc to use FPU 
instructions while conforming to a nominally soft-float ABI.

The OP wants the opposite: Conform to a hard-float ABI without actually using 
FPU instructions. It is (in thory) possible to do this in a half-sane way, 
however it's also easy to end up with something very fragile that breaks more 
often than it works.

Paul