defaultDialect = iface->getDefaultDialect();
} else {
Optional<Dialect::ParseOpHook> dialectHook;
- if (Dialect *dialect = opNameInfo->getDialect())
- dialectHook = dialect->getParseOperationHook(opName);
+ Dialect *dialect = opNameInfo->getDialect();
+ if (!dialect) {
+ InFlightDiagnostic diag =
+ emitError(opLoc) << "Dialect `" << opNameInfo->getDialectNamespace()
+ << "' not found for custom op '" << originalOpName
+ << "' ";
+ if (originalOpName != opName)
+ diag << " (tried '" << opName << "' as well)";
+ auto ¬e = diag.attachNote();
+ note << "Registered dialects: ";
+ llvm::interleaveComma(getContext()->getAvailableDialects(), note,
+ [&](StringRef dialect) { note << dialect; });
+ note << " ; for more info on dialect registration see "
+ "https://mlir.llvm.org/getting_started/Faq/"
+ "#registered-loaded-dependent-whats-up-with-dialects-management";
+ return nullptr;
+ }
+ dialectHook = dialect->getParseOperationHook(opName);
if (!dialectHook) {
InFlightDiagnostic diag =
emitError(opLoc) << "custom op '" << originalOpName << "' is unknown";
// -----
+func.func @unknown_dialect_operation() {
+ // expected-error@below {{Dialect `foo' not found for custom op 'foo.asd'}}
+ // expected-note-re@below {{Registered dialects:{{.*}} test{{.*}}}}
+ foo.asd
+}
+
+// -----
+
func.func @non_operation() {
// expected-error@+1 {{custom op 'asd' is unknown (tried 'func.asd' as well)}}
asd