Skip to content

Conversation

fabianschuiki
Copy link
Contributor

Introduce a dialect conversion step into the ConvertToArcs pass. We'll use this to map various core dialect operations to Arc-specific ones in the future. As a starting point, add a conversion from llhd.combinational to arc.execute. This, alongside lowering to LLVM to be added in later PRs, will implement some basic LLHD support in the Arc dialect.

@fabianschuiki fabianschuiki added the Arc Involving the `arc` dialect label Sep 12, 2025
@fabianschuiki fabianschuiki force-pushed the fschuiki/arc-llhd-combinational branch 2 times, most recently from bf81909 to ac154f1 Compare September 12, 2025 15:41
@fabianschuiki fabianschuiki force-pushed the fschuiki/arc-execute branch 2 times, most recently from a8437ac to 8c75ba9 Compare September 12, 2025 17:49
@fabianschuiki fabianschuiki force-pushed the fschuiki/arc-llhd-combinational branch from ac154f1 to 1625508 Compare September 12, 2025 17:49
Base automatically changed from fschuiki/arc-execute to main September 13, 2025 18:19
Introduce a dialect conversion step into the `ConvertToArcs` pass. We'll
use this to map various core dialect operations to Arc-specific ones in
the future. As a starting point, add a conversion from
`llhd.combinational` to `arc.execute`. This, alongside lowering to LLVM
to be added in later PRs, will implement some basic LLHD support in the
Arc dialect.
@fabianschuiki fabianschuiki force-pushed the fschuiki/arc-llhd-combinational branch from 1625508 to 078d3f1 Compare September 14, 2025 01:36
Comment on lines +586 to +587
target.markUnknownOpDynamicallyLegal(
[](Operation *op) { return !isa<llhd::LLHDDialect>(op->getDialect()); });
Copy link
Member

Choose a reason for hiding this comment

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

Is it required even when llhd::LHDDialect is registered as an illegal dialect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I ran into the issue that all operations/dialects not explicitly listed as legal leading to a "failed to legalize" error. I would have thought that the partial dialect conversion would just rewrite ops that were explicitly marked as illegal. But that didn't work for me 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, interesting! Thank you for trying it out!

Copy link
Member

Choose a reason for hiding this comment

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

One of the reasons I often just use greedy pattern rewriter or simple walk, as I always have to remember again and mostly I want any pattern that can apply to apply. (dialect conversion still very useful for ones where type conversion needed and I haven't tried the new oneshot one).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah same here. I have no mental model of the dialect conversion framework. It feels completely random to me what I have to put into legalization, type conversion, and what gets converted where. But the plain old rewriting framework is annoying when a lot of type conversions are involved. I'm also having trouble finding good documentation for the dialect conversion framework. Seems to be a RTFC kind of deal 😁

Copy link
Contributor

@TaoBi22 TaoBi22 left a comment

Choose a reason for hiding this comment

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

Sorry, that was meant to be part of this review ^ otherwise LGTM!

@fabianschuiki fabianschuiki merged commit e698309 into main Sep 16, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/arc-llhd-combinational branch September 16, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arc Involving the `arc` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants