This is an archive of the discontinued LLVM Phabricator instance.

[mlir] ODS: support operations with resizable operand lists
ClosedPublic

Authored by ftynse on Apr 16 2020, 5:33 AM.

Details

Summary

MLIR supports operations with resizable operand lists, but this property must
be indicated during the construction of such operations. It can be done
programmatically by calling a function on OperationState. Introduce an
ODS-internal trait ResizableOperandList to indicate such operations are use
it when generating the bodies of various build functions as well as the
parse function when the declarative assembly format is used.

Diff Detail

Event Timeline

ftynse created this revision.Apr 16 2020, 5:33 AM
Herald added a project: Restricted Project. · View Herald Transcript
rriddle accepted this revision.Apr 16 2020, 10:10 AM
This revision is now accepted and ready to land.Apr 16 2020, 10:10 AM

How do we refer to resizable operands? E.g., OpE has resizeable operands, how do you refer to them in a pattern?

Or is the expectation that the last operand is always variadic and that is the resizable one?

How do we refer to resizable operands? E.g., OpE has resizeable operands, how do you refer to them in a pattern?

The same way you usually do. It's up to your op how its operands are split into groups and how those groups are referred to. Being able to resize the list doesn't necessarily mean append operands. In most cases, I'd expect there is a variadic group. But I can also see an op with one optional operand. The use case I have has 3 variadic groups and 2 of them are modified.

This revision was automatically updated to reflect the committed changes.
mehdi_amini added a comment.EditedApr 16 2020, 2:56 PM

Can we handle this with a traits on the op itself instead?

This implementation does not seem to be robust with respect to custom builders, and I suspect that with a trait we could just change the generic create method to query this traits and set the right flag.