Hi there,
I chatted with Valentin at the dev meeting about their use case. I might actually have a similar one in a researchy project: patch clang's codegen to emit MLIR Affine dialect for affine loops (there is a project doing the detection
https://repo.or.cz/w/pet.git) and LLVM dialect for the rest. It should be then possible to run affine transformations within MLIR and then lower everything to LLVM IR.
Independently of that, being able to convert from LLVM IR to MLIR may also be valuable for different reasons. I see two risks of having that:
- the LLVM dialect is currently intended as a "target" dialect on which we don't do much of the transformations (we will be able to run CSE once a patch lands, but there is not even a canonicalization involved); I'm not convinced we actually should transform the LLVM dialect within MLIR instead of letting LLVM do its job;
- somebody may want to raise the LLVM dialect up to Affine, or maybe even further (we have a paper with Polly folks on detecting higher-level operations starting from an affine abstraction), which may often be implemented better if we could enter MLIR infrastructure at a higher level than LLVM.
Other than these concerns, implementing an interface that looks like LLVM's IRBuilder is pretty straightforward, mostly forwarding the calls and sometimes extracting the type/attribute information. I'm not sure where such a thing would live in the MLIR code layout though.