[all-commits] [llvm/llvm-project] 9627b6: [mlir][ODS] Optionally generate public C++ functio...

Matthias Springer via All-commits all-commits at lists.llvm.org
Tue Aug 20 00:27:54 PDT 2024


  Branch: refs/heads/users/matthias-springer/type_constr_cpp_function
  Home:   https://github.com/llvm/llvm-project
  Commit: 9627b6acae11071a605886e7cb72b4231695ec37
      https://github.com/llvm/llvm-project/commit/9627b6acae11071a605886e7cb72b4231695ec37
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M mlir/include/mlir/IR/BuiltinTypes.h
    M mlir/include/mlir/IR/BuiltinTypes.td
    M mlir/include/mlir/IR/CMakeLists.txt
    M mlir/include/mlir/IR/Constraints.td
    M mlir/include/mlir/TableGen/Constraint.h
    M mlir/lib/IR/BuiltinTypes.cpp
    M mlir/lib/IR/CMakeLists.txt
    M mlir/lib/TableGen/Constraint.cpp
    A mlir/test/mlir-tblgen/type-constraints.td
    M mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

  Log Message:
  -----------
  [mlir][ODS] Optionally generate public C++ functions for type constraints

Add `gen-type-constraint-decls` and `gen-type-constraint-defs`, which generate public C++ functions for type constraints. The name of the C++ function is specified in the `cppFunctionName` field.

Type constraints are typically used for op/type/attribute verification. They are also sometimes called from builders and transformations. Until now, this required duplicating the check in C++.

Note: This commit just adds the option for type constraints, but attribute constraints could be supported in the same way.

Alternatives considered:
1. The C++ functions could also be generated as part of `gen-typedef-decls/defs`, but that can be confusing because type constraints may rely on type definitions from multiple `.td` files.
2. The C++ functions could also be generated as static member functions of dialects, but they don't really belong to a dialect. (Because they may rely on type definitions from multiple dialects.)


  Commit: 79eb5772cae398165f0e9676a8213b3c27fd0544
      https://github.com/llvm/llvm-project/commit/79eb5772cae398165f0e9676a8213b3c27fd0544
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

  Log Message:
  -----------
  address comments


  Commit: 0f019541cdeb928b59cd04d8ff85c7e7003e2d56
      https://github.com/llvm/llvm-project/commit/0f019541cdeb928b59cd04d8ff85c7e7003e2d56
  Author: Matthias Springer <mspringer at nvidia.com>
  Date:   2024-08-20 (Tue, 20 Aug 2024)

  Changed paths:
    M mlir/docs/DefiningDialects/AttributesAndTypes.md
    M mlir/lib/IR/BuiltinTypes.cpp
    M mlir/test/mlir-tblgen/type-constraints.td
    M mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

  Log Message:
  -----------
  address comments


Compare: https://github.com/llvm/llvm-project/compare/82d69f29e82c...0f019541cdeb

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