This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Port Conversion Passes to LLVM to use TableGen generated constructors and options
ClosedPublic

Authored by zero9178 on Feb 10 2023, 11:37 AM.

Details

Summary

See https://github.com/llvm/llvm-project/issues/57475 for more context.

Using auto-generated constructors and options has significant advantages:

  • It forces a uniform style and expectation for consuming a pass
  • It allows to very easily add, remove or change options to a pass by simply making the changes in TableGen
  • Its less code

This patch in particular ports all the conversion passes which lower to LLVM to use the auto generated constructors and options. For the most part, care was taken so that auto generated constructor functions have the same name as they previously did. Only following slight breaking changes (which I consider as worth the churn) have been made:

  • mlir::cf::createConvertControlFlowToLLVMPass has been moved to the mlir namespace. This is consistent with basically all conversion passes
  • createGpuToLLVMConversionPass now takes a proper options struct array for its pass options. The pass options are now also autogenerated.
  • LowerVectorToLLVMOptions has been replaced by the autogenerated ConvertVectorToLLVMPassOptions which is automatically kept up to date by TableGen
  • I had to move one function in the GPU to LLVM lowering as it is used as default value for an option.
  • All passes that previously returned unique_ptr<OperationPass<...>> now simply return unique_ptr<Pass>

Diff Detail

Event Timeline

zero9178 created this revision.Feb 10 2023, 11:37 AM
zero9178 requested review of this revision.Feb 10 2023, 11:37 AM
rriddle accepted this revision.Feb 10 2023, 11:39 AM
This revision is now accepted and ready to land.Feb 10 2023, 11:39 AM
This revision was landed with ongoing or failed builds.Feb 10 2023, 11:55 AM
This revision was automatically updated to reflect the committed changes.