|
4 | 4 | (require "../utils/common.rkt" |
5 | 5 | "../utils/errors.rkt" |
6 | 6 | "../config.rkt" |
7 | | - "../core/rules.rkt" |
8 | 7 | "matcher.rkt" |
9 | 8 | "types.rkt" |
10 | 9 | "syntax.rkt" |
|
29 | 28 | (fprintf port "#<platform>"))]) |
30 | 29 |
|
31 | 30 | (provide *active-platform* |
32 | | - platform-lifting-rules |
33 | | - platform-lowering-rules |
34 | 31 | platform-copy |
35 | 32 | repr-exists? |
36 | 33 | get-representation |
|
170 | 167 | (define itypes (impl-info impl 'itype)) |
171 | 168 | (apply cost-proc (map loop args itypes))])))) |
172 | 169 |
|
173 | | -;; Rules from impl to spec (fixed for a particular platform) |
174 | | -(define/reset *lifting-rules* (make-hash)) |
175 | | - |
176 | | -;; Rules from spec to impl (fixed for a particular platform) |
177 | | -(define/reset *lowering-rules* (make-hash)) |
178 | | - |
179 | | -;; Synthesizes the LHS and RHS of lifting/lowering rules. |
180 | | -(define (impl->rule-parts impl) |
181 | | - (define vars (impl-info impl 'vars)) |
182 | | - (define spec (impl-info impl 'spec)) |
183 | | - (values vars spec (cons impl vars))) |
184 | | - |
185 | | -;; Synthesizes lifting rules for a platform platform. |
186 | | -(define (platform-lifting-rules [pform (*active-platform*)]) |
187 | | - (define impls (platform-impls pform)) |
188 | | - (for/list ([impl (in-list impls)]) |
189 | | - (hash-ref! (*lifting-rules*) |
190 | | - (cons impl pform) |
191 | | - (lambda () |
192 | | - (define name (sym-append 'lift- impl)) |
193 | | - (define-values (vars spec-expr impl-expr) (impl->rule-parts impl)) |
194 | | - (rule name impl-expr spec-expr '(lifting)))))) |
195 | | - |
196 | | -;; Synthesizes lowering rules for a given platform. |
197 | | -(define (platform-lowering-rules [pform (*active-platform*)]) |
198 | | - (define impls (platform-impls pform)) |
199 | | - (append* (for/list ([impl (in-list impls)]) |
200 | | - (hash-ref! (*lowering-rules*) |
201 | | - (cons impl pform) |
202 | | - (lambda () |
203 | | - (define name (sym-append 'lower- impl)) |
204 | | - (define-values (vars spec-expr impl-expr) (impl->rule-parts impl)) |
205 | | - (list (rule name spec-expr impl-expr '(lowering)) |
206 | | - (rule (sym-append 'lower-unsound- impl) |
207 | | - (add-unsound spec-expr) |
208 | | - impl-expr |
209 | | - '(lowering)))))))) |
210 | | - |
211 | 170 | ;; Extracts the `fpcore` field of an operator implementation |
212 | 171 | ;; as a property dictionary and expression. |
213 | 172 | (define (impl->fpcore impl) |
|
0 commit comments