[all-commits] [llvm/llvm-project] bb2106: [mlir][ODS] Verify type constraints in Types and A...

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Aug 7 09:16:55 PDT 2024


  Branch: refs/heads/users/matthias-springer/ods_type_verifier
  Home:   https://github.com/llvm/llvm-project
  Commit: bb210672984e9b0f54d0d67d84d38e1086bf57f5
      https://github.com/llvm/llvm-project/commit/bb210672984e9b0f54d0d67d84d38e1086bf57f5
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-08-07 (Wed, 07 Aug 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/GPU/IR/GPUDialect.h
    M mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
    M mlir/include/mlir/Dialect/Quant/QuantTypes.h
    M mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
    M mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
    M mlir/include/mlir/IR/CommonTypeConstraints.td
    M mlir/include/mlir/IR/Constraints.td
    M mlir/include/mlir/IR/StorageUniquerSupport.h
    M mlir/include/mlir/IR/Types.h
    M mlir/include/mlir/TableGen/AttrOrTypeDef.h
    M mlir/include/mlir/TableGen/Class.h
    M mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    M mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
    M mlir/lib/Dialect/Quant/IR/QuantTypes.cpp
    M mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
    M mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
    M mlir/lib/TableGen/AttrOrTypeDef.cpp
    A mlir/test/IR/test-verifiers-type.mlir
    M mlir/test/lib/Dialect/Test/TestAttrDefs.td
    M mlir/test/lib/Dialect/Test/TestTypeDefs.td
    M mlir/test/mlir-tblgen/attr-or-type-format.td
    M mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
    M mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp

  Log Message:
  -----------
  [mlir][ODS] Verify type constraints in Types and Attributes

When a type/attribute is defined in TableGen, a type constraint can be used for parameters, but the type constraint verification was missing.

Example:
```
def TestTypeVerification : Test_Type<"TestTypeVerification"> {
  let parameters = (ins AnyTypeOf<[I16, I32]>:$param);
  // ...
}
```

No verification code was generated to ensure that `$param` is I16 or I32.

When type constraints a present, a new method will generated for types and attributes: `verifyInvariantsImpl`. (The naming is similar to op verifiers.) The user-provided verifier is called `verify` (no change). There is now a new entry point to type/attribute verification: `verifyInvariants`. This function calls both `verifyInvariantsImpl` and `verify`. If neither of those two verifications are present, the `verifyInvariants` function is not generated.

When a type/attribute is not defined in TableGen, but a verifier is needed, users can implement the `verifyInvariants` function. (This function was previously called `verify`.)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list