Skip to content
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

[mlir][tools] Introduce tblgen-to-irdl tool #66865

Merged
merged 3 commits into from
Oct 7, 2023

Conversation

Groverkss
Copy link
Member

@Groverkss Groverkss commented Sep 20, 2023

This patch adds a new tool, tblgen-to-irdl, which is an IRDL backend to MLIR
ODS.

Currently, the tool only covers operation and dialect definitions and
generates verifiers constraints as "irdl::CPred", which is the constraint as a
C++ string. The tool currently does not support
traits/interfaces/regions/variadics as they are not added in IRDL yet, so the
generated definitions would not be correct for operations using them. Support
for these things will be added as they are implemented in IRDL.

This tool acts as a bridge to convert TableGen-defined dialects into IRDL
definitions, making operation definitions more easily introspectable. This
introspectablility allows for tools like fuzzers, mutators, and reducers to
work on ODS definitions as a MLIR dialect instead of trying to navigate through
TableGen.

Differential Revision: https://reviews.llvm.org/D156469
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Sep 20, 2023
@joker-eph
Copy link
Collaborator

Is there some context to read on this somewhere? A discourse thread?

@Groverkss
Copy link
Member Author

Is there some context to read on this somewhere? A discourse thread?

Sorry, was just moving it from phab. I will add more context it a bit.

@joker-eph
Copy link
Collaborator

Why a separate binary and not just another backend for mlir-tblgen?

@Groverkss
Copy link
Member Author

Why a separate binary and not just another backend for mlir-tblgen?

The reason I did not make this a backend for mlir-tblgen is that this would add a dependency of MLIRIR on mlir-tblgen. I’m not sure how this dependency affects things as I expect the MLIRIR definitions to be generated by mlir-tblgen and mlir-tblgen would start depending on those definitions.

The same question was asked on the RFC as well :) (https://discourse.llvm.org/t/rfc-tblgen-to-irdl-tool/73578/8)

@joker-eph
Copy link
Collaborator

The reason I did not make this a backend for mlir-tblgen is that this would add a dependency of MLIRIR on mlir-tblgen

This PR does not modify lib/IR/... ; can you clarify where is this dependency coming from?

@Groverkss
Copy link
Member Author

The reason I did not make this a backend for mlir-tblgen is that this would add a dependency of MLIRIR on mlir-tblgen

This PR does not modify lib/IR/... ; can you clarify where is this dependency coming from?

oops. I meant the other way around, mlir-tblgen would start depending on MLIRIR, since to generate IRDL, we use IR Builders.

@Groverkss
Copy link
Member Author

@joker-eph @Mogball gentle ping :)

Copy link
Contributor

@Mogball Mogball left a comment

Choose a reason for hiding this comment

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

nice

@Groverkss Groverkss merged commit e6e9beb into llvm:main Oct 7, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants