[Mlir-commits] [mlir] bd04138 - [mlir] Add non-attribute property predicates to adaptor verifiers (#150881)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 31 08:30:28 PDT 2025
Author: Krzysztof Drewniak
Date: 2025-07-31T10:30:24-05:00
New Revision: bd041389351dc920a6b7a6cc6703e30af5d0ad23
URL: https://github.com/llvm/llvm-project/commit/bd041389351dc920a6b7a6cc6703e30af5d0ad23
DIFF: https://github.com/llvm/llvm-project/commit/bd041389351dc920a6b7a6cc6703e30af5d0ad23.diff
LOG: [mlir] Add non-attribute property predicates to adaptor verifiers (#150881)
When adding a predicated field to non-attribute properties /
implemneting PropConstraint, a call to genPropertyVerifiers() wasn't
added to the generation sequence for [Op]GenericAdaptor::verify. This
commit fixes the issue.
Added:
Modified:
mlir/test/mlir-tblgen/op-properties-predicates.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/mlir-tblgen/op-properties-predicates.td b/mlir/test/mlir-tblgen/op-properties-predicates.td
index 7cd24aad97424..af09ee7c12f53 100644
--- a/mlir/test/mlir-tblgen/op-properties-predicates.td
+++ b/mlir/test/mlir-tblgen/op-properties-predicates.td
@@ -70,6 +70,12 @@ def OpWithPredicates : NS_Op<"op_with_predicates"> {
// CHECK-NEXT: if (!(((!prop.has_value())) || ((::llvm::all_of((*(prop)), [](const int64_t& baseStore) -> bool { return [](int64_t baseIface) -> bool { return ((baseIface >= 0)); }(baseStore); })) && (!(((*(prop)).empty()))))))
// CHECK: failed to satisfy constraint: optional non-empty array of non-negative int64_
+// CHECK-LABEL: ::llvm::LogicalResult OpWithPredicatesAdaptor::verify
+// Note: comprehensive emission of verifiers is tested in verifyINvariantsImpl() below
+// CHECK: int64_t tblgen_scalar = this->getScalar();
+// CHECK: if (!((tblgen_scalar >= 0)))
+// CHECK: return emitError(loc, "'test.op_with_predicates' op ""property 'scalar' failed to satisfy constraint: non-negative int64_t");
+
// CHECK-LABEL: OpWithPredicates::verifyInvariantsImpl()
// Note: for test readability, we capture [[maybe_unused]] into the variable maybe_unused
// CHECK: [[maybe_unused:\[\[maybe_unused\]\]]] int64_t tblgen_scalar = this->getScalar();
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index f35cfa6826388..8ea4eb7b3eeca 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -1127,7 +1127,7 @@ static void genPropertyVerifier(
body << formatv(fetchProperty, varName, getterName,
prop.prop.getInterfaceType());
auto uniquedFn = staticVerifierEmitter.getPropConstraintFn(prop.prop);
- if (uniquedFn.has_value())
+ if (uniquedFn.has_value() && emitHelper.isEmittingForOp())
body << formatv(verifyPropertyUniqued, *uniquedFn, varName, prop.name);
else
body << formatv(
@@ -4764,6 +4764,7 @@ void OpOperandAdaptorEmitter::addVerification() {
FmtContext verifyCtx;
populateSubstitutions(emitHelper, verifyCtx);
+ genPropertyVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter);
genAttributeVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter,
useProperties);
More information about the Mlir-commits
mailing list