Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mlir/test/mlir-tblgen/op-properties-predicates.td
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -4764,6 +4764,7 @@ void OpOperandAdaptorEmitter::addVerification() {

FmtContext verifyCtx;
populateSubstitutions(emitHelper, verifyCtx);
genPropertyVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter);
genAttributeVerifier(emitHelper, verifyCtx, body, staticVerifierEmitter,
useProperties);

Expand Down