How to embed LLVM?
Asked Answered
E

2

16

The LLVM Core project consists of:

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

How can I embed the VM to a C++ application?

Emmott answered 20/8, 2010 at 0:55 Comment(2)
More typically LLVM is used to compile directly to machine code. I'm not familiar with the latest, but Apple Clang is the most active LLVM project, and it's being postured as a competitor to GCC.Benford
@Potatoswatter: unfortunately Clang is still a bit lacking (especially in C++0x features) but I have great hope indeed. Also the modular design is just so useful, a great many editors could benefit from its parser.Pass
D
8

Take a look at the HowToUseJIT example in LLVM.

Dichroscope answered 21/8, 2010 at 12:30 Comment(0)
F
9

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.

Forbidding answered 20/8, 2010 at 13:25 Comment(1)
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: llvm.org/docs/UsingLibraries.htmlForbidding
D
8

Take a look at the HowToUseJIT example in LLVM.

Dichroscope answered 21/8, 2010 at 12:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.