Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to embed LLVM Interpreter in my software and does it make sense?

Suppose I have a software and I want to make cross-plataform plugins. You compile the plugin for a virtual machine, and any platform running my software would be able to run this code.

I am wondering if it is possible to use LLVM interpreter and bytecode for this purpose. Also, I am wondering if does make sense using LLVM for this purpose instead of something else, i.e. is it what LLVM was made for?

like image 362
André Puel Avatar asked Nov 08 '11 16:11

André Puel


People also ask

Is LLVM an interpreter?

LLVM provides an interpreter tool lli which is capable of interpreting LLVM bitcode and JIT compiler using both aforementioned Execution Engine.

Why should I use LLVM?

LLVM helps build new computer languages and improve existing languages. It automates many of the difficult and unpleasant tasks involved in language creation, such as porting the outputted code to multiple platforms and architectures.

Is LLVM cross platform?

LLVM IR can be cross-platform, with the obvious exceptions others have listed. However, that does not mean Clang generates cross-platform code. As you note, the preprocessor is almost universally used to only pass parts of the code to the C/C++ compiler, depending on the platform.

Is LLVM a virtual machine?

LLVM isn't a virtual machine. LLVM is not a virtual machine. It's a compiler infrastructure.


1 Answers

There is VMIR (https://github.com/andoma/vmir) which is a LLVM bitcode interpreter / JIT engine that's intended to be embedded into other apps.

Disclaimer: I'm the author of it and it's still work-in-progress but works reasonable well.

like image 113
andoma Avatar answered Oct 03 '22 00:10

andoma