|
77 | 77 | (define insert-brfs (egglog-runner-brfs runner)) |
78 | 78 | (define curr-program (make-egglog-program)) |
79 | 79 |
|
80 | | - ;; 1. Add the Prelude |
| 80 | + ;; 1. Add the Prelude (includes all rules) |
81 | 81 | (prelude curr-program #:mixed-egraph? #t) |
82 | 82 |
|
83 | | - ;; 2. User Rules which comes from schedule (need to be translated) |
84 | | - (define tag-schedule |
85 | | - (for/list ([step (in-list (egglog-runner-schedule runner))]) |
86 | | - (match step |
87 | | - ['lift 'lift] |
88 | | - ['lower 'lower] |
89 | | - ['unsound |
90 | | - ;; Add the unsound rules |
91 | | - (egglog-program-add-list! (egglog-rewrite-rules (*sound-removal-rules*) 'unsound) |
92 | | - curr-program) |
93 | | - 'unsound] |
94 | | - ['rewrite |
95 | | - ;; Add the rewrite ruleset and rules |
96 | | - (egglog-program-add! `(ruleset rewrite) curr-program) |
97 | | - (egglog-program-add-list! (egglog-rewrite-rules (*rules*) 'rewrite) curr-program) |
98 | | - 'rewrite]))) |
99 | | - |
100 | | - ;; 3. Inserting expressions into the egglog program and getting a Listof (exprs . extract bindings) |
| 83 | + ;; 2. Inserting expressions into the egglog program and getting a Listof (exprs . extract bindings) |
101 | 84 |
|
102 | 85 | ;; Overview of the new extraction method: |
103 | 86 | ;; |
|
162 | 145 |
|
163 | 146 | ;; 4. Running the schedule : having code inside to emulate egraph-run-rules |
164 | 147 |
|
165 | | - ; run-schedule specifies the schedule of rulesets to saturate the egraph |
166 | | - ; For performance, it stores the schedule in reverse order, and is reversed at the end |
167 | | - |
168 | | - (for ([tag (in-list tag-schedule)]) |
169 | | - (match tag |
| 148 | + (for ([step (in-list (egglog-runner-schedule runner))]) |
| 149 | + (match step |
170 | 150 | ['lift (send-to-egglog (list '(run-schedule (saturate lift))) subproc)] |
171 | 151 |
|
172 | 152 | ['lower (send-to-egglog (list '(run-schedule (saturate lower))) subproc)] |
173 | 153 |
|
174 | 154 | ['unsound (send-to-egglog (list '(run-schedule (saturate unsound))) subproc)] |
175 | 155 |
|
176 | 156 | ;; Run the rewrite ruleset interleaved with const-fold until the best iteration |
177 | | - ['rewrite (egglog-unsound-detected-subprocess tag subproc)])) |
| 157 | + ['rewrite (egglog-unsound-detected-subprocess step subproc)])) |
178 | 158 |
|
179 | 159 | ;; 5. Extraction -> should just need constructor names from egglog-add-exprs |
180 | 160 | (define extract-commands |
|
306 | 286 |
|
307 | 287 | (egglog-program-add! (approx-lifting-rule) curr-program) |
308 | 288 |
|
| 289 | + ;; Add unsound rules |
| 290 | + (egglog-program-add-list! (egglog-rewrite-rules (*sound-removal-rules*) 'unsound) curr-program) |
| 291 | + |
| 292 | + ;; Add rewrite ruleset and rules |
| 293 | + (egglog-program-add! `(ruleset rewrite) curr-program) |
| 294 | + (egglog-program-add-list! (egglog-rewrite-rules (*rules*) 'rewrite) curr-program) |
| 295 | + |
309 | 296 | (void)) |
310 | 297 |
|
311 | 298 | (define const-fold |
|
0 commit comments