[LLVMdev] Handling of built-in functions

Javier Martinez javier at jmartinez.org
Sat Jul 18 02:10:18 PDT 2009


Hello,

Just wondering if anyone had ideas on this and I apologize if bumps are 
frowned upon.

Thanks,
Javier

On 7/16/2009 2:07 AM, Javier Martinez wrote:
> Hi,
>
> I'm trying to add support in my back end for certain functions that 
> are seen as built-in by the target. Some of these functions can be 
> implemented in a) LLVM, and some in b) the native target language.
>
> My approach to case a) is to write the built-in function 
> implementation in C, compile it to LLVM using Clang, link it to the 
> module that uses it and finally add a pass to inline it. The last two 
> steps can be made inside a ModulePass. The definition of TargetMachine 
> allows for any pass manager deriving form BasicPass to be passed to 
> AddPassesToEmitFile. However, I see that llc uses a 
> FunctionPassManager for all the passes. A (module)PassManager is used 
> only if the target implements AddPassesToEmitWholeFile but the 
> comments on the base class discourage this path. Am I approaching the 
> problem the wrong way?
>
> I haven't worked much on case b) but my idea was to use a similar 
> approach but instead of writing the built-in function implementation 
> in straight C an asm block would be used to insert the code. Does this 
> make sense?
>
> Thanks,
> Javier
>
>



More information about the llvm-dev mailing list