3 ms·
Tree 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 tha
by yencabulator 3y ago
Tree 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