;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
$kreceive $kargs $kfun $ktail $kclause
;; Expressions.
- $void $const $prim $fun $closure $branch
+ $const $prim $fun $closure $branch
$call $callk $primcall $values $prompt
;; First-order CPS root.
(define-cps-type $kclause arity cont alternate)
;; Expressions.
-(define-cps-type $void)
(define-cps-type $const val)
(define-cps-type $prim name)
(define-cps-type $fun free body) ; Higher-order.
(define-syntax build-cps-exp
(syntax-rules (unquote
- $void $const $prim $fun $closure $branch
+ $const $prim $fun $closure $branch
$call $callk $primcall $values $prompt)
((_ (unquote exp)) exp)
- ((_ ($void)) (make-$void))
((_ ($const val)) (make-$const val))
((_ ($prim name)) (make-$prim name))
((_ ($fun free body)) (make-$fun free (build-cps-cont body)))
;; Calls.
(('continue k exp)
(build-cps-term ($continue k (src exp) ,(parse-cps exp))))
- (('void)
- (build-cps-exp ($void)))
(('const exp)
(build-cps-exp ($const exp)))
(('prim name)
;; Calls.
(($ $continue k src exp)
`(continue ,k ,(unparse-cps exp)))
- (($ $void)
- `(void))
(($ $const val)
`(const ,val))
(($ $prim name)
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
($continue k src
($primcall 'return (unspec)))))
(kvoid ($kargs () ()
- ($continue kunspec src ($void)))))
+ ($continue kunspec src
+ ($const *unspecified*)))))
($continue kvoid src ,exp)))))
(($ $kreceive arity kargs)
,(match arity
($primcall 'values (void)))))
(kvoid ($kargs () ()
($continue kvalues src
- ($void)))))
+ ($const *unspecified*)))))
($continue kvoid src ,exp)))))))
(($ $kargs () () _)
($continue k src ,exp))
(_
,(let-fresh (k*) ()
(build-cps-term
- ($letk ((k* ($kargs () () ($continue k src ($void)))))
+ ($letk ((k* ($kargs () () ($continue k src
+ ($const *unspecified*)))))
($continue k* src ,exp)))))))
(1
(rewrite-cps-term (lookup-cont k dfg)
(define (visit-exp k src exp)
(rewrite-cps-term exp
- ((or ($ $void)
- ($ $const)
+ ((or ($ $const)
($ $prim)
($ $values (_)))
,(adapt-exp 1 k src exp))
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
free
(cons var free)))
(match exp
- ((or ($ $void) ($ $const) ($ $prim)) '())
+ ((or ($ $const) ($ $prim)) '())
(($ $call proc args)
(for-each clear-well-known! args)
(fold adjoin (adjoin proc '()) args))
src var (well-known? kfun) fun-free
body)))))))
- (($ $continue k src (or ($ $void) ($ $const) ($ $prim)))
+ (($ $continue k src (or ($ $const) ($ $prim)))
term)
(($ $continue k src ($ $fun () ($ $cont kfun)))
(($ $values (arg))
(or (maybe-load-constant dst arg)
(maybe-mov dst (slot arg))))
- (($ $void)
- (emit-load-constant asm dst *unspecified*))
(($ $const exp)
(emit-load-constant asm dst exp))
(($ $closure k 0)
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(define (compute-exp-key exp)
(match exp
- (($ $void) 'void)
(($ $const val) (cons 'const val))
(($ $prim name) (cons 'prim name))
(($ $fun free body) #f)
(define (visit-exp exp)
;; We shouldn't see $fun here.
(rewrite-cps-exp exp
- ((or ($ $void) ($ $const) ($ $prim)) ,exp)
+ ((or ($ $const) ($ $prim)) ,exp)
(($ $call proc args)
($call (subst-var proc) ,(map subst-var args)))
(($ $callk k proc args)
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(bitvector-set! live-conts n #t)))
(when (bitvector-ref live-conts n)
(match exp
- ((or ($ $void) ($ $const) ($ $prim))
+ ((or ($ $const) ($ $prim))
#f)
(($ $fun free body)
(visit-fun body))
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(define (use! sym)
(add-use! sym label))
(match exp
- ((or ($ $void) ($ $const) ($ $prim) ($ $closure)) #f)
+ ((or ($ $const) ($ $prim) ($ $closure)) #f)
(($ $call proc args)
(use! proc)
(for-each use! args))
(format port " k~a k~a\n" kt kf))
(($ $continue k src exp)
(match exp
- (($ $void) (format port "void"))
(($ $const val) (format port "const ~@y" val))
(($ $prim name) (format port "prim ~a" name))
(($ $fun free ($ $cont kbody)) (format port "fun k~a" kbody))
(match (find-defining-expression sym dfg)
(($ $const val)
(values #t val))
- (($ $continue k src ($ $void))
- (values #t *unspecified*))
(else
(values #f #f))))
(define (expression-effects exp dfg)
(match exp
- ((or ($ $void) ($ $const) ($ $prim) ($ $values))
+ ((or ($ $const) ($ $prim) ($ $values))
&no-effects)
(($ $fun)
(&allocate &unknown-memory-kinds))
=> (lambda (idx)
(builtin-ref idx k src)))
(else (primitive-ref name k src)))
- (build-cps-term ($continue k src ($void)))))
+ (build-cps-term ($continue k src
+ ($const *unspecified*)))))
(($ $primcall 'call-thunk/no-inline (proc))
(build-cps-term
($continue k src ($call proc ()))))
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
($continue (relabel k) src ,(visit-exp exp)))))
(define (visit-exp exp)
(match exp
- ((or ($ $void) ($ $const) ($ $prim))
+ ((or ($ $const) ($ $prim))
exp)
(($ $closure k nfree)
(build-cps-exp ($closure (relabel k) nfree)))
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(define (visit-exp exp)
(rewrite-cps-exp exp
- ((or ($ $void) ($ $const) ($ $prim)) ,exp)
+ ((or ($ $const) ($ $prim)) ,exp)
(($ $fun free body)
($fun free ,(resolve-self-references body env)))
(($ $call proc args)
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
(build-cps-term ($continue k src ,(visit-exp exp))))))))
(define (visit-exp exp)
(match exp
- ((or ($ $void) ($ $const) ($ $prim)) exp)
+ ((or ($ $const) ($ $prim)) exp)
(($ $fun) (visit-fun exp))
(($ $call proc args)
(let ((args (map subst args)))
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;; are finished with the scan, we kill uses of the
;; terminator, but leave its definitions.
(match (find-expression body)
- ((or ($ $void) ($ $const) ($ $prim) ($ $closure)
+ ((or ($ $const) ($ $prim) ($ $closure)
($ $primcall) ($ $prompt)
;; If $values has more than one argument, it may
;; use a temporary, which would invalidate our
;;; Continuation-passing style (CPS) intermediate language (IL)
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
($letk ((k* ($kargs ('val) (val)
($continue k src ($primcall 'values (val)))))
(kvoid ($kargs () ()
- ($continue k* src ($void)))))
+ ($continue k* src ($const *unspecified*)))))
($continue kvoid src exp)))))
(define-syntax-rule (adapt-val exp)
(let-fresh (k*) (val)
(match (lookup-cont k dfg)
(($ $kargs (_) (var))
(let ((entry (match exp
- (($ $void)
- (make-type-entry &unspecified -inf.0 +inf.0))
(($ $const val)
(constant-type val))
((or ($ $prim) ($ $fun) ($ $closure))
(define (visit-expression exp k-env v-env)
(match exp
- (($ $void)
- #t)
(($ $const val)
#t)
(($ $prim (? symbol? name))
(var ($continue k src ($values (var))))))
(($ <void> src)
- (build-cps-term ($continue k src ($void))))
+ (build-cps-term ($continue k src ($const *unspecified*))))
(($ <const> src exp)
(build-cps-term ($continue k src ($const exp))))