Dialects can be translated to LLVM IR when they have the
LLVMTranslationDialectInterface interface registered. In case the
interface isn't explicitly registered, even the LLVM dialect can't be
exported to LLVM IR. This make the error message more explicit on this.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks!
I haven't gotten to some of the cleanups yet. Do you mind adding a test for these case?
Any suggestion how? mlir-translate --mlir-to-llvmir does not register any other dialect than the one that can be exported, so it can't parse the standard dialect for example. Locally I tested it by adding the standard dialect to the mlir-to-llvmir translation, but I don't think this is what we want here.
Test dialect doesn't have LLVM translation interface, and we can register it under #ifdef MLIR_INCLUDE_TESTS in mlir-translate.cpp similarly to what we do in mlir-opt.cpp. Failing to convert an operation sounds more intrusive. We could consider conditionally registering a translation for the test dialect based on some command-line flag (forwarded to a proper function), but I'm not sure it is worth it.
Actually we can't do that in mlir-translate.cpp like we did in mlir-opt.cpp because there is no dialect registry passed through this interface. We'd have to do it in ConvertToLLVMIR.cpp but I'm not sure it is desirable there, let me know if you have another idea I'll address this post-commit.