[mlir] Support verification order (2/3)
authorChia-hung Duan <chiahungduan@google.com>
Fri, 25 Feb 2022 18:17:30 +0000 (18:17 +0000)
committerChia-hung Duan <chiahungduan@google.com>
Fri, 25 Feb 2022 19:04:56 +0000 (19:04 +0000)
commit9445b39673c81e9b5ffeda0f71be0c1476e9f313
tree1a58978363f96942804dfdcffee69ddff092e82e
parentd04d9220e1c3d1b72cd2c7401fe684af16973bcc
[mlir] Support verification order (2/3)

    This change gives explicit order of verifier execution and adds
    `hasRegionVerifier` and `verifyWithRegions` to increase the granularity
    of verifier classification. The orders are as below,

    1. InternalOpTrait will be verified first, they can be run independently.
    2. `verifyInvariants` which is constructed by ODS, it verifies the type,
       attributes, .etc.
    3. Other Traits/Interfaces that have marked their verifier as
       `verifyTrait` or `verifyWithRegions=0`.
    4. Custom verifier which is defined in the op and has marked
       `hasVerifier=1`

    If an operation has regions, then it may have the second phase,

    5. Traits/Interfaces that have marked their verifier as
       `verifyRegionTrait` or
       `verifyWithRegions=1`. This implies the verifier needs to access the
       operations in its regions.
    6. Custom verifier which is defined in the op and has marked
       `hasRegionVerifier=1`

    Note that the second phase will be run after the operations in the
    region are verified. Based on the verification order, you will be able to
    avoid verifying duplicate things.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D116789
28 files changed:
mlir/docs/OpDefinitions.md
mlir/docs/Traits.md
mlir/include/mlir/Dialect/Affine/IR/AffineOps.h
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/TableGen/Interfaces.h
mlir/include/mlir/TableGen/Trait.h
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/IR/MLIRContext.cpp
mlir/lib/IR/Verifier.cpp
mlir/lib/TableGen/Interfaces.cpp
mlir/lib/TableGen/Trait.cpp
mlir/test/Dialect/Arithmetic/invalid.mlir
mlir/test/Dialect/GPU/invalid.mlir
mlir/test/Dialect/LLVMIR/global.mlir
mlir/test/Dialect/Linalg/invalid.mlir
mlir/test/Dialect/Linalg/named-ops.mlir
mlir/test/Dialect/SPIRV/IR/bit-ops.mlir
mlir/test/Dialect/Shape/invalid.mlir
mlir/test/Dialect/traits.mlir
mlir/test/IR/invalid-module-op.mlir
mlir/test/IR/traits.mlir
mlir/test/mlir-tblgen/op-decl-and-defs.td
mlir/test/mlir-tblgen/op-interface.td
mlir/test/mlir-tblgen/types.mlir
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp