nlvm
nlvm copied to clipboard
Mid-level intermediate representation (possibly using MLIR)?
Out of curiosity, I wonder if nlvm has any plans to implement IR like other languages:
Julia https://docs.julialang.org/en/v1/devdocs/ssair/ Rust https://rustc-dev-guide.rust-lang.org/mir/index.html#the-mir-mid-level-ir Swift https://github.com/apple/swift/blob/main/docs/SIL.rst Flang https://github.com/llvm/llvm-project/tree/main/flang
Any comments will be greatly appreciated. Thanks!
Yeah, I've thought about it, though it would actually be most powerful if done in the upstream compiler such that both the nlvm and C backends (which are quite similar at the end of the day) would use / benefit - one of the more difficult issues to deal with in nlvm
is bug-for-bug compatibility.
Ideally it would also integrate with an llvm-based CTFE engine such that the nim VM is no longer used (currently there's a VM in nim which quite significantly differs from the runtime code, which incidentally also has its own IR) and instead, the same ir is used for both VM and final compile.
--gc:arc
pretty much uses a Nim specific IR, it keeps changing though and some form of SSA would be useful to have.
Perhaps,
CIL : Common MLIR abstraction for C / C++/ Fortran https://github.com/compiler-tree-technologies/cil https://llvm.org/devmtg/2020-09/slides/CIL_Common_MLIR_Abstraction.pdf https://www.youtube.com/watch?v=3gcw-8C9UbA
might help (if and only if this or similar technologies are implemented in MLIR one day)?