Open
Description
Currently the compiler backend performs several stages of Node AST rewrites before generating SSA. We should investigate generating SSA directly from the AST produced by the frontend. Rationale:
- order.go exists as a separate pass primarily to simplify maintaining order-of-evaluation in walk.go, but we can probably just as easily handle this when directly producing SSA.
- order.go and walk.go iterate across the entire function AST a couple times, reading and writing to every pointer slot. Usually the values written are also identical to the values already in memory too.
- AST rewrites requires the intermediary format to be representable in the AST too, which may complicate transitioning to package syntax. There are currently several gc.Ops generated and used only within the backend (e.g., OSQRT, OINDREGSP, OEFACE, ...).
- The AST invariants between these phases are poorly documented or at least poorly understood.
/cc @randall77 @josharian