Currently working on a project that involves lowering to (mostly) LLVM IR dialect MLIR to be directly injected into Mojo source code and compiling it with the Mojo compiler.
Should I be using __mlir_region (as briefly visible in stdlib/builtin/coroutine.mojo) and then using __mlir_op for the operations within it? Or is there a more appropriate way to pass through entire MLIR regions?
If that is the recommended approach, is there a way of representing basic blocks with unstructured control flow?
I’m not aware of a good way to do this. The __mlir_region thing was developed with a specific narrow goal of unlocking the coroutine use case - I’m not sure how generalized it is, but you can give it a try to see if it works for you. Beyond that, there isn’t another way.
Mojo can’t build unstructured control flow, or multiple basic blocks, the optimizer doesn’t support that right now. :-/