[mlir] ODS: support TableGen dag objects to specify OpBuilder parameters
authorAlex Zinenko <zinenko@google.com>
Fri, 16 Oct 2020 09:40:34 +0000 (11:40 +0200)
committerAlex Zinenko <zinenko@google.com>
Wed, 21 Oct 2020 09:42:50 +0000 (11:42 +0200)
commit6ec3872845dbb4d98a9e21ba43428ba2c023209b
treed7626020af4e326806806743b219e48730394a89
parent88241ffb5636ebc0579d3ab8eeec78446a769c54
[mlir] ODS: support TableGen dag objects to specify OpBuilder parameters

Historically, custom builder specification in OpBuilder has been accepting the
formal parameter list for the builder method as a raw string containing C++.
While this worked well to connect the signature and the body, this became
problematic when ODS needs to manipulate the parameter list, e.g. to inject
OpBuilder or to trim default values when generating the definition. This has
also become inconsistent with other method declarations, in particular in
interface definitions.

Introduce the possibility to define OpBuilder formal parameters using a
TableGen dag similarly to other methods. Additionally, introduce a mechanism to
declare parameters with default values using an additional class. This
mechanism can be reused in other methods. The string-based builder signature
declaration is deprecated and will be removed after a transition period.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D89470
mlir/docs/OpDefinitions.md
mlir/include/mlir/IR/OpBase.td
mlir/test/mlir-tblgen/op-decl.td
mlir/test/mlir-tblgen/op-error.td [new file with mode: 0644]
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp