mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 08:17:35 +02:00
WIP - explicit inlines
This commit is contained in:
parent
edccb56163
commit
8b6830ea49
1 changed files with 18 additions and 0 deletions
18
cyclone.scm
18
cyclone.scm
|
@ -36,6 +36,7 @@
|
||||||
(define module-globals '()) ;; Globals defined by this module
|
(define module-globals '()) ;; Globals defined by this module
|
||||||
(define program? #t) ;; Are we building a program or a library?
|
(define program? #t) ;; Are we building a program or a library?
|
||||||
(define imports '())
|
(define imports '())
|
||||||
|
(define inlines '())
|
||||||
(define imported-vars '())
|
(define imported-vars '())
|
||||||
(define lib-name '())
|
(define lib-name '())
|
||||||
(define lib-exports '())
|
(define lib-exports '())
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
(set! program? #f)
|
(set! program? #f)
|
||||||
(set! lib-name (lib:name (car input-program)))
|
(set! lib-name (lib:name (car input-program)))
|
||||||
(set! c-headers (lib:include-c-headers (car input-program)))
|
(set! c-headers (lib:include-c-headers (car input-program)))
|
||||||
|
(set! inlines (lib:inlines (car input-program)))
|
||||||
(set! lib-exports
|
(set! lib-exports
|
||||||
(cons
|
(cons
|
||||||
(lib:name->symbol lib-name)
|
(lib:name->symbol lib-name)
|
||||||
|
@ -89,6 +91,17 @@
|
||||||
(set! imports (car reduction))
|
(set! imports (car reduction))
|
||||||
(set! input-program (cdr reduction)))
|
(set! input-program (cdr reduction)))
|
||||||
|
|
||||||
|
;; Handle inline list, if present`
|
||||||
|
(let ((lis (lib:inlines `(dummy dummy ,@input-program))))
|
||||||
|
(cond
|
||||||
|
((not (null? lis))
|
||||||
|
(set! inlines lis)
|
||||||
|
(set! input-program
|
||||||
|
(filter
|
||||||
|
(lambda (expr)
|
||||||
|
(not (tagged-list? 'inline expr)))
|
||||||
|
input-program)))))
|
||||||
|
|
||||||
;; Handle any C headers
|
;; Handle any C headers
|
||||||
(let ((headers (lib:include-c-headers `(dummy dummy ,@input-program))))
|
(let ((headers (lib:include-c-headers `(dummy dummy ,@input-program))))
|
||||||
(cond
|
(cond
|
||||||
|
@ -101,6 +114,9 @@
|
||||||
input-program)))))
|
input-program)))))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(trace:info "inline candidates:")
|
||||||
|
(trace:info inlines)
|
||||||
|
|
||||||
;; Process library imports
|
;; Process library imports
|
||||||
(trace:info "imports:")
|
(trace:info "imports:")
|
||||||
(trace:info imports)
|
(trace:info imports)
|
||||||
|
@ -298,11 +314,13 @@
|
||||||
(trace:info input-program) ;pretty-print
|
(trace:info input-program) ;pretty-print
|
||||||
|
|
||||||
;; Identify native Scheme functions (from module being compiled) that can be inlined
|
;; Identify native Scheme functions (from module being compiled) that can be inlined
|
||||||
|
;; TODO: this will never work 100%. I suggest Scheme code needs to be able to make functions as inline, and the code below will run those functions through the inlinable-top-level-lambda? check below.
|
||||||
(define inlinable-scheme-fncs '())
|
(define inlinable-scheme-fncs '())
|
||||||
(let ((lib-init-fnc (lib:name->symbol lib-name))) ;; safe to ignore for programs
|
(let ((lib-init-fnc (lib:name->symbol lib-name))) ;; safe to ignore for programs
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (e)
|
(lambda (e)
|
||||||
(when (and (define? e)
|
(when (and (define? e)
|
||||||
|
#f ;; TODO: replace with lookup check from user-specified inline list
|
||||||
(not (equal? (define->var e) lib-init-fnc))
|
(not (equal? (define->var e) lib-init-fnc))
|
||||||
(inlinable-top-level-lambda? e))
|
(inlinable-top-level-lambda? e))
|
||||||
(set! inlinable-scheme-fncs
|
(set! inlinable-scheme-fncs
|
||||||
|
|
Loading…
Add table
Reference in a new issue