This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add support for parsing optional Attribute values.
ClosedPublic

Authored by rriddle on Jul 13 2020, 12:49 PM.

Details

Summary

This adds a parseOptionalAttribute method to the OpAsmParser that allows for parsing optional attributes, in a similar fashion to how optional types are parsed. This also enables the use of attribute values as the first element of an assembly format optional group.

Diff Detail

Event Timeline

rriddle created this revision.Jul 13 2020, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2020, 12:49 PM
jpienaar accepted this revision.Jul 13 2020, 1:04 PM

Nice, thanks (just small nits)

mlir/lib/Parser/AttributeParser.cpp
194

Is there a reason for the ordering or could we keep it sorted?

mlir/tools/mlir-tblgen/OpFormatGen.cpp
635–639

Nit: firstElement is not that much longer, lets just spell it out (I was going to say firstElem so that we use element's actual abbreviation but then it was even closer to full).

646

Could we do this one first and so keep these sorted?

1954

Same re sorted

This revision is now accepted and ready to land.Jul 13 2020, 1:04 PM
rriddle updated this revision to Diff 277958.Jul 14 2020, 1:14 PM
rriddle marked 4 inline comments as done.

Resolve comments

rriddle marked an inline comment as done.Jul 14 2020, 1:14 PM
rriddle added inline comments.
mlir/lib/Parser/AttributeParser.cpp
194

No particular reason, this was just the order from parseAttribute.

This revision was automatically updated to reflect the committed changes.