Lowering an HLL to a specific dialect in mlir

  1. Is there any command that generate a specific mlir dialect file for a given source code (e.g: python file) ?
  2. Is there any command that lowers mlir to llvm-ir?

No. The client (language) is expected to write the lowering to whatever dialect mix they see fit. They may also introduce additional dialects that match the semantics of their language better. For C++, you can look at Polygeist. For Fortran, you can look at Flang. I’m not aware of any Python frontend.

For an MLIR module consisting only of dialects that have registered an LLVM IR translation interface implementation (LLVM, OpenMP, NVVM, etc. dialects), mlir-translate --mlir-to-llvmir is the command. Any other dialects must be converted (lowered). The specific details depend on the dialects.

1 Like

Actually I think there is some work in Numba with a lowering to MLIR (of course it isn’t full-fledge python either).

Here the repo: GitHub - intel/mlir-extensions: A staging ground for MLIR dialects and tools for Intel devices using the MLIR toolchain. (CC @Hardcode84)