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

Gil Dogon gil.dogon at mobileye.com
Tue Mar 3 01:53:26 PST 2009


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 ?



More information about the llvm-dev mailing list