-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PR#175 with all the changes agreed upon at the weekly Qi compi…
…ler meeting on 2024-06-21. - add detailed explanation for inline-consing syntax - use Racket's conventions for parentheses - add description of fsp-, fst-, and fsc- prefixes - move define-and-register-deforest-pass and related to separate module, add comments
- Loading branch information
1 parent
de25f55
commit 2f3085b
Showing
3 changed files
with
129 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#lang racket/base | ||
|
||
(provide define-and-register-deforest-pass) | ||
|
||
(require (for-syntax racket/base | ||
syntax/parse) | ||
syntax/parse | ||
"syntax.rkt" | ||
"../../passes.rkt" | ||
"../../strategy.rkt") | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; The actual fusion generator implementation | ||
|
||
;; Used only in deforest-rewrite to properly recognize the end of | ||
;; fusable sequence. | ||
(define-syntax-class non-fusable | ||
(pattern (~not (~or _:fst-syntax | ||
_:fsp-syntax | ||
_:fsc-syntax)))) | ||
|
||
(define (make-deforest-rewrite generate-fused-operation) | ||
(lambda (stx) | ||
(syntax-parse stx | ||
[((~datum thread) _0:non-fusable ... | ||
p:fsp-syntax | ||
;; There can be zero transformers here: | ||
t:fst-syntax ... | ||
c:fsc-syntax | ||
_1 ...) | ||
#:with fused (generate-fused-operation | ||
(syntax->list #'(p t ... c)) | ||
stx) | ||
#'(thread _0 ... fused _1 ...)] | ||
[((~datum thread) _0:non-fusable ... | ||
t1:fst-syntax0 | ||
t:fst-syntax ... | ||
c:fsc-syntax | ||
_1 ...) | ||
#:with fused (generate-fused-operation | ||
(syntax->list #'(list->cstream t1 t ... c)) | ||
stx) | ||
#'(thread _0 ... fused _1 ...)] | ||
[((~datum thread) _0:non-fusable ... | ||
p:fsp-syntax | ||
;; Must be 1 or more transformers here: | ||
t:fst-syntax ...+ | ||
_1 ...) | ||
#:with fused (generate-fused-operation | ||
(syntax->list #'(p t ... cstream->list)) | ||
stx) | ||
#'(thread _0 ... fused _1 ...)] | ||
[((~datum thread) _0:non-fusable ... | ||
f1:fst-syntax0 | ||
f:fst-syntax ...+ | ||
_1 ...) | ||
#:with fused (generate-fused-operation | ||
(syntax->list #'(list->cstream f1 f ... cstream->list)) | ||
stx) | ||
#'(thread _0 ... fused _1 ...)] | ||
;; return the input syntax unchanged if no rules | ||
;; are applicable | ||
[_ stx]))) | ||
|
||
;; This syntax is actively used only once as it is intended to be used | ||
;; by alternative implementations. Currently only the CPS | ||
;; implementation uses it, however in the near future the named-let | ||
;; implementation will use it as well. | ||
(define-syntax (define-and-register-deforest-pass stx) | ||
(syntax-parse stx | ||
((_ (deforest-pass ops ctx) expr ...) | ||
#'(define-and-register-pass 100 (deforest-pass stx) | ||
(find-and-map/qi | ||
(make-deforest-rewrite | ||
(lambda (ops ctx) | ||
expr ...)) | ||
stx))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters