[LLVMdev] API on JIT, code snippets

Misha Brukman brukman at uiuc.edu
Mon Aug 9 05:57:57 PDT 2004


On Mon, Aug 09, 2004 at 12:11:03AM +0400, Valery A.Khamenya wrote:
> What about very small JIT-based example similar 
> to ModuleMaker?
> 
> I mean example, where, say, two simple functions are 
> created, inserted to a Module/BasicBlock, then executed 
> via JIT and result is passed to a driver. 
> It would be really great.

Your example would essentially take lli.cpp and hack out the part where
the bytecode is read from a file to instead construct a Module directly.
See the part where there's a ModuleProvider created from an InputFile
and then ExecutionEngine::create() is called on the ModuleProvider.
That's about all that would need to change.

You can also use ExecutionEngine::runFunctionAsMain() if you wish.

For a trivial example, if you look through the Module, ModuleProvider,
and ExecutionEngine interfaces, you can probably simplify lli.cpp a
great deal to work with a single main() function in a Module with one
return statement.

HTH,
-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list