An out-of-tree MLIR dialect template

I was fiddling around with a few custom MLIR dialects and I wanted to make it easier and quicker to start a new dialect project. I just finished setting up a standalone out-of-tree dialect template for MLIR. It is available on GitHub.

Comments and suggestions are welcome and very much appreciated!

4 Likes

This looks pretty useful - thanks for sharing! A couple of minor things to be consistent with MLIR style.

  1. You can drop the INCLUDE_ prefixes on the header macro guards.
  2. lib/standalone -> lib/Standalone

Thanks for your comments! I completely overlooked these details. Should be fixed now.

This is great! I’ve been thinking we needed something just like this. Would you like to suggest this as an addition to the mlir/examples directory?

I think there are few things that are also needed once the more complex capabilities of MLIR are used (generated transforms which depend on the dialect, generated Enums, etc.) I’ll send you a pull request.

Would you like to suggest this as an addition to the mlir/examples directory?

I am not sure how this would integrate into the current examples directory, since the examples use in-tree functionalities. Would you just copy the current template root directory to mlir/examples without adding it to the CMakeLists.txt?

I think there are few things that are also needed once the more complex capabilities of MLIR are used

Yes, agreed. Right now it is a really bare bones starting template and adding a few more bits and pieces could be really useful. Feel free to send PRs!

Yes, basically. One possibility would be that we have another regular build rule which configures and builds the out of tree version of mlir-opt and then runs all the regular tests it.

I would also love to have an example like this included with the main tree, and possibly incorporated into a tutorial somehow!

I will try to submit a patch to the main repository for the minimal version as soon as I have some time to work on it. It will make it easier for people to contribute and it should make it easier not to get out-of-sync with the main development work.

It could probably be integrated in some existing parts of the documentation (maybe by extending docs/CreatingADialect.md).

1 Like

Blockquote[quote=“Kayjukh, post:8, topic:823, full:true”]
It could probably be integrated in some existing parts of the documentation (maybe by extending docs/CreatingADialect.md).
[/quote]

That would be a great place to start!