From a9ec16f9c5574d80f66c173b495285579f5894b4 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 11 Mar 2015 21:51:33 +0100 Subject: [PATCH] Remove $void CPS expression type * module/language/cps.scm: Remove the $void expression type, replaced by $const of the unspecified value. * module/language/cps/arities.scm: * module/language/cps/closure-conversion.scm: * module/language/cps/compile-bytecode.scm: * module/language/cps/cse.scm: * module/language/cps/dce.scm: * module/language/cps/dfg.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm: * module/language/cps/renumber.scm: * module/language/cps/self-references.scm: * module/language/cps/simplify.scm: * module/language/cps/slot-allocation.scm: * module/language/cps/specialize-primcalls.scm: * module/language/cps/types.scm: * module/language/cps/verify.scm: * module/language/tree-il/compile-cps.scm: Update callers. --- module/language/cps.scm | 12 +++--------- module/language/cps/arities.scm | 13 +++++++------ module/language/cps/closure-conversion.scm | 6 +++--- module/language/cps/compile-bytecode.scm | 2 -- module/language/cps/cse.scm | 5 ++--- module/language/cps/dce.scm | 4 ++-- module/language/cps/dfg.scm | 7 ++----- module/language/cps/effects-analysis.scm | 2 +- module/language/cps/reify-primitives.scm | 3 ++- module/language/cps/renumber.scm | 4 ++-- module/language/cps/self-references.scm | 4 ++-- module/language/cps/simplify.scm | 4 ++-- module/language/cps/slot-allocation.scm | 4 ++-- module/language/cps/specialize-primcalls.scm | 4 ++-- module/language/cps/types.scm | 2 -- module/language/cps/verify.scm | 2 -- module/language/tree-il/compile-cps.scm | 2 +- 17 files changed, 33 insertions(+), 47 deletions(-) diff --git a/module/language/cps.scm b/module/language/cps.scm index f570921d8..ee201979f 100644 --- a/module/language/cps.scm +++ b/module/language/cps.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -122,7 +122,7 @@ $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. @@ -188,7 +188,6 @@ (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. @@ -264,10 +263,9 @@ (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))) @@ -380,8 +378,6 @@ ;; 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) @@ -441,8 +437,6 @@ ;; Calls. (($ $continue k src exp) `(continue ,k ,(unparse-cps exp))) - (($ $void) - `(void)) (($ $const val) `(const ,val)) (($ $prim name) diff --git a/module/language/cps/arities.scm b/module/language/cps/arities.scm index e6c5f298a..479d56dcb 100644 --- a/module/language/cps/arities.scm +++ b/module/language/cps/arities.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -61,7 +61,8 @@ ($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 @@ -82,14 +83,15 @@ ($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) @@ -134,8 +136,7 @@ (define (visit-exp k src exp) (rewrite-cps-term exp - ((or ($ $void) - ($ $const) + ((or ($ $const) ($ $prim) ($ $values (_))) ,(adapt-exp 1 k src exp)) diff --git a/module/language/cps/closure-conversion.scm b/module/language/cps/closure-conversion.scm index 89e209052..90e6bdcd2 100644 --- a/module/language/cps/closure-conversion.scm +++ b/module/language/cps/closure-conversion.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -119,7 +119,7 @@ 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)) @@ -448,7 +448,7 @@ bound to @var{var}, and continue with @var{body}." 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))) diff --git a/module/language/cps/compile-bytecode.scm b/module/language/cps/compile-bytecode.scm index 9537e9ce8..7f6dae4ba 100644 --- a/module/language/cps/compile-bytecode.scm +++ b/module/language/cps/compile-bytecode.scm @@ -250,8 +250,6 @@ (($ $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) diff --git a/module/language/cps/cse.scm b/module/language/cps/cse.scm index 3a03ede83..593346ee9 100644 --- a/module/language/cps/cse.scm +++ b/module/language/cps/cse.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -294,7 +294,6 @@ could be that both true and false proofs are available." (define (compute-exp-key exp) (match exp - (($ $void) 'void) (($ $const val) (cons 'const val)) (($ $prim name) (cons 'prim name)) (($ $fun free body) #f) @@ -462,7 +461,7 @@ could be that both true and false proofs are available." (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) diff --git a/module/language/cps/dce.scm b/module/language/cps/dce.scm index b3dba097c..e6780c35a 100644 --- a/module/language/cps/dce.scm +++ b/module/language/cps/dce.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -205,7 +205,7 @@ (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)) diff --git a/module/language/cps/dfg.scm b/module/language/cps/dfg.scm index 5b674e189..e2cc4a218 100644 --- a/module/language/cps/dfg.scm +++ b/module/language/cps/dfg.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -671,7 +671,7 @@ body continuation in the prompt." (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)) @@ -766,7 +766,6 @@ body continuation in the prompt." (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)) @@ -842,8 +841,6 @@ body continuation in the prompt." (match (find-defining-expression sym dfg) (($ $const val) (values #t val)) - (($ $continue k src ($ $void)) - (values #t *unspecified*)) (else (values #f #f)))) diff --git a/module/language/cps/effects-analysis.scm b/module/language/cps/effects-analysis.scm index 8951b407a..3c0da24d7 100644 --- a/module/language/cps/effects-analysis.scm +++ b/module/language/cps/effects-analysis.scm @@ -441,7 +441,7 @@ is or might be a read or a write to the same location as A." (define (expression-effects exp dfg) (match exp - ((or ($ $void) ($ $const) ($ $prim) ($ $values)) + ((or ($ $const) ($ $prim) ($ $values)) &no-effects) (($ $fun) (&allocate &unknown-memory-kinds)) diff --git a/module/language/cps/reify-primitives.scm b/module/language/cps/reify-primitives.scm index db9f4bb54..286fd7c41 100644 --- a/module/language/cps/reify-primitives.scm +++ b/module/language/cps/reify-primitives.scm @@ -139,7 +139,8 @@ => (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 ())))) diff --git a/module/language/cps/renumber.scm b/module/language/cps/renumber.scm index 4f51b7081..4bbeb36ef 100644 --- a/module/language/cps/renumber.scm +++ b/module/language/cps/renumber.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -308,7 +308,7 @@ ($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))) diff --git a/module/language/cps/self-references.scm b/module/language/cps/self-references.scm index be4f2d9df..62d3f654a 100644 --- a/module/language/cps/self-references.scm +++ b/module/language/cps/self-references.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -56,7 +56,7 @@ (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) diff --git a/module/language/cps/simplify.scm b/module/language/cps/simplify.scm index 2c33edd82..d74767f92 100644 --- a/module/language/cps/simplify.scm +++ b/module/language/cps/simplify.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -238,7 +238,7 @@ (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))) diff --git a/module/language/cps/slot-allocation.scm b/module/language/cps/slot-allocation.scm index d9d53f53e..f9a86951d 100644 --- a/module/language/cps/slot-allocation.scm +++ b/module/language/cps/slot-allocation.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -452,7 +452,7 @@ are comparable with eqv?. A tmp slot may be used." ;; 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 diff --git a/module/language/cps/specialize-primcalls.scm b/module/language/cps/specialize-primcalls.scm index 0502fe6c3..cb5a70d89 100644 --- a/module/language/cps/specialize-primcalls.scm +++ b/module/language/cps/specialize-primcalls.scm @@ -1,6 +1,6 @@ ;;; 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 @@ -73,7 +73,7 @@ ($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) diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm index 934fa11ce..f9dee59a2 100644 --- a/module/language/cps/types.scm +++ b/module/language/cps/types.scm @@ -1276,8 +1276,6 @@ mapping symbols to types." (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)) diff --git a/module/language/cps/verify.scm b/module/language/cps/verify.scm index a52924b0b..e005594d3 100644 --- a/module/language/cps/verify.scm +++ b/module/language/cps/verify.scm @@ -135,8 +135,6 @@ (define (visit-expression exp k-env v-env) (match exp - (($ $void) - #t) (($ $const val) #t) (($ $prim (? symbol? name)) diff --git a/module/language/tree-il/compile-cps.scm b/module/language/tree-il/compile-cps.scm index a5afa7a7c..0cea636ea 100644 --- a/module/language/tree-il/compile-cps.scm +++ b/module/language/tree-il/compile-cps.scm @@ -253,7 +253,7 @@ (var ($continue k src ($values (var)))))) (($ src) - (build-cps-term ($continue k src ($void)))) + (build-cps-term ($continue k src ($const *unspecified*)))) (($ src exp) (build-cps-term ($continue k src ($const exp)))) -- 2.20.1