Skip to content

Commit 8760810

Browse files
authored
Merge pull request #1359 from herbie-fp/codex/move-validate-platform-to-platform-language.rkt
Move validate-platform into platform-language
2 parents d00d235 + 494a339 commit 8760810

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/syntax/platform-language.rkt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@
244244
; Update table
245245
(hash-set! impls (operator-impl-name impl) impl))
246246

247+
(define (validate-platform! platform)
248+
(when (empty? (platform-implementations platform))
249+
(raise-herbie-error "Platform contains no operations"))
250+
(for ([(name impl) (in-hash (platform-implementations platform))])
251+
(define ctx (operator-impl-ctx impl))
252+
(for ([repr (in-list (cons (context-repr ctx) (context-var-reprs ctx)))])
253+
(unless (equal? (hash-ref (platform-representations platform) (representation-name repr) #f)
254+
repr)
255+
(raise-herbie-error "Representation ~a not defined" (representation-name repr))))))
256+
247257
(define-syntax (platform-register-implementations! stx)
248258
(syntax-case stx ()
249259
[(_ platform ([name ([var : repr] ...) otype spec fl fpcore cost] ...))

src/syntax/platform.rkt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
platform-lifting-rules
3333
platform-lowering-rules
3434
platform-copy
35-
validate-platform!
3635
repr-exists?
3736
get-representation
3837
impl-exists?
@@ -68,16 +67,6 @@
6867
(define impls (make-hash))
6968
(create-platform reprs impls repr-costs))
7069

71-
(define (validate-platform! platform)
72-
(when (empty? (platform-implementations platform))
73-
(raise-herbie-error "Platform contains no operations"))
74-
(for ([(name impl) (in-hash (platform-implementations platform))])
75-
(define ctx (operator-impl-ctx impl))
76-
(for ([repr (in-list (cons (context-repr ctx) (context-var-reprs ctx)))])
77-
(unless (equal? (hash-ref (platform-representations platform) (representation-name repr) #f)
78-
repr)
79-
(raise-herbie-error "Representation ~a not defined" (representation-name repr))))))
80-
8170
;; Returns the representation associated with `name`
8271
;; attempts to generate the repr if not initially found
8372
(define (get-representation name)

0 commit comments

Comments
 (0)