I’m looking for frontend tools that can generate MLIR code directly instead of LLVM IR. My main focus is on parsing C/C++ and Java source files. I was wondering if the current version of clang has this capability built in. From what I can see in the documentation, there don’t seem to be many options available right now. Has anyone found working solutions for converting these languages to MLIR format? I need this for a project where I want to work with MLIR’s intermediate representation rather than going through the traditional LLVM pipeline. Any suggestions or experiences would be really helpful.
wait, which mlir dialects are u planning to use? what transformations r u after that make mlir better than just sticking with llvm ir?
flang (fortran frontend) has mlir support now if that helps. honestly the ecosystem’s still pretty limited compared to llvm ir - most tools target llvm first, then maybe add mlir later. worth checking out polygeist for c/c++ to mlir conversion, it’s been gaining traction lately.
Yes, Clang does support MLIR output using the -emit-mlir flag, but it’s still a developing feature. The standard frontend can produce MLIR from C/C++ code, though this will typically be at a higher level than LLVM IR. Depending on your specific requirements, you might need additional lowering passes. For Java, the situation is more complex as Clang doesn’t natively process it—consider using Java bytecode to MLIR converters or developing custom frontend passes. Be prepared for a greater degree of manual dialect registration and pass management with MLIR, which adds to the complexity compared to standard LLVM workflows.