Change dialect `printOperation()` hook to `getOperationPrinter()`
authorMehdi Amini <joker.eph@gmail.com>
Sat, 28 Aug 2021 03:02:55 +0000 (03:02 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Tue, 31 Aug 2021 17:52:39 +0000 (17:52 +0000)
commitfd87963eee23f6cf2aed97bf182a6b3f5e9450ed
tree7ad92f1652b039d4f3c39b1e39e175ee5ba0dd10
parent6726a3d858ac40de32efb9da4af4cd8e44454981
Change dialect `printOperation()` hook to `getOperationPrinter()`

This makes the hook return a printer if available, instead of using LogicalResult  to
indicate if a printer was available (and invoked). This allows the caller to detect that
the dialect has a printer for a given operation without actually invoking the printer.
It'll be leveraged in a future revision to move printing the op name itself under control
of the ASMPrinter.

Differential Revision: https://reviews.llvm.org/D108803
mlir/include/mlir/IR/Dialect.h
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/Dialect.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td