-
Notifications
You must be signed in to change notification settings - Fork 17
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
MassaLabs: Implement a Intermediate Representation to improve the compilation process #359
base: next
Are you sure you want to change the base?
Conversation
Translation from AST has been vastly commented out, to rework
Updated inlining test template
- remove leading and ending new lines - display calls as SSA - remove var name in function return signatures - handle Operation {Sub, Mul} - display Constants as Type(value)
+ remap operation's parametters to new body's NodeIndex
@bitwalker, first of all, thank you for this detailed answer, it will sure help a lot! |
You bet! Sorry if presenting a sketch of the RVSDG design gave you a scare - didn't want to stress you out worrying about needing to refactor things, hopefully it just provided a useful reference for past and future conversations.
Yes, I believe all of my questions are addressed, except maybe a few small fresh ones I've left as comments. Ping me once a few of the more complex tests are implemented, and I'll re-review ASAP. Thanks for all the hard work! |
No problem! It will serve as a reference for further discussions, and as a target to tend towards as we refactor our implementation based on what we need.
I have left comments addressing these. For now I don't think the remaining points require immediate attention, we already have plenty to do based on your feedback. I'll be sure to ping you when a review is needed. Thanks again for all your valuable feedback! |
implement real depth first remove external stack in post-order visit abstract Visit trait with auto implem for VisitContext implems
implement Enf, Call, Fold, For, If, Vector, Matrix, Boundary, Parameter
added Eq support to operation few bugfixes
Hello @bitwalker ! We wanted to give you an update on what we've been working on, and to get your input on a few things. Our main rework working branch is the following: https://github.com/massalabs/air-script/tree/thy-rework-ir We've mainly worked on:
What we have to do:
As a result, it would be great if you could look at the structure and answer our questions below so we can finalize the design! Thank you again. |
Hey! Below is a summary of the new structure for the IR. Our rework of the MirGraph structure:Our current structure:Implemented traits are marked [Trait]. dyn Op: gives access to the Operation
dyn Value: * shared behaviour by all nodes
Operand: [Value]
owner: Operation
value: dyn Value
OpResult: [Value]
owner: dyn Op
Operation: [Value]
owner: dyn Op
Vec<Operand>
result: OpResult
Add: [Op, Value]
Operation
...
Matrix: [Op, Value]
Operation
Parameter: [Value]
owner: FunctionOrEvaluator
Block:
owner: FunctionOrEvaluator
Vec<dyn Op>
Fonction/Evaluator:
params: Parameter
blocks: Vec<Block> Problems & Potential Solutions:P: Dynamic dispatch makes things tricky due to casting to non-primitive types.S: Replace with enums. P:
|
rename NodeTypes to NodeType split NodeType into LeafNode, RootNode, MiddleNode removed debugging
new_i32 replaced by generic new_value LeafNode::I32 renamed to Value implemented Felt Leaf node improved conversions removed debugging
removed MiddleNode::Node renamed new_body -> new_scope implement Default
Merge new IR structure
Hello @bitwalker,
Next step is to replace the old structure by this new one, which will be done through this PR: massalabs#4 |
The goal of this PR is to introduce a Middle Intermediate Representation, to avoid making optimization on the AST directly, while keeping enough information to handle type checking, optimization for each pass.
See the initial issue and design discussion for additional context:
Putting it as draft now that we have:
Parse to AST > Constant propagation > Lowering to MIR
all pass, but the resulting MIR is not checked. We may need to improve testing on this side.Additionally, we have a partial pretty printer for the MIR to help us debug in the future (to ensure the graph constructed is what we expect after each pass)
@bitwalker, don't hesitate to comment on things that should be handled differently.
For now, we haven't fully settled on the various nodes of the MIR graph, as we add / change things depending on the needs of our implementation. We will also add checks made to ensure the proper diagnostics are raised (potentially after each pass as discussed previously), but we will probably do this at a later stage.