mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Rework setting of globals and checking flags, for cps opt
This commit is contained in:
parent
3af8cef894
commit
53471fc4c1
2 changed files with 23 additions and 20 deletions
35
cyclone.scm
35
cyclone.scm
|
@ -433,35 +433,40 @@
|
|||
(trace:info "---------------- after CPS:")
|
||||
(trace:info (ast:ast->pp-sexp input-program))
|
||||
|
||||
(define
|
||||
*cps-opt-options*
|
||||
(list
|
||||
(cons 'module-globals module-globals)
|
||||
;(cons)
|
||||
))
|
||||
TODO: use this function to set module-globals and globals, then pass it instead of options above
|
||||
(define (inject-globals lis)
|
||||
(cons 'module-globals module-globals)
|
||||
;(set! globals (union globals '())) ;; Ensure list is sorted
|
||||
;(define
|
||||
; *cps-opt-options*
|
||||
; (list
|
||||
; (cons 'module-globals module-globals)
|
||||
; ;(cons)
|
||||
; ))
|
||||
;TODO: use this function to set module-globals and globals, then pass it instead of options above
|
||||
(define (inject-globals! lis)
|
||||
(set! module-globals (append module-globals lis))
|
||||
(set! globals (append globals lis))
|
||||
(set! globals (union globals '())) ;; Ensure list is sorted
|
||||
)
|
||||
TODO: pass this function to check flags, instead of having search logic in CPS opt module
|
||||
(define (flag-set? flag)
|
||||
;TODO: pass this function to check flags, instead of having search logic in CPS opt module
|
||||
(define (flag-set? flag)
|
||||
(cond
|
||||
((eq? flag 'memoize-pure-functions)
|
||||
#t)
|
||||
(else #f)))
|
||||
|
||||
(when (> *optimization-level* 0)
|
||||
(set! input-program
|
||||
(optimize-cps input-program *cps-opt-options*))
|
||||
(optimize-cps input-program inject-globals! flag-set?))
|
||||
(report:elapsed "---------------- after cps optimizations (1):")
|
||||
(trace:info "---------------- after cps optimizations (1):")
|
||||
(trace:info (ast:ast->pp-sexp input-program))
|
||||
|
||||
(set! input-program
|
||||
(optimize-cps input-program *cps-opt-options*))
|
||||
(optimize-cps input-program inject-globals! flag-set?))
|
||||
(report:elapsed "---------------- after cps optimizations (2):")
|
||||
(trace:info "---------------- after cps optimizations (2):")
|
||||
(trace:info (ast:ast->pp-sexp input-program))
|
||||
|
||||
(set! input-program
|
||||
(optimize-cps input-program *cps-opt-options*))
|
||||
(optimize-cps input-program inject-globals! flag-set?))
|
||||
(report:elapsed "---------------- after cps optimizations (3):")
|
||||
(trace:info "---------------- after cps optimizations (3):")
|
||||
(trace:info (ast:ast->pp-sexp input-program))
|
||||
|
|
|
@ -1700,7 +1700,7 @@
|
|||
;; TODO: re-run phases again until program is stable (less than n opts made, more than r rounds performed, etc)
|
||||
;; END notes
|
||||
|
||||
(define (optimize-cps ast . options)
|
||||
(define (optimize-cps ast add-globals! flag-set?)
|
||||
(adb:clear!)
|
||||
(analyze-cps ast)
|
||||
(trace:info "---------------- cps analysis db:")
|
||||
|
@ -1716,10 +1716,8 @@
|
|||
)
|
||||
|
||||
;; Memoize pure functions, if instructed
|
||||
(let ((module-globals-pair (assoc 'module-globals (car options))))
|
||||
(when (and module-globals-pair #t ;; TODO: (assoc 'memoize-pure-functions (car options))
|
||||
)
|
||||
(set! new-ast (opt:memoize-pure-fncs new-ast (cdr module-globals-pair))))
|
||||
(when (and (procedure? flag-set?) (flag-set? 'memoize-pure-functions))
|
||||
(set! new-ast (opt:memoize-pure-fncs new-ast add-globals!))
|
||||
)
|
||||
new-ast
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue