Replies: 1 comment 1 reply
-
I really like this! One thing I'm wondering about - would it make sense to do this after we implement the "missing pieces" for AirScript to be functionally complete (i.e., to have enough of a functionality to describe Miden VM constraints). In my mind, it will be functionally complete when we implement #123, #143, and #183. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While doing the refactoring work early this summer on the compiler, I made some compromises to keep large structural changes relatively contained, i.e. I didn't want downstream crates to change much, if at all possible. I wasn't super successful in that regard; while the codegen crates were largely unaffected, the IR crate was completely reworked, and knowing what I know now, I would have come at things a different way.
The main compromise I made was re-using the AST as the IR on which the compiler does the bulk of its work. What is currently in our
ir
crate is not actually the compiler IR, but rather the algebraic graph (AIR), i.e. the representation we want for codegen. However, most of the heavy lifting is done outside of the algebraic graph, on the AST.There are a few issues with re-using the AST for our IR:
I'd like to propose that we plan to do the following:
This would significantly reduce the complexity of the code currently in the middle tier (e.g. inlining), and would provide a much cleaner interface for writing additional optimizations/transformations. Much of the complexity in that code today exists because of the awkward way in which we have to traverse and modify the AST to perform analysis and effect desired changes. This would also have the effect of making the compiler snappier, and scale better (e.g. it fixes the potential for stack overflows during traversal).
We can do this in a few individual steps parallel to other AirScript development (with rough estimates on how long each would take):
ir
crate to a sharedcodegen
crate which all of the codegen backend crates reference. (est. 1-2h)ir
crate, but not yet used anywhere (est. 3d)Since the level of abstraction in MIR would be the same as the AST, just structured differently, translating AST->MIR and MIR->AIR is trivial. Most of the development time required will be in handling the mechanical work of rewriting passes and tests in terms of the new structure, rather than implementing anything novel.
This proposal isn't necessary to implement right now, but I think we should start planning on it, and perhaps get steps 1-3 done so that we have a foundation on which to implement and test the remaining steps.
If anyone has any questions, I'm happy to answer them!
Beta Was this translation helpful? Give feedback.
All reactions