This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ods] Add tablegen field for concise printing of BitEnum attributes
ClosedPublic

Authored by jfurtek on Apr 15 2022, 12:57 PM.

Details

Summary

This diff introduces a tablegen field for bit enum attributes
(printBitEnumPrimaryGroups) to control printing when the enum uses "group"
cases. An example would be an implementation that uses a fastmath enum value
as an alias for individual fastmath flags. The proposed field would allow
printing of simply fast for the enum value, instead of the more verbose list
that would include fast as well as the individual flags (e.g. `reassoc,nnan,
ninf,nsz,arcp,contract,afn,fast`).

Diff Detail

Event Timeline

jfurtek created this revision.Apr 15 2022, 12:57 PM
jfurtek requested review of this revision.Apr 15 2022, 12:57 PM
rriddle added inline comments.Apr 18 2022, 12:16 PM
mlir/tools/mlir-tblgen/EnumsGen.cpp
191

Can you document these?

192–193

Please format these as you would if you wrote it directly(e.g. proper newlines, formatting, etc.) We want the generated code to be in the same form as hand written code (when possible).

195

Can you drop the braces here?

218

Can you just use llvm::reverse here?

229

Drop the trivial braces here.

mlir/unittests/TableGen/enums.td
52–60

Can you reduce the number of lines here? This style feels different from the rest of the file.

jfurtek planned changes to this revision.Apr 19 2022, 6:19 PM
jfurtek updated this revision to Diff 424024.Apr 20 2022, 2:12 PM
  • Correct formatting, add comments, use llvm::reverse()
jfurtek marked 6 inline comments as done.Apr 20 2022, 3:44 PM
rriddle accepted this revision.Apr 22 2022, 11:07 AM

LG, thanks!

mlir/tools/mlir-tblgen/EnumsGen.cpp
216–217

Prefer to keep the code here readable as well.

223

Same here.

231
239
247
This revision is now accepted and ready to land.Apr 22 2022, 11:07 AM
jfurtek updated this revision to Diff 424559.Apr 22 2022, 12:01 PM
  • Correct formatting, add comments, use llvm::reverse()
  • Make formatting code more readable
  • Properly punctuate comments.
jfurtek marked 5 inline comments as done.Apr 22 2022, 12:02 PM