[LLVMdev] Implementing platform specific library call simplification

Chris Lattner clattner at apple.com
Sun Feb 13 00:24:38 PST 2011


On Feb 2, 2011, at 10:11 AM, Richard Osborne wrote:
> The newlib C library provides iprintf(), a restricted version of printf 
> without support for floating-point formatting. I'd like to add an 
> optimization which turns calls to printf() into calls to iprintf() if 
> the format string has no floating point specifiers.

Cool, ok.  I can see how this would be very useful for a variety of embedded systems.

> At the moment I've got this working locally by adding code to the 
> simplify-libcalls pass. However this will break on targets where 
> iprintf() isn't available. Is there a sensible place to add information 
> about which library functions are available for a particular target?

I'd suggest adding a bool argument (HasIPrintf) to the createSimplifyLibCallsPass function and the pass constructor.  Then clang (or whatever is setting up the pass manager) can query the appropriate target info to pass down this flag.

Longer term, I'd like to introduce a simple interface (via TargetRegistry) for exposing target libcall info.  This would be useful to eliminate the HAVE_FLOORF etc #defines in simplifylibcalls, which break cross compilation.

-Chris



More information about the llvm-dev mailing list