Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 02 25 demo #11

Merged
merged 7 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions egglog_src/lakeroad.egg → egglog_src/churchroad.egg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
; Ops
(datatype Op
(And)
(Add)
(Or)
(Xor)
(Shr)
Expand Down Expand Up @@ -102,6 +103,7 @@
;;; op.
(relation AllBitwidthsMatch (Op))
(AllBitwidthsMatch (And))
(AllBitwidthsMatch (Add))
(AllBitwidthsMatch (Or))
(AllBitwidthsMatch (Xor))
(AllBitwidthsMatch (Shr))
Expand Down
78 changes: 78 additions & 0 deletions egglog_src/module_enumeration_rewrites.egg
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

(ruleset enumerate-modules)
(rewrite (Var name bw) (apply (MakeModule (Hole) (vec-of 0)) (vec-of (Var_ name bw))) :ruleset enumerate-modules)
(rewrite
(Op0 op )
(apply (MakeModule (Op0_ op ) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) ))) (vec-append (vec-pop (vec-of (Var "unused" 0))) ))
:ruleset enumerate-modules
)
(rewrite
(Op1 op expr0)
(apply (MakeModule (Op1_ op (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0)))
:ruleset enumerate-modules
)
(rewrite
(Op1 op (apply (MakeModule graph0 _) args0))
(apply (MakeModule (Op1_ op graph0) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0))
:ruleset enumerate-modules
)
(rewrite
(Op2 op expr0 expr1)
(apply (MakeModule (Op2_ op (Hole) (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1)))
:ruleset enumerate-modules
)
(rewrite
(Op2 op expr0 (apply (MakeModule graph1 _) args1))
(apply (MakeModule (Op2_ op (Hole) graph1) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1))
:ruleset enumerate-modules
)
(rewrite
(Op2 op (apply (MakeModule graph0 _) args0) expr1)
(apply (MakeModule (Op2_ op graph0 (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1)))
:ruleset enumerate-modules
)
(rewrite
(Op2 op (apply (MakeModule graph0 _) args0) (apply (MakeModule graph1 _) args1))
(apply (MakeModule (Op2_ op graph0 graph1) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1))
:ruleset enumerate-modules
)
(rewrite
(Op3 op expr0 expr1 expr2)
(apply (MakeModule (Op3_ op (Hole) (Hole) (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1) (vec-of expr2)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1) (vec-of expr2)))
:ruleset enumerate-modules
)
(rewrite
(Op3 op expr0 expr1 (apply (MakeModule graph2 _) args2))
(apply (MakeModule (Op3_ op (Hole) (Hole) graph2) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1) args2))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) (vec-of expr1) args2))
:ruleset enumerate-modules
)
(rewrite
(Op3 op expr0 (apply (MakeModule graph1 _) args1) expr2)
(apply (MakeModule (Op3_ op (Hole) graph1 (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1 (vec-of expr2)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1 (vec-of expr2)))
:ruleset enumerate-modules
)
(rewrite
(Op3 op expr0 (apply (MakeModule graph1 _) args1) (apply (MakeModule graph2 _) args2))
(apply (MakeModule (Op3_ op (Hole) graph1 graph2) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1 args2))) (vec-append (vec-pop (vec-of (Var "unused" 0))) (vec-of expr0) args1 args2))
:ruleset enumerate-modules
)
(rewrite
(Op3 op (apply (MakeModule graph0 _) args0) expr1 expr2)
(apply (MakeModule (Op3_ op graph0 (Hole) (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1) (vec-of expr2)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1) (vec-of expr2)))
:ruleset enumerate-modules
)
(rewrite
(Op3 op (apply (MakeModule graph0 _) args0) expr1 (apply (MakeModule graph2 _) args2))
(apply (MakeModule (Op3_ op graph0 (Hole) graph2) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1) args2))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 (vec-of expr1) args2))
:ruleset enumerate-modules
)
(rewrite
(Op3 op (apply (MakeModule graph0 _) args0) (apply (MakeModule graph1 _) args1) expr2)
(apply (MakeModule (Op3_ op graph0 graph1 (Hole)) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1 (vec-of expr2)))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1 (vec-of expr2)))
:ruleset enumerate-modules
)
(rewrite
(Op3 op (apply (MakeModule graph0 _) args0) (apply (MakeModule graph1 _) args1) (apply (MakeModule graph2 _) args2))
(apply (MakeModule (Op3_ op graph0 graph1 graph2) (debruijnify (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1 args2))) (vec-append (vec-pop (vec-of (Var "unused" 0))) args0 args1 args2))
:ruleset enumerate-modules
)
Loading