[mlir][OpFormatGen] Update "custom" directives for attributes.
authorMike Urbach <mikeurbach@gmail.com>
Wed, 23 Sep 2020 18:01:39 +0000 (18:01 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 23 Sep 2020 18:33:39 +0000 (18:33 +0000)
commitd14cfe10341681d18edf05ac98da2c5241b0864e
tree0be68c34d800f7789e4715e495c01a2d97c43427
parent11a75e6c92c9bde26f3c925b25135c2461afac1c
[mlir][OpFormatGen] Update "custom" directives for attributes.

This tweaks the generated code for parsing attributes with a custom
directive to call `addAttribute` on the `OperationState` directly,
and adds a newline after this call. Previously, the generated code
would call `addAttribute` on the `OperationState` field `attributes`,
which has no such method and fails to compile. Furthermore, the lack
of newline would generate code with incorrectly formatted single line
`if` statements. Added tests for parsing and printing attributes with
a custom directive.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D87860
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/op-format.mlir
mlir/tools/mlir-tblgen/OpFormatGen.cpp