Skip to content

[MLIR][IRDL] Added IRDL to C++ Translation #141248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 107 commits into from
May 25, 2025
Merged

Conversation

hhkit
Copy link
Contributor

@hhkit hhkit commented May 23, 2025

A re-attempt at merging IRDL-to-CPP (#133982) after a sanitizer check failed in post-merge CI (resolving #138285).


This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to C++ definitions.

The C++ definitions allow use of the IRDL-defined dialect in MLIR C++ infrastructure, enabling the use of conversion patterns with IRDL dialects for example. This PR also adds CMake utilities to easily integrate the IRDL dialects into MLIR projects.

Note that most IRDL features are not supported. In general, we are only able to define simple types and operations.

  • The only type constraint supported is irdl.any.
  • Variadic operands and results are not supported.
  • Verifiers for the IRDL constraints are not generated.
  • Attributes are not supported.

Copy link
Member

@Moxinilian Moxinilian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving per reviews in #133982

@@ -302,6 +304,7 @@ void registerTestPasses() {
mlir::test::registerTestVectorReductionToSPIRVDotProd();
mlir::test::registerTestVulkanRunnerPipeline();
mlir::test::registerTestWrittenToPass();
mlir::test::registerTestIrdlTestDialectConversionPass();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this in alphabetical order?

@@ -331,6 +334,7 @@ int main(int argc, char **argv) {
::test::registerTestTransformsTransformDialectExtension(registry);
::test::registerTestTilingInterfaceTransformDialectExtension(registry);
::test::registerTestDynDialect(registry);
::test::registerIrdlTestDialect(registry);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it could you sort this alphabetically too if that doesn't break anything (just try it and if CI complain let's reverse)?

@Moxinilian Moxinilian merged commit c76e280 into llvm:main May 25, 2025
11 checks passed
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to
C++ definitions.

The C++ definitions allow use of the IRDL-defined dialect in MLIR C++
infrastructure, enabling the use of conversion patterns with IRDL
dialects for example. This PR also adds CMake utilities to easily
integrate the IRDL dialects into MLIR projects.

Note that most IRDL features are not supported. In general, we are only
able to define simple types and operations.

- The only type constraint supported is irdl.any.
- Variadic operands and results are not supported.
- Verifiers for the IRDL constraints are not generated.
- Attributes are not supported.

---------

Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr>
Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants