I have tried this twice 2-3 years ago with Verona and our experience wasn’t great.
The semantics of modules, functions, regions is too restrictive to do clever AST things (one of the issues was the topic of this RFC), the symbol table doesn’t have proper support for nesting and cross-module access, and anything that becomes shared (singleton) has to become a global in a module, so inaccessible from another module, and bam: duplication.
If Mojo is trying to go that way, I’d love to hear about the problems you guys are having and if you share my experiences.
But indeed this is a conceptual question: do we want to extend (and complicate) MLIR to become an AST replacement? Or do we keep it as a high-level IR to replace many of the existing LLVM optimizations at the right level?
With Clang and Flang and possibly other off-tree front-ends using MLIR as their output, trying to move MLIR up could gather wider consensus. But the risks of making the IR more complicated needs to be weighed in for the transformations that we stil want to do at the Linalg/SCF level without having to do full dominance analysis that makes LLVM IR a pain to work with.