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

Matthias Springer via All-commits all-commits at lists.llvm.org
Thu Aug 8 02:47:58 PDT 2024


  Branch: refs/heads/users/matthias-springer/ods_type_verifier
  Home:   https://github.com/llvm/llvm-project
  Commit: 33db3e644d2ad6eaff6bcd57d23ed33538bf0b97
      https://github.com/llvm/llvm-project/commit/33db3e644d2ad6eaff6bcd57d23ed33538bf0b97
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-08-08 (Thu, 08 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/Dialect/SparseTensor/IR/SparseTensorDialect.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