[LLVMdev] Adding Intrinsics for custom processor (frotend problem)

Richard Osborne richard at xmos.com
Tue Mar 3 03:12:03 PST 2009


Personally I would just modify the frontend - it's not that hard once 
you know where to look . In this case all you need to do is add the 
declaration of your builtin to the TARGET_INIT_BUILTINS target hook (see 
the gcc internals manual) defined in the gcc/config directory 
corresponding to your target. If the name the the declaration matches 
the name used with GCCBuiltin in the intrinsics td file then any calls 
to the gcc builtin in the source should get automatically translated to 
the calls to the LLVM intrinsic.

Gil Dogon wrote:
> As mentioned in an earlier mail, I am working on an LLVM backend for a 
> custom processor based on MIPS.
> My problem is how to extend LLVM to support some esoteric/non-standard 
> feature of the underlying hardware.
> I saw in the "Extending LLVM" document, that the easiest / most common 
> way to do this was using an intrinsic function,
> and examples of the technique abound (all SSE for example).
> My problem though as mentioned before is that  the frontend support for 
> intrinsics, is undocumented, and implemented
> in  llvm-gcc which I prefer not to hack with (I  use a binary 
> precompiled one).  As far as I could see it supports the
> intrinsics using gcc style __builtin_ function names.
>
> Currently what I think to do , is the following :
>
> 1. Define my intrinsics in a special (which would be preincluded in our 
> build system) .h file (using whatever name convention I want)
> 2. Then I need to add a pass to llvm which will translate the names of 
> those intrinsics to llvm style names , since
>    LLVM intrinsics start with "llvm." which makes them non legal as "C" 
> identifiers.
>
> I have two questions :
>
> 1. Is that the right way to go, or is there a simpler/more standard way 
> to have frontend support for new architecture intrinsics ?
>
> 2. If thats the simplest way , I would like to have a quick advice on 
> how to write the rather trivial pass described in '2'.
>    I guess that I need to replace a given Function object with an 
> allmost identical one, but with a different name (the "llvm.something' name
>   of the intrisic)   What is the correct code to do this ?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>   


-- 
Richard Osborne | XMOS
http://www.xmos.com





More information about the llvm-dev mailing list