[Mlir-commits] [mlir] [mlir] Allow using non-attribute properties in declarative rewrite patterns (PR #143071)

Krzysztof Drewniak llvmlistbot at llvm.org
Thu Jun 19 21:26:22 PDT 2025


================
@@ -487,6 +492,19 @@ void PatternEmitter::emitNativeCodeMatch(DagNode tree, StringRef opName,
       auto leaf = tree.getArgAsLeaf(i);
       if (leaf.isAttrMatcher() || leaf.isConstantAttr()) {
         os << "::mlir::Attribute " << argName << ";\n";
+      } else if (leaf.isPropMatcher()) {
+        StringRef interfaceType = leaf.getAsPropConstraint().getInterfaceType();
+        if (interfaceType.empty())
+          PrintFatalError(loc, "NativeCodeCall cannot have a property operand "
+                               "with unspecified interface type");
+        os << interfaceType << " " << argName;
+        if (leaf.isPropDefinition()) {
+          Property propDef = leaf.getAsProperty();
+          // Ensure properties that aren't zero-arg-constructable still work.
----------------
krzysz00 wrote:

No, it's a best-effort attempt to make that sort of thing work (since properties have a field letting you give their default value in their storage type)

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


More information about the Mlir-commits mailing list