[Mlir-commits] [mlir] [mlir-c] Add ConversionTarget dynamic legality C API (PR #206161)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jun 28 21:50:59 PDT 2026
================
@@ -533,6 +533,37 @@ MLIR_CAPI_EXPORTED void
mlirConversionTargetAddIllegalDialect(MlirConversionTarget target,
MlirStringRef dialectName);
+/// Callback for dynamic legality checks. Return true if the operation is
+/// legal, false if illegal.
+typedef bool (*MlirConversionTargetDynamicLegalityCallback)(MlirOperation op,
+ void *userData);
----------------
PragmaTwice wrote:
I notice that in C++ the `DynamicLegalityCallbackFn` is defined as
```c++
using DynamicLegalityCallbackFn =
std::function<std::optional<bool>(Operation *)>;
```
Not sure what's difference between `false` and `nullopt`. Here we just use `bool` so the callback cannot return a `nullopt` state?
https://github.com/llvm/llvm-project/pull/206161
More information about the Mlir-commits
mailing list