RVSDG: Improvements
Overview
The issue collects some high-level improvements I sometimes think about. So, no guarantee that they'll be implemented.
SExpr Serialization
As specially for testing a RVSDG -> sexpr serialization would be nice. It'd allow us to write nicer tests as well, as well as provide a machine readable format. I think de-serialization is out of scope for now, since that is harder.
Egglog optimizer
It would be nice to have some kind of egglog integration. At best it would be possible to specify a optimization pipeline for any RVSDG in egglog as a opt-pipeline. We'd then load all rules and execute egglog. This would free me from having to implement local optimization by hand.
A caveat is, that we'd need to somehow define a custom-node -> egglog-name mapping.
Better node and edge layouting for the rvsdg-viewer
Right now the viewer works, but generates hard to read layouts at times. This are the main problems:
- A successor can be higher, which looks like a cycle/back edge at first sight, but is not. The layouting should layout all predecessors higher then a given node.
- edges crossing nodes: All edges should avoid crossing any node.
- edges should only be allowed to move down and horizontally for better readability
Interactive RVSDG-Viewer
The viewer currently generates single .svg files. However, it would be nice to be able to see change in between optimization steps.
An easy way would be to use the node's u64
ID to identify nodes across opt-stages, and blend via an animation between graph states. I think that would already be a good first implementation. Macroquad
is already included. So we could build a simple interactive viewer that loads a AST / File, executes a optimization pipeline, records all stages and then lets you
Show AttributeStore in RVSDG-Viewer
We have the AttribStore which can be attached to any element on the RVSDG. So we could also make them visible.
Topological Order iterator
The source paper uses topological ordering in reference passes often. So a TopoOrdIter
and TopoOrdIterMut
would be nice.
General structural passes
One of the big advantages of the RVSDG is its structural nodes and regions. This allows us to define one inline pass that works everywhere, one Common Node Elimination etc.
So it might be good to just implement them once.
Graph -> Graph translation utility
A utility that allows us to transform a RVSDG<A, E>
to RVSDG<B, E>
would allow us to implement MLIR-style dialect lowering in a nice way.