This is an archive of the discontinued LLVM Phabricator instance.

Change dialect `printOperation()` hook to `getOperationPrinter()`
ClosedPublic

Authored by mehdi_amini on Aug 26 2021, 9:57 PM.

Details

Summary

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.

Diff Detail

Event Timeline

mehdi_amini created this revision.Aug 26 2021, 9:57 PM
mehdi_amini requested review of this revision.Aug 26 2021, 9:57 PM
rriddle accepted this revision.Aug 26 2021, 10:36 PM
This revision is now accepted and ready to land.Aug 26 2021, 10:36 PM

Use std::function instead of function_ref: this allows to return a capturing lambda

rriddle added inline comments.Aug 26 2021, 11:22 PM
mlir/include/mlir/IR/Dialect.h
124–125

Can we use unique_function instead?

mehdi_amini marked an inline comment as done.Aug 27 2021, 8:05 PM
mehdi_amini added inline comments.
mlir/include/mlir/IR/Dialect.h
124–125

Done!

This revision was automatically updated to reflect the committed changes.
mehdi_amini marked an inline comment as done.