|
From: | David Brown |
Subject: | Re: [avr-libc-dev] Feature wishlisht |
Date: | Sat, 26 Feb 2011 14:18:21 +0100 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 |
On 25/02/2011 23:00, Joerg Wunsch wrote:
As Weddington, Eric wrote:On the other hand, I don't like it as an option. -mint8 already breaks avr-libc.Not really. -mint8 doesn't work with the non-mint8 avr-libc binary distributions (so people who'd like to use it have to roll their own or stay away from using library functions), but that's about all.I would rather see 64-bit doubles, 32-bit floats, and library routines to support the user who can then decide which routines to use.The problem here is the same that initially led to the creation of the -mint8 option: promotion rules demand promotions from float to double in many situations, which for sure will cause bloat, lots of bloat. Even the 8->16 bit integer promotions haven't all been shaken out of those places where they aren't necessary within the 10+ years of AVR-GCC lifetime, so I'd expect it'll take another ten years (after establishing 64-bit double support at all) to shake out all the unneeded 32->64 bit FP promotions. Within that period of time, an option like -mdouble32 might save our back. If we do it right, it might even be possible to have avr-libc being compatible with -mdouble32: floating-point arguments aren't used outside libm in many places. libm itself could perhaps map all the 64-bit double functions to their 32-bit float counterparts through #defines if it notices -mdouble32 is in effect, so only a few things remain like printf with floating-point formats, where it could probably be handled by linking a different library through GCC's specs declarations. But well, before that, we need someone to actually implement it ... Btw., IIRC even IAR supports an option like that, despite they are *very* eager to conform to any of the existing standards.
gcc already has a "-fshort-double" switch that makes it use the same size for doubles and floats. I don't know what happens with this if you use library functions (i.e., if you compile "double x = 3.14; double y = sin(x)" with -fshort-double). But this should probably be the starting point for any options about double sizes. In the development line of gcc, there is also a warning "-Wdouble-promotion" to warn if a float gets promoted to a double, and "-Wunsuffixed-float-constants" which warns about writing things like "1.1" instead of "1.1f" or "1.1d". Although AVR is one of the smallest mainline gcc targets, the issue of 32-bit floats and doubles is becoming a major issue for bigger targets. I don't know how many people here use gcc for things like the ARM or the PPC, but there are several of these devices that have floating point hardware support for 32-bit floats, but software-only for 64-bit doubles. The relative cost of using 64-bit doubles compared to 32-bit floats is a lot higher on a Cortex M4 than it is on an AVR (or will be, when 64-bit doubles are implemented...). Because of this, support for "-fshort-double" and new flags like "-Wdouble-promotion" are already in place in gcc, and groups like CodeSourcery have already been through the issues and written the code. It may be that there are outstanding issues, such as making sure the libraries work correctly in the face of these flags, but it should be possible to make use of this existing work. mvh., David
[Prev in Thread] | Current Thread | [Next in Thread] |