Yeah so MLIR is basically perfect for this. MLIR [1] is like a new LLVM thing that can compile to LLVM IR, but it can also compile to C code or SPIRV or whatever. It’s what clang is currently being rewritten in [2], LLVM version of Fortran uses it [3], and Chris Lattners new language Mojo is basically a thin wrapper around it [4] [5]
I guess the main thing I'm worried about is that, since Guile is a GNU project, I thought maybe there's some sort of cultural or policy restriction in the Guile community to not use LLVM and instead use something like libgccjit [6] like what Rust is doing for its GCC backend [7] If that's not the case, then I would strongly encourage MLIR for this use case. [1] https://mlir.llvm.org/ [2] https://github.com/llvm/clangir [3] https://blog.llvm.org/posts/2025-03-11-flang-new/ [4] https://arxiv.org/pdf/2509.21039 [5] https://docs.modular.com/mojo/vision/#mlir-core [6] https://gcc.gnu.org/onlinedocs/jit/ [7] https://github.com/rust-lang/rustc_codegen_gcc Get Outlook for iOS<https://aka.ms/o0ukef> ________________________________ From: Olivier Dion <[email protected]> Sent: Saturday, November 1, 2025 4:39:15 PM To: Srayan Jana <[email protected]>; guile-devel <[email protected]> Subject: Re: What’s more useful, Guile to C or Guile to MLIR? On Sat, 01 Nov 2025, Srayan Jana <[email protected]> wrote: > Hello again! > I'm seriously considering spending some time for the rest of the year working > on some sort of Ahead of Time compiler for Guile that reuses parts of Hoot. > However, I have a question that is going to decide what I'm going to spend > most of my time on. > Should I try to aim for Guile to C or Guile to MLIR? > Personally, I'm much more interested in MLIR (especially since MLIR > has an option to emit c anyways) My 2 cents. To IR, simply because we can apply more optimizations at that level if needed or we can transform the code to other representation like GPU kernel instead of C. As for MLIR, I never heard of it, but I would avoid targeting a complex IR base on LLVM. Have you considered something like QBE [0] ? Thanks, Olivier [0] https://c9x.me/compile/doc/llvm.html -- Olivier Dion oldiob.ca
