diff --git a/flang/tools/tco/tco.cpp b/flang/tools/tco/tco.cpp --- a/flang/tools/tco/tco.cpp +++ b/flang/tools/tco/tco.cpp @@ -86,7 +86,7 @@ errs() << "Error can't load file " << inputFilename << '\n'; return mlir::failure(); } - if (mlir::failed(owningRef->verify())) { + if (mlir::failed(owningRef->verifyInvariants())) { errs() << "Error verifying FIR module\n"; return mlir::failure(); } diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -564,14 +564,13 @@ _additional_ verification, you can use ```tablegen -let verifier = [{ - ... -}]; +let hasVerifier = 1; ``` -Code placed in `verifier` will be called after the auto-generated verification -code. The order of trait verification excluding those of `verifier` should not -be relied upon. +This will generate a `LogicalResult verify()` method declaration on the op class +that can be defined with any additional verification constraints. This method +will be invoked after the auto-generated verification code. The order of trait +verification excluding those of `hasVerifier` should not be relied upon. ### Declarative Assembly Format diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h @@ -225,7 +225,7 @@ static StringRef getOperationName() { return "affine.dma_start"; } static ParseResult parse(OpAsmParser &parser, OperationState &result); void print(OpAsmPrinter &p); - LogicalResult verify(); + LogicalResult verifyInvariants(); LogicalResult fold(ArrayRef cstOperands, SmallVectorImpl &results); @@ -313,7 +313,7 @@ static StringRef getTagMapAttrName() { return "tag_map"; } static ParseResult parse(OpAsmParser &parser, OperationState &result); void print(OpAsmPrinter &p); - LogicalResult verify(); + LogicalResult verifyInvariants(); LogicalResult fold(ArrayRef cstOperands, SmallVectorImpl &results); }; diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -2451,7 +2451,16 @@ // Custom assembly format. string assemblyFormat = ?; - // Custom verifier. + // A bit indicating if the operation has additional invariants that need to + // verified (aside from those verified by other ODS constructs). If set to `1`, + // an additional `LogicalResult verify()` declaration will be generated on the + // operation class. The operation should implement this method and verify the + // additional necessary invariants. + bit hasVerifier = 0; + // A custom code block corresponding to the extra verification code of the + // operation. + // NOTE: This field is deprecated in favor of `hasVerifier` and is slated for + // deletion. code verifier = ?; // Whether this op has associated canonicalization patterns. diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -201,7 +201,7 @@ protected: /// If the concrete type didn't implement a custom verifier hook, just fall /// back to this one which accepts everything. - LogicalResult verify() { return success(); } + LogicalResult verifyInvariants() { return success(); } /// Parse the custom form of an operation. Unless overridden, this method will /// first try to get an operation parser from the op's dialect. Otherwise the @@ -1604,6 +1604,7 @@ public: /// Inherit getOperation from `OpState`. using OpState::getOperation; + using OpState::verifyInvariants; /// Return if this operation contains the provided trait. template