Skip to content

Commit a6fd8c8

Browse files
committed
Unconditionally add all rules
1 parent 183270b commit a6fd8c8

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

src/core/egglog-herbie.rkt

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,10 @@
7777
(define insert-brfs (egglog-runner-brfs runner))
7878
(define curr-program (make-egglog-program))
7979

80-
;; 1. Add the Prelude
80+
;; 1. Add the Prelude (includes all rules)
8181
(prelude curr-program #:mixed-egraph? #t)
8282

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)
10184

10285
;; Overview of the new extraction method:
10386
;;
@@ -162,19 +145,16 @@
162145

163146
;; 4. Running the schedule : having code inside to emulate egraph-run-rules
164147

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
170150
['lift (send-to-egglog (list '(run-schedule (saturate lift))) subproc)]
171151

172152
['lower (send-to-egglog (list '(run-schedule (saturate lower))) subproc)]
173153

174154
['unsound (send-to-egglog (list '(run-schedule (saturate unsound))) subproc)]
175155

176156
;; 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)]))
178158

179159
;; 5. Extraction -> should just need constructor names from egglog-add-exprs
180160
(define extract-commands
@@ -306,6 +286,13 @@
306286

307287
(egglog-program-add! (approx-lifting-rule) curr-program)
308288

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+
309296
(void))
310297

311298
(define const-fold

0 commit comments

Comments
 (0)