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

Yul AST contains dialect #15560

Merged
merged 8 commits into from
Dec 3, 2024
Merged

Yul AST contains dialect #15560

merged 8 commits into from
Dec 3, 2024

Conversation

clonker
Copy link
Member

@clonker clonker commented Oct 31, 2024

Follow up of #15534.

I streamlined some interfaces which would take an object as well as the dialect to just take the object and instead pull the dialect out of it. I think a lot more could be done potentially by reworking most optimizer steps to optionally run on an instance of yul::AST instead of the root block - that way dialect <-> ast consistency would be harder to break.

Base automatically changed from yul_object_contains_dialect to develop October 31, 2024 16:46
@clonker clonker force-pushed the yul_ast_contains_dialect branch 2 times, most recently from 930ee2a to db5b7e4 Compare November 1, 2024 08:37
@github-actions github-actions bot added the stale The issue/PR was marked as stale because it has been open for too long. label Nov 15, 2024
@cameel cameel removed the stale The issue/PR was marked as stale because it has been open for too long. label Nov 16, 2024
@ekpyron ekpyron added the 🟡 PR review label label Nov 20, 2024
@clonker clonker force-pushed the yul_ast_contains_dialect branch from db5b7e4 to 8aa7afd Compare December 2, 2024 13:50
@cameel cameel force-pushed the yul_ast_contains_dialect branch from 8aa7afd to 96e63ab Compare December 2, 2024 19:37
@ethereum ethereum deleted a comment from github-actions bot Dec 2, 2024
@cameel
Copy link
Member

cameel commented Dec 2, 2024

I think a lot more could be done potentially by reworking most optimizer steps to optionally run on an instance of yul::AST instead of the root block

One additional place that could benefit from it (and is much less work than the whole optimizer) would be the AsmAnalyzer. I still takes the dialect and the root block separately.

@clonker clonker merged commit df91531 into develop Dec 3, 2024
73 checks passed
@clonker clonker deleted the yul_ast_contains_dialect branch December 3, 2024 08:53
@clonker
Copy link
Member Author

clonker commented Dec 3, 2024

One additional place that could benefit from it (and is much less work than the whole optimizer) would be the AsmAnalyzer. I still takes the dialect and the root block separately.

That requires rethinking the compilability checker / the AST itself a bit, as there the dialect is overridden with the NoOutputDialect decoration when passed into AsmAnalyzer. We could offer three overloads of analyzeStrictAssertCorrect though, with

  • AsmAnalysisInfo analyzeStrictAssertCorrect(Object const& _object),
  • AsmAnalysisInfo analyzeStrictAssertCorrect(AST const& _ast, Object::Structure _objectStructure), and
  • AsmAnalysisInfo analyzeStrictAssertCorrect(Dialect const& _dialect, Block const& _astRoot, Object::Structure _objectStructure).

Then at least where no decorated dialect is required, we can take the AST instance directly.

@cameel
Copy link
Member

cameel commented Dec 6, 2024

@clonker Interesting. I wasn't aware of this pattern, but looking it it now, this is a really weird design. Having generateCode() as a part of the dialect seems unnecessary. I think that Dialect was meant to be more of a declarative component so tightly coupling it with code generation now leads to issues like this. Code generation should sit in some other class that we would only use in places where we actually want to generate it - in vast majority of places that use Dialect we don't.

So yeah, a proper solution is more work than just a small refactor. But there is a simple workaround - just pass the original dialect from the object to AsmAnalyzer. AsmAnalyzer is not supposed to call generateCode() anyway so there's no difference in the current usage.

There's already an implicit assumption in CompilabilityChecker that, other than code generation, NoOutputEVMDialect matches all aspects of the dialect present in the object. If it does not, things will break. Passing in the original dialect just means that we'll only see the effects of the breakage during code generation if it ever happens (and it's not supposed to ever happen). Might be worth a comment to document that assumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor 🟡 PR review label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants