File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 287287 [`(Explanation ,body ... ) `(Explanation ,@(map (lambda (e) (loop e type)) body))]
288288 [(list 'Rewrite=> rule expr) (list 'Rewrite=> (get-canon-rule-name rule rule) (loop expr type))]
289289 [(list 'Rewrite<= rule expr) (list 'Rewrite<= (get-canon-rule-name rule rule) (loop expr type))]
290- [(list op args ... )
291- #:when (string-prefix? (symbol->string op) "sound- " )
292- (define op* (string->symbol (substring (symbol->string (car expr)) (string-length "sound- " ))))
293- (define args* (drop-right args 1 ))
294- (cons op* (map loop args* (map (const 'real ) args*)))]
295290 [(list op args ... )
296291 ;; Unfortunately the type parameter doesn't tell us much because mixed exprs exist
297292 ;; so if we see something like (and a b) we literally don't know which "and" it is
Original file line number Diff line number Diff line change 9090 approxs*)
9191
9292(define (run-lowering altns global-batch)
93- (define schedule `((lower . ((iteration . 1 ) (scheduler . simple)))))
93+ (define schedule
94+ `((,(*sound-removal-rules*) . ((iteration . 1 ) (scheduler . simple)))
95+ (lower . ((iteration . 1 ) (scheduler . simple)))))
9496
9597 ; run egg
9698 (define brfs (map alt-expr altns))
160162 ; generate required rules
161163 (define rules (*rules*))
162164
163- ; egg schedule (3 -phases for mathematical rewrites and implementation selection)
165+ ; egg schedule (4 -phases for mathematical rewrites, sound-X removal, and implementation selection)
164166 (define schedule
165167 (list `(lift . ((iteration . 1 ) (scheduler . simple)))
166168 `(,rules . ((node . ,(*node-limit*))))
169+ `(,(*sound-removal-rules*) . ((iteration . 1 ) (scheduler . simple)))
167170 `(lower . ((iteration . 1 ) (scheduler . simple)))))
168171
169172 (define brfs (map alt-expr altns))
Original file line number Diff line number Diff line change 66 "../syntax/syntax.rkt " )
77
88(provide *rules*
9+ *sound-removal-rules*
910 (struct-out rule)
1011 add-sound)
1112
612613 [cosh-atanh-rev (/ 1 (sqrt (- 1 (* x x)))) (cosh (atanh x))]
613614 [asinh-2 (acosh (+ (* 2 (* x x)) 1 )) (* 2 (asinh (fabs x)))]
614615 [acosh-2-rev (* 2 (acosh x)) (acosh (- (* 2 (* x x)) 1 ))])
616+
617+ ; Sound-X removal rules: run these before lowering
618+ (define (*sound-removal-rules*)
619+ (list (rule 'remove-sound-/ '(sound-/ a b fallback) '(/ a b) '(sound-removal))
620+ (rule 'remove-sound-pow '(sound-pow a b fallback) '(pow a b) '(sound-removal))
621+ (rule 'remove-sound-log '(sound-log a fallback) '(log a) '(sound-removal))))
You can’t perform that action at this time.
0 commit comments