This commit is contained in:
2025-08-19 09:55:17 +02:00
parent 9c2913af18
commit 34fd6adb3c

View File

@@ -179,28 +179,17 @@
] ]
#section[ #section[
== egg == E-Graphs
Some people might say: "bUt Im JuSt GoInG tO uSe EgG, i DoNt NeEd A pAtTeRn MaTcHiNg DiAlEcT" #inline-block(flink("https://en.wikipedia.org/wiki/E-graph")[E-Graphs]) are magical datastructures
(specifically #person(people.ote) said something like that) that can be used to efficiently encode all possible transformations, and then select the best transformation.
#flink("https://egraphs-good.github.io/")[egg] is a IR pattern matching and transformation library An example implementation is #flink("https://egraphs-good.github.io/")[egg]
that uses #inline-block(flink("https://en.wikipedia.org/wiki/E-graph")[E-Graphs]) to
magically solve (almost) all problems regarding IR pattern matching.
Even though egg solves most problems, I still recommend using a pattern matching dialect, especially in multi-level compilers, Even though E-Graphs solve most problems, I still recommend using a pattern matching dialect, especially in multi-level compilers,
to be more flexible, and have more future-proof pattern matching, if for example there suddenly is a better alternative to egg, to be more flexible, and have more future-proof pattern matching,
or you decide that you want to match some complex patterns manually. or you decide that you want to match some complex patterns manually.
] ]
#section[
A problem with using egg in combination with pattern matching dialects is that it might be harder
to write the code to convert the pattern matching dialect to egg patterns.
Additionally, some more complex transformations (not the matches) can't always be directly converted to egg transformations
(depending on the feature set provided by the transformation dialect),
but that can be solved by using a custom ```rust egg::Applier```
]
#section[ #section[
= More Advantages of Structured Pattern Matching = More Advantages of Structured Pattern Matching