A simple question regarding LLVM intrinsics.

Hi. My name is Gil Dogon and I am working in MobileEye using LLVM in order to generate code for a proprietary processor.
Our processor architecture is very similar to MIPS, so I started to work using the "experimental" MIPS back end.

Anyway, my question is rather simple but somehow I did not find a quick answer to it in the documentation.

What I want to know, is how can the llvm.<something> intrinsics be used by the application programmer.

As a simple example take the llvm.ctlz intrinsic. How does one use it from C program ??

I guess there must be a ".h" file somewhere which defines some of those intrinsics for "C" and maybe some modification
for the llvm-gcc frontend is involved...

The question is more general. I guess some of the intrinsics are just for internal use by the LLVM passes, but in that case maybe
it would have been better to have them as LLVM IR instructions, if they are real intrinsics there should be a mechanism
which makes them visible somehow to the "C" programmer so they can be used ......

What I want to know, is how can the llvm.<something> intrinsics be used
by the application programmer.

At the IR level, you just call them. There isn't any general way to
write them in C.

As a simple example take the llvm.ctlz intrinsic. How does one use it
from C program ??

Use the gcc builtin __builtin_clz.

I guess there must be a ".h" file somewhere which defines some of those
intrinsics for "C" and maybe some modification
for the llvm-gcc frontend is involved...

If you're using llvm-gcc, you have to use the gcc mechanisms for
defining platform-specific builtins; I'm not really familiar with the
details.

The question is more general. I guess some of the intrinsics are just
for internal use by the LLVM passes, but in that case maybe
it would have been better to have them as LLVM IR instructions

Intrinsics are for "internal use" in the sense that they aren't real
functions. The reason we have both intrinsics and instructions is
that it's easier to add an intrinsic than an instruction. There
really isn't any substantial difference between intrinsics and
instructions in terms of what you're allowed to do with them.

-Eli