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

[MooreToCore] Alternative conditional lowering and type conversion fixes #7625

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

maerhart
Copy link
Member

  • Alternative conditional op lowering to a mux if there are no relevant side-effects in the regions
  • Add missing type conversions (mostly target types not marked legal and target types with nested source types not supported). This is necessary to make the conditional lowering work because the dialect conversion framework pushes an InlineBlockRewrite to the queue with triggers a signature conversion call to the function body the conditional op is in, which failed because the target types were not marked legal.
  • Use the type converters isLegal helpers to determine dynamic legality instead of a custom solution.

@maerhart maerhart force-pushed the maerhart-moore-to-core-improvements branch from 537dde8 to 7993ae3 Compare September 24, 2024 23:57
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! The isLegal query is really neat and cleans stuff up very nicely.

Copy link
Member

@hailongSun2000 hailongSun2000 left a comment

Choose a reason for hiding this comment

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

I have a personal question regarding typeConverter.addConversion([&](hw::InOut/Array/StructType type).... If we convert moore.ref/array/struct to hw.inout/array/struct, would we get an error type like hw.inout<moore.i32> 🤔?

@maerhart
Copy link
Member Author

maerhart commented Sep 25, 2024

I have a personal question regarding typeConverter.addConversion([&](hw::InOut/Array/StructType type).... If we convert moore.ref/array/struct to hw.inout/array/struct, would we get an error type like hw.inout<moore.i32> 🤔?

Not with this set of conversion callbacks, because we always convert the inner type as well (and return early if that was unsuccessful) and because we now also have conversion callbacks for the target types that also convert the inner types. Before this PR, if you have such a type in the IR for some reason, it would not be properly lowered.

@maerhart maerhart merged commit 337dad5 into main Sep 25, 2024
4 checks passed
@maerhart maerhart deleted the maerhart-moore-to-core-improvements branch September 25, 2024 08:43
@hailongSun2000
Copy link
Member

I understand these callbacks but sorry for not realizing which special case will trigger this error 😅.

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.

3 participants