Closed mohammadfawaz closed 1 month ago
The function evaluate
should be quite useful here.
I think the E2E tests should have another phase which includes these type of transforms separately.
Where 'flattened' is anything which is desugared but still pretty much resembles the parsed tree. The 'optimised' stage will have items removed or combined and is the final output.
Yes that makes sense. I had a chat with @lethalgem yesterday about the differences between "flattening" (we may need a better name for this now) and "optimization" and how one is required while the other is not. We should certainly split the two into separate phases where flattening happens first and produces valid code that asm gen can understand, while the optimizers runs after (and is optional in principle). Things like dead code elimination and const folding should go into the optimizer.
For example, remove constraints like this:
and so on...
We can start with some simple stuff and evolve the pass to support more complex structures in the future.