This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow passing AsmState when printing Attributes and Types
ClosedPublic

Authored by rriddle on Aug 26 2022, 3:55 AM.

Details

Summary

This allows for extracting assembly information when printing an attribute
or type, such as the dialect resources referenced. This functionality is used in
a followup that adds resource support to the bytecode. This change also results
in a nice cleanup of AsmPrinter now that we don't need to awkwardly workaround
optional AsmStates.

Diff Detail

Event Timeline

rriddle created this revision.Aug 26 2022, 3:55 AM
rriddle requested review of this revision.Aug 26 2022, 3:55 AM
jpienaar accepted this revision.Aug 30 2022, 6:59 PM

Would this also allow be propagated down to custom printers that want to access AsmState/OpPrintingFlags?

This revision is now accepted and ready to land.Aug 30 2022, 6:59 PM
tpopp added a subscriber: tpopp.Aug 31 2022, 2:55 AM

Drive by warning. If this patch is depending on a non-landed commit, this comment might be wrong. It looks like one python binding test case will fail with this patch:

Exit Code: 2

Command Output (stderr):
--
<mlir_parser_buffer>:1:1: error: expected non-function type
BAD_TYPE_DOES_NOT_EXIST
^
error: vector elements must be int/index/float type but got 'none'
error: invalid tensor element type: 'none'
error: invalid tensor element type: 'none'
...
********************
Failed Tests (1):
  MLIR :: python/ir/builtin_types.py

This is only tested with cmake ... -DMLIR_ENABLE_BINDINGS_PYTHON=On and has dependencies on python -m pip install -r mlir/python/requirements.txt

rriddle updated this revision to Diff 458251.Sep 6 2022, 1:02 PM
rriddle edited the summary of this revision. (Show Details)

Would this also allow be propagated down to custom printers that want to access AsmState/OpPrintingFlags?

Yeah, it should make it a bit easier to propagate stuff along.

Drive by warning. If this patch is depending on a non-landed commit, this comment might be wrong. It looks like one python binding test case will fail with this patch:

Exit Code: 2

Command Output (stderr):
--
<mlir_parser_buffer>:1:1: error: expected non-function type
BAD_TYPE_DOES_NOT_EXIST
^
error: vector elements must be int/index/float type but got 'none'
error: invalid tensor element type: 'none'
error: invalid tensor element type: 'none'
...
********************
Failed Tests (1):
  MLIR :: python/ir/builtin_types.py

This is only tested with cmake ... -DMLIR_ENABLE_BINDINGS_PYTHON=On and has dependencies on python -m pip install -r mlir/python/requirements.txt

Thanks for this, fixed.