Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating LLVM Code from Java [closed]

Tags:

I want to use the LLVM code generation Framework from Java.

I.e., I do not want to compile Java code into LLVM. I simply want an LLVM library for code generation that I can call from Java. The usual LLVM library is C, so I cannot use it.

Are there any Java ports? If no, what would be the easiest way to do it anyway? Wrap the API into JNI?

like image 600
gexicide Avatar asked Sep 10 '12 20:09

gexicide


People also ask

Is LLVM open source?

LLVM is publicly available under an open source License. Also, you might want to check out the new features in Git that will appear in the next LLVM release. If you want them early, download LLVM through anonymous Git.

Does LLVM support Java?

Status (December 2019) All translations from Java to LLVM IR are complete. This means that all Java 7 language features---expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc.

Is LLVM a virtual machine?

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

Does Scala use LLVM?

Scala Native's key is the compiler generating LLVM intermediate representation, used to produce efficient platform-dependent machine code.


2 Answers

A quick search for llvm java api bindings turned out several projects that seem like a good fit:

  • LLVM-J
  • JLLVM
  • LAJ

All of those libraries use JNI to access the C-API, so you have a DLL or SO file of the LLVM itself in any case.

like image 182
nd. Avatar answered Sep 24 '22 03:09

nd.


To answer the question with more up-to-date information based on the current LLVM v3.6. Your options are:

  • RoboVM LLVM Java bindings part of RoboVM project supporting the current LLVM v3.6 (GPL License).
  • LLVM-J which moved to Github and supports LLVM v3.0 (MIT License).
  • JLLVM which supports LLVM v3.2 (LGBL License).

If GPL licensing is OK with you, then you should definitely go for RoboVM. It's an active project with robust support for the latest LLVM version. JLLVM and LLVM-J are no longer active so you will need to do some extra work using them.

like image 40
Codoka Avatar answered Sep 23 '22 03:09

Codoka