[Mlir-commits] [mlir] [MLIR][docs] Mention declarePromisedInterface in Interfaces doc (PR #88689)

Frederik Harwath llvmlistbot at llvm.org
Tue Apr 16 00:34:54 PDT 2024


================
@@ -299,6 +299,23 @@ owner of the dialect containing the object nor the owner of the interface are
 aware of an interface implementation, which can lead to duplicate or
 diverging implementations.
 
+Forgetting to register an external model can lead to bugs which are hard
+to track down. The `declarePromisedInterface` function can be used
+to declare that an external model implementation for an operation
+must eventually be provided.
+```
+  void MyDialect::initialize() {
+    declarePromisedInterface<SomeInterface, SomeOp>();
+     ...
+  }
+```
+Now attempting to use the interface, e.g in a cast, without a prior
+registration of the external model will lead to a runtime error that will
+look similar to this:
+```
+LLVM ERROR: checking for an interface (`SomeInterface`) that was promised by dialect 'mydialect' but never implemented. This is generally an indication that the dialect extension implementing the interface was never registered.
+```
----------------
frederik-h wrote:

> Maybe add:

That should be useful! Thanks for the addition.

https://github.com/llvm/llvm-project/pull/88689


More information about the Mlir-commits mailing list