1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 05:50:26 +02:00

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.
This commit is contained in:
Andy Wingo 2015-03-11 21:51:33 +01:00
parent 1f3babaaef
commit a9ec16f9c5
17 changed files with 33 additions and 47 deletions

View file

@ -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)

View file

@ -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))

View file

@ -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)))

View file

@ -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)

View file

@ -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)

View file

@ -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))

View file

@ -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))))

View file

@ -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))

View file

@ -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 ()))))

View file

@ -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)))

View file

@ -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)

View file

@ -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)))

View file

@ -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

View file

@ -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)

View file

@ -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))

View file

@ -135,8 +135,6 @@
(define (visit-expression exp k-env v-env)
(match exp
(($ $void)
#t)
(($ $const val)
#t)
(($ $prim (? symbol? name))

View file

@ -253,7 +253,7 @@
(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))))