This is an archive of the discontinued LLVM Phabricator instance.

[mlir][tosa] operation printing syntax prettification
ClosedPublic

Authored by tatwaichong on Jul 13 2023, 1:58 PM.

Details

Summary

The initial patch defines the printing format of tosa operations in
declarative and C++ manners to make alignment against more readable
syntax in other dialects. The general change to assembly output is
shown below.

from

%out = "tosa.op"(%input1, %input2, ...) : (type1, type2, ...) -> (out_type)

to

%out = tosa.op %input1, %input2, ... : (type1, type2, ...) -> out_type

There is a significant structural printing change to tosa control-flow
operations, cond_if and while_loop, aiming to provide more concise
and intuitive syntax. Note that we leave tosa.const unchanged. As this
op can be attached with quantization information, may need more tweaks
to distinguish plain integer type from quantized type for printing the
value in a concise form.

Diff Detail

Event Timeline

tatwaichong created this revision.Jul 13 2023, 1:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 1:58 PM
tatwaichong requested review of this revision.Jul 13 2023, 1:58 PM
sabauma added inline comments.Jul 14 2023, 10:00 AM
mlir/include/mlir/Dialect/Tosa/IR/TosaOpBase.td
224

You can consider using the functional-type(operands, results) specification for the type portion of the syntax. That will print like you expect while being more permissive with parenthesis in the parser.

rebase, and apply functional-type widely as suggested.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 15 2023, 11:18 AM
This revision was automatically updated to reflect the committed changes.