First working version for takl loops

This commit is contained in:
Justin Ethier 2018-06-07 21:58:52 -04:00
parent e80b83440e
commit 9c1ea32be0

View file

@ -712,7 +712,7 @@
;; c-compile-app : app-exp (string -> void) -> string ;; c-compile-app : app-exp (string -> void) -> string
(define (c-compile-app exp append-preamble cont trace cps?) (define (c-compile-app exp append-preamble cont trace cps?)
(trace:info `(c-compile-app: ,exp ,trace)) ;;(trace:info `(c-compile-app: ,exp ,trace))
(let (($tmp (mangle (gensym 'tmp)))) (let (($tmp (mangle (gensym 'tmp))))
(let* ((args (app->args exp)) (let* ((args (app->args exp))
(fun (app->fun exp))) (fun (app->fun exp)))
@ -746,61 +746,28 @@
(map (lambda (a) (c:allocs->str (c:allocs a))) cgen-lis))) (map (lambda (a) (c:allocs->str (c:allocs a))) cgen-lis)))
(parent-fnc (adbv:assigned-value (adb:get (cdr trace)))) (parent-fnc (adbv:assigned-value (adb:get (cdr trace))))
(parent-args (ast:lambda-args (if (pair? parent-fnc) (car parent-fnc) parent-fnc))) (parent-args
;; TODO: extract top-level function args from anaylsis DB?? (cdr ;; Skip continuation
;; (shorterp (ast:lambda-args
;; . (if (pair? parent-fnc)
;; #((record-marker) (car parent-fnc)
;; #((record-marker) parent-fnc))))
;; "<analysis-db-variable>" (cgen-body
;; (global (apply
;; defined-by string-append
;; defines-lambda-id (map
;; const (lambda (arg body-exp)
;; const-value (string-append
;; ref-count (mangle arg)
;; ref-by " = "
;; reassigned (c:body body-exp)
;; assigned-value ";"
;; app-fnc-count
;; app-arg-count
;; inlinable
;; mutated-indirectly
;; cont
;; def-in-loop
;; ref-in-loop
;; direct-rec-call))
;; #(?
;; -1
;; 130
;; #f
;; #f
;; 3
;; (130 -1 138)
;; #f
;; (#((record-marker)
;; #((record-marker)
;; "<lambda-ast>"
;; (id args body has-cont))
;; #(130
;; (k$241 x$6$133 y$5$132)
;; ((if (null? y$5$132)
;; (k$241 #f)
;; (if (null? x$6$133)
;; (k$241 #t)
;; (shorterp k$241 (cdr x$6$133) (cdr y$5$132)))))
;; #t)))
;; 2
;; 0
;; #f
;; #f
;; #f
;; #f
;; #f
;; #t)))
;;
) )
(trace:info `(loop ,cgen-lis ,parent-args)) )
parent-args
cgen-lis)))
)
;;(trace:info `(loop ,cgen-lis ,parent-args))
;; Output so far on ntakl: ;; Output so far on ntakl:
;;(loop (("Cyc_cdr(data, x_736_73133)" ()) ;;(loop (("Cyc_cdr(data, x_736_73133)" ())
;; ("Cyc_cdr(data, y_735_73132)" ())) ;; ("Cyc_cdr(data, y_735_73132)" ()))
@ -810,7 +777,7 @@
(string-append (string-append
cgen-allocs ;(c:allocs->str (c:allocs cgen)) cgen-allocs ;(c:allocs->str (c:allocs cgen))
"\n" "\n"
;; TODO: (c:body cgen) ;; TODO: re-assign function args, longer-term using temp variables cgen-body ;; TODO: (c:body cgen) ;; TODO: re-assign function args, longer-term using temp variables
"\n" "\n"
"goto loop;"))) "goto loop;")))
) )
@ -1369,8 +1336,10 @@
(has-closure? "") (has-closure? "")
(else (else
(string-append (string-append
(st:->code trace)
;; TODO: probably needs brackets afterwards...
(if has-loop? "\nloop:\n" "") (if has-loop? "\nloop:\n" "")
(st:->code trace))))) ))))
body) body)
" ") " ")
"; \n" "; \n"