If you were building a compiler, would it be best to optimize at the AST level?
Compared to AST (rather than CFG) is one of the easiest optimization tail mail customizations: See a sub-line of:
returns the call f. ergus x, y, ...
You can jump it from F
. If f (a, b)
is a function that appears in tail-call, the replacement is as simple as:
a = x;
I think it is easiest to represent a jump as a special "restart" statement, which treats AST-> CFG first hand as an edge node. Jumping into other functions is a bit complicated because you can not just set local variables, you really need to think in advance how the arguments are passed and ready to translate it at the lower level. For example, AST may need a special node which can direct with the argument to overwrite the current stack frame next to the next and jump accordingly.
No comments:
Post a Comment