This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ods] Extend the EnumAttr tablegen class to support BitEnum attributes
ClosedPublic

Authored by jfurtek on Apr 15 2022, 3:54 PM.

Details

Summary

This diff allows the EnumAttr class to be used for bit enum attributes (in
addition to previously supported integer enum attributes). While integer
and bit enum attributes share many common implementation aspects, parsing
bit enum values requires a separate implementation. This is accomplished
by creating empty parser and printer strings in the EnumAttrInfo record,
and having derived classes (specific to bit and integer enums) override with
an appropriate parser/printer string.

To support existing bit enums that may use a vertical bar separator, the
parser is modified to support the | token.

Tests were added for bit enums alongside integer enums.

Future diffs for fastmath attributes in the arithmetic dialect will use these
changes.

(resubmission of earlier abaondoned diff, updated to reflect subsequent changes
in the repository)

Diff Detail

Event Timeline

jfurtek created this revision.Apr 15 2022, 3:54 PM
Herald added a project: Restricted Project. · View Herald Transcript
jfurtek requested review of this revision.Apr 15 2022, 3:54 PM
Mogball accepted this revision.Apr 18 2022, 6:01 PM
Mogball added inline comments.
mlir/test/lib/Dialect/Test/TestOps.td
326

Add a test for "|" as well?

This revision is now accepted and ready to land.Apr 18 2022, 6:01 PM
jfurtek planned changes to this revision.Apr 19 2022, 9:24 PM

Adding vertical bar test...

jfurtek updated this revision to Diff 423910.Apr 20 2022, 8:08 AM
  • Update lexer to support vertical bar token, and add test for vertical bar case
This revision is now accepted and ready to land.Apr 20 2022, 8:08 AM
jfurtek marked an inline comment as done.Apr 20 2022, 8:10 AM
jfurtek added inline comments.
mlir/test/lib/Dialect/Test/TestOps.td
326

Great suggestion - I had assumed that it would "just work", but I had not made the necessary changes to the lexer. (That is fixed in the updated commit.)

jfurtek updated this revision to Diff 424928.Apr 25 2022, 9:04 AM
jfurtek marked an inline comment as done.
  • Rebase