wingo pushed a commit to branch master
in repository guile.
commit ef5f2fcaaa787187f1f4763b000f32cccf055fc3
Author: Andy Wingo wi...@pobox.com
Date: Tue May 12 21:53:42 2015 +0200
Add optimization pass over CPS2
* module/language/cps2/optimize.scm: New file.
* module/language/cps2/simplify.scm: New file, factored out of
simplify2.scm.
* module/language/cps/simplify2.scm: Remove, as it's obsolete.
* module/language/cps2/compile-cps.scm: Optimize the CPS.
* module/Makefile.am: Adapt for added and deleted files.
---
module/Makefile.am |3 +-
module/language/cps/simplify2.scm| 747 --
module/language/cps2/compile-cps.scm |4 +-
module/language/cps2/optimize.scm| 56 +++
module/language/cps2/simplify.scm| 237 +++
5 files changed, 298 insertions(+), 749 deletions(-)
diff --git a/module/Makefile.am b/module/Makefile.am
index 8c4480f..145b04f 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -141,7 +141,6 @@ CPS_LANG_SOURCES =
\
language/cps/self-references.scm \
language/cps/slot-allocation.scm \
language/cps/simplify.scm\
- language/cps/simplify2.scm \
language/cps/spec.scm\
language/cps/specialize-primcalls.scm\
language/cps/type-fold.scm \
@@ -151,6 +150,8 @@ CPS2_LANG_SOURCES =
\
language/cps2.scm\
language/cps2/compile-cps.scm\
language/cps2/renumber.scm \
+ language/cps2/optimize.scm \
+ language/cps2/simplify.scm \
language/cps2/spec.scm \
language/cps2/utils.scm
diff --git a/module/language/cps/simplify2.scm
b/module/language/cps/simplify2.scm
deleted file mode 100644
index d819a7a..000
--- a/module/language/cps/simplify2.scm
+++ /dev/null
@@ -1,747 +0,0 @@
-;;; Continuation-passing style (CPS) intermediate language (IL)
-
-;; 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
- License as published by the Free Software Foundation; either
- version 3 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
-
-;;; Commentary:
-;;;
-;;; The fundamental lambda calculus reductions, like beta and eta
-;;; reduction and so on. Pretty lame currently.
-;;;
-;;; Code:
-
-(define-module (language cps simplify2)
- #:use-module (ice-9 match)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-26)
- #:use-module (language cps)
- #:use-module (language cps intset)
- #:use-module (language cps intmap)
- #:export (simplify2))
-
-;; advantages of cps2: little recursion so evaluator doesn't consume too
-;; much stack at boot time, rewriting can share more state for conts
-;; that don't need rewrites, transformations can use dominators instead
-;; of scoping approximation, redomination isn't a thing that needs to
-;; happen, more functional techniques... easy detection of when no
-;; transformation is necessary, transform-conts...
-
-(define-syntax build-term
- (syntax-rules (unquote $rec $continue)
-((_ (unquote exp))
- exp)
-((_ ($continue k src exp))
- (build-cps-term ($continue k src exp)
-
-(define-syntax-rule (build-cont-body cont)
- (match (build-cps-cont (#f cont))
-(($ $cont k x) x)))
-
-(define-syntax build-cont
- (syntax-rules (unquote $kreceive $kargs $kfun $ktail $kclause)
-((_ (unquote exp))
- exp)
-((_ ($kreceive req rest kargs))
- (build-cont-body ($kreceive req rest kargs)))
-((_ ($kargs (name ...) (unquote syms) body))
- (build-cont-body ($kargs (name ...) (unquote syms)
-,(build-term body
-((_ ($kargs (name ...) (sym ...) body))
- (build-cont-body ($kargs (name ...) (sym ...) ,(build-term body
-((_ ($kargs names syms body))
- (build-cont-body ($kargs names syms ,(build-term body
-((_