[LLVMdev] Programmatically converting LLVM IR to native code

Eli Friedman eli.friedman at gmail.com
Thu Sep 20 02:57:23 PDT 2012


On Thu, Sep 20, 2012 at 2:42 AM, Baris Aktemur
<baris.aktemur at ozyegin.edu.tr> wrote:
> 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.

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

-Eli



More information about the llvm-dev mailing list