This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ODS] Automatically create `result_segment_sizes` in builder
ClosedPublic

Authored by zero9178 on Aug 25 2022, 7:00 AM.

Details

Summary

When using multiple variadic results of differing sizes, using AttrSizedResultSegments is currently a requirement. Unlike AttrSizedOperandSegments however, it is not created within the default builders created by tablegen. Instead, one has to explicitly add DenseI32ArrayAttr:$result_segments_sizes as argument and then also explicitly specify all the sizes when using the builder from C++.

This patch fixes that redundancy, by making the builder generate the attribute in similar fashion as it already does for AttrSizedOperandSegments. The sizes required are simply gathered from the result type arguments of the builder.

Diff Detail

Event Timeline

zero9178 created this revision.Aug 25 2022, 7:00 AM
zero9178 requested review of this revision.Aug 25 2022, 7:00 AM
mehdi_amini accepted this revision.Aug 25 2022, 7:23 AM

LG, but please wait for at least one more approval from any of the other reviewers. Thanks!

This revision is now accepted and ready to land.Aug 25 2022, 7:23 AM
Mogball accepted this revision.Aug 25 2022, 9:29 AM

LGTM Thanks!

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
1529

if {} else if {} else {} seems cleaner to me here since they're all one liners

1542–1543
zero9178 updated this revision to Diff 455627.Aug 25 2022, 10:03 AM

Address review comments

This revision was landed with ongoing or failed builds.Aug 25 2022, 10:09 AM
This revision was automatically updated to reflect the committed changes.