I'm fully aware that a similar question was already asked here: Generating LLVM Code from Java
The thing is, that was in 2012...I looked at the solutions and found most of the projects mentioned abandoned or at least very inactive. So, as someone who is most used to working with Java, what would be my options for working with LLVM (to create a toy language, not using clang or anything)?
Just to finally answer this, Java C++ Presets are a useful and mostly-upto-date option for this: https://github.com/bytedeco/javacpp-presets/tree/master/llvm
I came across the same problem recently since I'm using ANTLR in Java/Scala to define my lexer and parser and LLVM to generate the actual machine code through its IR. In trying to bind JVM-based front-end to LLVM IR and back-end I am actually trying to use GraalVM https://www.graalvm.org/ since it offers a seamless way to interact across languages, including the LLVM bitcode, using its Polyglot.
Here some references:
You should be able to access LLVM IR directly from your Java/Scala code or vice versa, you could access your AST in JVM-based language from LLVM/C++ code using Polyglot calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With