[Mlir-commits] [mlir] [MLIR][Python] Add bindings for PDL native rewrite function registering (PR #159926)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Sep 23 00:27:58 PDT 2025
================
@@ -24,6 +27,27 @@ using namespace mlir::python;
namespace {
#if MLIR_ENABLE_PDL_IN_PATTERNMATCH
+nb::object objectFromPDLValue(MlirPDLValue value) {
+ if (mlirPDLValueIsValue(value))
+ return nb::cast(mlirPDLValueAsValue(value));
+ if (mlirPDLValueIsOperation(value))
+ return nb::cast(mlirPDLValueAsOperation(value));
+ if (mlirPDLValueIsAttribute(value))
+ return nb::cast(mlirPDLValueAsAttribute(value));
+ if (mlirPDLValueIsType(value))
+ return nb::cast(mlirPDLValueAsType(value));
+
+ throw std::runtime_error("unsupported PDL value type");
+}
+
+MlirLogicalResult logicalResultFromObject(const nb::object &obj) {
+ if (obj.is_none())
+ return mlirLogicalResultSuccess();
----------------
ftynse wrote:
I wouldn't necessarily interpret `None` as success. Please document and potentially change the name to reflect this.
https://github.com/llvm/llvm-project/pull/159926
More information about the Mlir-commits
mailing list