This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Generate Op builders for Python bindings
ClosedPublic

Authored by ftynse on Nov 10 2020, 10:27 AM.

Details

Summary

Add an ODS-backed generator of default builders. This currently does not
support operation with attribute arguments, for which the builder is
just ignored. Attribute support will be introduced separately for
builders and accessors.

Default builders are always generated with the same number of result and
operand groups as the ODS specification, i.e. one group per each operand
or result. Optional elements accept None but cannot be omitted. Variadic
groups accept iterable objects and cannot be replaced with a single
object.

For some operations, it is possible to infer the result type given the
traits, but most traits rely on inline pieces of C++ that we cannot
(yet) forward to Python bindings. Since the Ops where the inference is
possible (having the SameOperandAndResultTypes trait or
TypeMatchesWith without transform field) are a small minority, they
also require the result type to make the builder syntax more consistent.

Diff Detail

Event Timeline

ftynse created this revision.Nov 10 2020, 10:27 AM
ftynse requested review of this revision.Nov 10 2020, 10:27 AM
stellaraccident accepted this revision.Nov 11 2020, 5:55 PM
This revision is now accepted and ready to land.Nov 11 2020, 5:55 PM
This revision was automatically updated to reflect the committed changes.