This is an archive of the discontinued LLVM Phabricator instance.

[mlir][pdl] Remove CreateNativeOp in favor of a more general ApplyNativeRewriteOp.

Authored by rriddle on Jan 29 2021, 7:55 PM.



This has a numerous amount of benefits, given the overly clunky nature of CreateNativeOp:

  • Users can now call into arbitrary rewrite functions from inside of PDL, allowing for more natural interleaving of PDL/C++ and enabling for more of the pattern to be in PDL.
  • Removes the need for an additional set of C++ functions/registry/etc. The new ApplyNativeRewriteOp will use the same PDLRewriteFunction as the existing RewriteOp. This reduces the API surface area exposed to users.

This revision also introduces a new PDLResultList class. This class is used to provide results of native rewrite functions back to PDL. We introduce a new class instead of using a SmallVector to simplify the work necessary for variadics, given that ranges will require some changes to the structure of PDLValue.

Depends On D95719

Diff Detail

Event Timeline

rriddle created this revision.Jan 29 2021, 7:55 PM
rriddle requested review of this revision.Jan 29 2021, 7:55 PM
ftynse accepted this revision.Mar 10 2021, 6:21 AM
This revision is now accepted and ready to land.Mar 10 2021, 6:21 AM
jpienaar accepted this revision.Mar 10 2021, 9:54 AM
jpienaar added inline comments.

Could you show the C++ side here too?


Ooc why does the executor not use ref for first arg?

rriddle updated this revision to Diff 330788.Mar 15 2021, 1:25 PM
rriddle marked 2 inline comments as done.


rriddle added inline comments.Mar 15 2021, 1:27 PM

For me it's more of conventional, i.e. it's a buffer of commands so it feels weird to pass a reference to the first value. I generally try to err on the side of "I pass this value in the way I expect to use it", which in this case is always as a buffer.

This revision was landed with ongoing or failed builds.Mar 16 2021, 1:20 PM
This revision was automatically updated to reflect the committed changes.