Intrinsics and external functions

Dear all,

I recently started using LLVM to design a simple compiler and I got stuck at the DAG->DAG instruction selection.

Let me describe you the situation:

     - I implemented a simple language and I was successful with obtaining the LLVM IR.
     - Most of the operations were calls to external functions.
     - I successful JITed it for the x86 backend.
     - Then, I replaced the function calls by intrinsics so that I can take advantage of the LLVM optimization passes. I updated the IntrinsicsX86.td and the files concerning constant folding with this purpose.
     - The LLVM IR with the intrinsics looks great and benefits from all the optimization passes I was using.
     - Now, while Jitting to the x86 backend I got the error message "Cannot select: intrinsics %llvm.x86.my.intrinsic.name".

The obtained error makes sense: I did not inserted any information in the x86.td files to tell the tool how the intrinsic is supposed to be executed.

After looking to the way other intrinsics are implemented for the X86 backend I could not find any similar example to what I am trying to do: treat the calls as intrinsics and JIT them has normal external function calls.

Am I trying to do something not possible? Am I missing some simple step? Any document to look at as reference?

Any help is more than appreciated,

Regards,
Samuel