public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Is it possible to make gcc detect whether printf prints floating point numbers?
       [not found] <CAHFci29a5rfe+5BeyHmfzXcV7T=mQkQW9XXtTo=7CvpM5=-zWQ@mail.gmail.com>
@ 2012-06-08  9:14 ` Andrew Haley
  2012-06-08  9:57   ` Bin.Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2012-06-08  9:14 UTC (permalink / raw)
  To: Bin.Cheng; +Cc: gcc-help

[Redirect to gcc-help]

On 06/08/2012 09:54 AM, Bin.Cheng wrote:
> In micro-controller applications, code size is critical and the size
> problem is worse if library is linked.
> For example, most c programs call printf to format output data, that
> means floating point code get linked even the program only want to
> output non-floating point numbers. Currently, we rely on end-user to
> call iprintf if the program does not want floating point.
>
> I noticed that GCC now can check format string of printf functions, so
> I am wondering if it is possible to take advantage of this utility, by
> making gcc detect whether printf prints floating point number and then
> generate assembly directive in backend to pull in floating point
> functions only if necessary.

It wouldn't be at all difficult, but you'd have to change gcc.

Andrew.


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

* Re: Is it possible to make gcc detect whether printf prints floating point numbers?
  2012-06-08  9:14 ` Is it possible to make gcc detect whether printf prints floating point numbers? Andrew Haley
@ 2012-06-08  9:57   ` Bin.Cheng
  2012-06-08 10:17     ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Bin.Cheng @ 2012-06-08  9:57 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-help

On Fri, Jun 8, 2012 at 5:14 PM, Andrew Haley <aph@redhat.com> wrote:
> [Redirect to gcc-help]
>
> On 06/08/2012 09:54 AM, Bin.Cheng wrote:
>> In micro-controller applications, code size is critical and the size
>> problem is worse if library is linked.
>> For example, most c programs call printf to format output data, that
>> means floating point code get linked even the program only want to
>> output non-floating point numbers. Currently, we rely on end-user to
>> call iprintf if the program does not want floating point.
>>
>> I noticed that GCC now can check format string of printf functions, so
>> I am wondering if it is possible to take advantage of this utility, by
>> making gcc detect whether printf prints floating point number and then
>> generate assembly directive in backend to pull in floating point
>> functions only if necessary.
>
> It wouldn't be at all difficult, but you'd have to change gcc.
>

Thanks Andrew.
How about the question:
The check is done in front end, so how should I expose the check
result to back-end. Is there any hook utility?

Thanks.
-- 
Best Regards.

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

* Re: Is it possible to make gcc detect whether printf prints floating point numbers?
  2012-06-08  9:57   ` Bin.Cheng
@ 2012-06-08 10:17     ` Andrew Haley
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2012-06-08 10:17 UTC (permalink / raw)
  To: gcc-help

On 06/08/2012 10:57 AM, Bin.Cheng wrote:
> On Fri, Jun 8, 2012 at 5:14 PM, Andrew Haley <aph@redhat.com> wrote:
>> [Redirect to gcc-help]
>>
>> On 06/08/2012 09:54 AM, Bin.Cheng wrote:
>>> In micro-controller applications, code size is critical and the size
>>> problem is worse if library is linked.
>>> For example, most c programs call printf to format output data, that
>>> means floating point code get linked even the program only want to
>>> output non-floating point numbers. Currently, we rely on end-user to
>>> call iprintf if the program does not want floating point.
>>>
>>> I noticed that GCC now can check format string of printf functions, so
>>> I am wondering if it is possible to take advantage of this utility, by
>>> making gcc detect whether printf prints floating point number and then
>>> generate assembly directive in backend to pull in floating point
>>> functions only if necessary.
>>
>> It wouldn't be at all difficult, but you'd have to change gcc.
>>
> 
> Thanks Andrew.
> How about the question:
> The check is done in front end, so how should I expose the check
> result to back-end.

I wouldn't.  I'd just call printf or iprintf, depending on the
use of floating-point.

Andrew.

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

end of thread, other threads:[~2012-06-08 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAHFci29a5rfe+5BeyHmfzXcV7T=mQkQW9XXtTo=7CvpM5=-zWQ@mail.gmail.com>
2012-06-08  9:14 ` Is it possible to make gcc detect whether printf prints floating point numbers? Andrew Haley
2012-06-08  9:57   ` Bin.Cheng
2012-06-08 10:17     ` Andrew Haley

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).