4 ms·
Seems like something that could be leveraged in optimization and AST lowering with great success. Admittedly the examples on the main page aren't well explained
by junon 3y ago
Seems like something that could be leveraged in optimization and AST lowering with great success. Admittedly the examples on the main page aren't well explained, so requires a bit of groking.
Really cool looking stuff though.
- UncleEntity 3y agoThat's what I thought it was based on the title -- I've been looking for a simple tree-rewriting library (or DSL) for a while now. Treecc[0] is probably the closest I've found and AFAICT would have to be beaten into submission to provide similar functionality. Plus its been abandoned and quite complicated methinks. There was a project doing almost exactly what I wanted but in a different domain but, unfortunately, my indexing skills are subpar and I can't remember what it was called so it's lost... [0] https://www.gnu.org/software/dotgnu/treecc/treecc.html https://www.gnu.org/software/dotgnu/treecc/treecc.html
- yencabulator 3y agoTree rewriting is at the core of many compilers, but many compilers are huge labyrinths with historical cruft. You might find inspiration in Go, though, as that compiler is surprisingly simple in structure. The SSA rewrite rules look like (Add8 (Const8 [c]) (Const8 [d])) => (Const8 [c+d]) (EqPtr x x) => (ConstBool [true]) https://go.dev/src/cmd/compile/internal/ssa/_gen/generic.rules https://go.dev/src/cmd/compile/internal/ssa/_gen/generic.rul... https://go.dev/src/cmd/compile/README https://go.dev/src/cmd/compile/README
- deleted 3y ago[deleted]