|
289 | 289 | [(list 'Rewrite<= rule expr) (list 'Rewrite<= (get-canon-rule-name rule rule) (loop expr type))] |
290 | 290 | [(list op args ...) |
291 | 291 | #:when (string-prefix? (symbol->string op) "sound-") |
292 | | - (define op* (string->symbol (substring (symbol->string (car expr)) (string-length "sound-")))) |
| 292 | + (define op* (string->symbol (substring (symbol->string op) (string-length "sound-")))) |
293 | 293 | (define args* (drop-right args 1)) |
294 | 294 | (cons op* (map loop args* (map (const 'real) args*)))] |
295 | 295 | [(list op args ...) |
|
525 | 525 | ;; Synthesizes lowering rules for a given platform. |
526 | 526 | (define (platform-lowering-rules [pform (*active-platform*)]) |
527 | 527 | (define impls (platform-impls pform)) |
528 | | - (append* |
529 | | - (for/list ([impl (in-list impls)]) |
530 | | - (hash-ref! |
531 | | - (*lowering-rules*) |
532 | | - (cons impl pform) |
533 | | - (lambda () |
534 | | - (define name (sym-append 'lower- impl)) |
535 | | - (define-values (vars spec-expr impl-expr) (impl->rule-parts impl)) |
536 | | - (list (rule name spec-expr impl-expr '(lowering)) |
537 | | - (rule (sym-append 'lower-sound- impl) (add-sound spec-expr) impl-expr '(lowering)))))))) |
| 528 | + (append* (for/list ([impl (in-list impls)]) |
| 529 | + (hash-ref! (*lowering-rules*) |
| 530 | + (cons impl pform) |
| 531 | + (lambda () |
| 532 | + (define name (sym-append 'lower- impl)) |
| 533 | + (define-values (vars spec-expr impl-expr) (impl->rule-parts impl)) |
| 534 | + (list (rule name spec-expr impl-expr '(lowering)))))))) |
538 | 535 |
|
539 | 536 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
540 | 537 | ;; Racket egraph |
|
1257 | 1254 | ['lower |
1258 | 1255 | (define rules (expand-rules (platform-lowering-rules))) |
1259 | 1256 | (egraph-run-rules egg-graph rules #:iter-limit 1 #:scheduler 'simple)] |
| 1257 | + ['unsound |
| 1258 | + (define rules (expand-rules (*sound-removal-rules*))) |
| 1259 | + (egraph-run-rules egg-graph rules #:iter-limit 1 #:scheduler 'simple)] |
1260 | 1260 | ['rewrite |
1261 | 1261 | (define rules (expand-rules (*rules*))) |
1262 | 1262 | (egraph-run-rules egg-graph rules #:node-limit (*node-limit*))])) |
|
1298 | 1298 | ;; The schedule is a list of step symbols: |
1299 | 1299 | ;; - `lift`: run lifting rules for 1 iteration with simple scheduler |
1300 | 1300 | ;; - `rewrite`: run rewrite rules up to node limit with backoff scheduler |
| 1301 | +;; - `unsound`: run sound-removal rules for 1 iteration with simple scheduler |
1301 | 1302 | ;; - `lower`: run lowering rules for 1 iteration with simple scheduler |
1302 | 1303 | (define (make-egraph batch brfs reprs schedule ctx) |
1303 | 1304 | (define (oops! fmt . args) |
1304 | 1305 | (apply error 'verify-schedule! fmt args)) |
1305 | 1306 | ; verify the schedule |
1306 | 1307 | (for ([step (in-list schedule)]) |
1307 | | - (unless (memq step '(lift lower rewrite)) |
| 1308 | + (unless (memq step '(lift lower unsound rewrite)) |
1308 | 1309 | (oops! "unknown schedule step `~a`" step))) |
1309 | 1310 |
|
1310 | 1311 | (define-values (root-ids egg-graph) (egraph-run-schedule batch brfs schedule ctx)) |
|
0 commit comments