Skip to content

Commit 1404b15

Browse files
committed
Just send commands right away
1 parent 130f032 commit 1404b15

File tree

1 file changed

+27
-38
lines changed

1 file changed

+27
-38
lines changed

src/core/egglog-herbie.rkt

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@
470470
(define mappings (build-vector (batch-length batch) values))
471471
(define bindings (make-hash))
472472
(define vars (make-hash))
473-
(define commands-to-send '()) ; Accumulate all commands to send
474473
(define (remap x spec?)
475474
(cond
476475
[(hash-has-key? vars x)
@@ -545,34 +544,30 @@
545544
(set! root-bindings (cons (vector-ref mappings n) root-bindings))))
546545

547546
; Var-lowering-rules
548-
(for ([var (in-list (context-vars ctx))]
549-
[repr (in-list (context-var-reprs ctx))])
550-
551-
(set! commands-to-send
552-
(cons `(rule ((= e (Var ,(symbol->string var))))
553-
((let ty ,(symbol->string (representation-name repr))
554-
)
555-
(let ety (,(typed-var-id (representation-name repr))
556-
,(symbol->string var))
557-
)
558-
(union (do-lower e ty) ety))
559-
:ruleset
560-
lower)
561-
commands-to-send)))
547+
(send-to-egglog (for/list ([var (in-list (context-vars ctx))]
548+
[repr (in-list (context-var-reprs ctx))])
549+
`(rule ((= e (Var ,(symbol->string var))))
550+
((let ty ,(symbol->string (representation-name repr))
551+
)
552+
(let ety (,(typed-var-id (representation-name repr))
553+
,(symbol->string var))
554+
)
555+
(union (do-lower e ty) ety))
556+
:ruleset
557+
lower))
558+
subproc)
562559

563560
; Var-lifting-rules
564-
(for ([var (in-list (context-vars ctx))]
565-
[repr (in-list (context-var-reprs ctx))])
566-
567-
(set! commands-to-send
568-
(cons `(rule ((= e (,(typed-var-id (representation-name repr)) ,(symbol->string var))))
569-
((let se (Var
570-
,(symbol->string var))
571-
)
572-
(union (do-lift e) se))
573-
:ruleset
574-
lift)
575-
commands-to-send)))
561+
(send-to-egglog (for/list ([var (in-list (context-vars ctx))]
562+
[repr (in-list (context-var-reprs ctx))])
563+
`(rule ((= e (,(typed-var-id (representation-name repr)) ,(symbol->string var))))
564+
((let se (Var
565+
,(symbol->string var))
566+
)
567+
(union (do-lift e) se))
568+
:ruleset
569+
lift))
570+
subproc)
576571

577572
(define all-bindings '())
578573
(define binding->constructor (make-hash)) ; map from binding name to constructor name
@@ -589,9 +584,8 @@
589584
; Define the actual binding
590585
(define curr-var-spec-binding `(let ,binding-name (Var ,(symbol->string var))))
591586

592-
; Add the unique constructor to send list
593-
(set! commands-to-send
594-
(cons `(constructor ,constructor-name () M :unextractable) commands-to-send))
587+
; Send the constructor definition
588+
(send-to-egglog (list `(constructor ,constructor-name () M :unextractable)) subproc)
595589

596590
; Add the binding and constructor set to all-bindings for the future rule
597591
(set! all-bindings (cons curr-var-spec-binding all-bindings))
@@ -611,9 +605,8 @@
611605
(define curr-var-typed-binding
612606
`(let ,binding-name (,(typed-var-id (representation-name repr)) ,(symbol->string var))))
613607

614-
; Add the unique constructor to send list
615-
(set! commands-to-send
616-
(cons `(constructor ,constructor-name () MTy :unextractable) commands-to-send))
608+
; Send the constructor definition
609+
(send-to-egglog (list `(constructor ,constructor-name () MTy :unextractable)) subproc)
617610

618611
; Add the binding and constructor set to all-bindings for the future rule
619612
(set! all-bindings (cons curr-var-typed-binding all-bindings))
@@ -646,8 +639,7 @@
646639

647640
(define curr-binding-exprs `(let ,binding-name ,actual-binding))
648641

649-
(set! commands-to-send
650-
(cons `(constructor ,constructor-name () ,curr-datatype :unextractable) commands-to-send))
642+
(send-to-egglog (list `(constructor ,constructor-name () ,curr-datatype :unextractable)) subproc)
651643

652644
(set! all-bindings (cons curr-binding-exprs all-bindings))
653645
(set! all-bindings (cons `(set (,constructor-name) ,binding-name) all-bindings))
@@ -666,9 +658,6 @@
666658

667659
(hash-ref binding->constructor curr-binding-name)))
668660

669-
; Send all accumulated commands to egglog
670-
(send-to-egglog (reverse commands-to-send) subproc)
671-
672661
(values (reverse all-bindings) curr-bindings))
673662

674663
(define (egglog-unsound-detected-subprocess tag subproc)

0 commit comments

Comments
 (0)