views:

172

answers:

2
+4  Q: 

How to embed LLVM?

As I understand, the LLVM Core project consists of:

  • Compiler - converts my source code to LLVM IR
  • VM - executes the compiled IR code

How can I embed this VM to my C++ application?

A: 

The LLVM is really a collection of libraries that you can link to, so it's pretty easy to embed. More often the LLVM takes IR that you generate and compiles it directly to machine code. There is also a library available to interpret and execute IR for platforms that do not support JIT compilation.

There's a pretty good tutorial available on the LLVM website here: http://llvm.org/docs/tutorial/. I suggest that you go through that and then ask more specific questions if you have them.

Evan Shaw
Which library exactly?
TTT
Likely you'll need several of them. LLVMCore, LLVMSupport, and LLVMSystem are the bare minimum. It really depends on what you want to do, exactly. For a somewhat outdated list, see: http://llvm.org/docs/UsingLibraries.html
Evan Shaw
+1  A: 

Take a look at the HowToUseJIT example in LLVM.

SK-logic