[Mlir-commits] [mlir] [MLIR][Python] Add bindings for PDL native rewrite function registering (PR #159926)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Sep 23 07:10:29 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();
----------------
PragmaTwice wrote:

Done.

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


More information about the Mlir-commits mailing list