Programmatically converting LLVM IR to native code

I am generating LLVM IR code and I would like to convert this IR code to native code using the LLVM C++ API. This would be very similar to what’s done in the Kaleidoscope tutorial, but instead of relying on JIT compilation, I’d like to emit native code – the same native code that’s produced by llc, for instance.

I’m sure this is possible, but I wasn’t able to find the resource I need. Any help would be much appreciated.

Thanks in advance.

-Baris Aktemur

Have you looked at the source code for "llc" itself (in
tools/llc/llc.cpp)? The API you're looking for is


Thank you. I've started adapting this code.

-Baris Aktemur