Tweaked with if to make it do the old general cps style for BEGIN
authorStephen Adams <edu/mit/csail/zurich/adams>
Mon, 27 Feb 1995 22:38:15 +0000 (22:38 +0000)
committerStephen Adams <edu/mit/csail/zurich/adams>
Mon, 27 Feb 1995 22:38:15 +0000 (22:38 +0000)
actions because rtlgen doesnt like (begin (if x x y) ...).  rtlgen
should be fixed too.

v8/src/compiler/midend/cpsconv.scm

index 88989235dbe6932f308a1343e05657f13eda3e70..5e3519451a14266b63481879e6e7192a6b7ad729 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: cpsconv.scm,v 1.6 1995/02/27 17:33:45 adams Exp $
+$Id: cpsconv.scm,v 1.7 1995/02/27 22:38:15 adams Exp $
 
 Copyright (c) 1994 Massachusetts Institute of Technology
 
@@ -295,26 +295,35 @@ MIT in each case. |#
                   next)))))))
 
 (define-cps-converter IF (cont pred conseq alt)
-  (if (form/simple? pred)
-      (if (and (not (eq? (cpsconv/cont/kind cont) 'NAMED))
-              (form/pseudo-simple? conseq)
-              (form/pseudo-simple? alt))
-         (cpsconv/return form cont (cpsconv/simple/copy form))
-         `(IF ,(cpsconv/simple/copy pred)
-              ,(cpsconv/expr cont conseq)
-              ,(cpsconv/expr cont alt)))
-      ;; This does anchor pointing by default?
-      (let ((consname (cpsconv/new-name 'CONS))
-           (altname  (cpsconv/new-name 'ALT))
-           (ignore1   (cpsconv/new-ignored-continuation))
-           (ignore2   (cpsconv/new-ignored-continuation)))
-       `(LET ((,consname (LAMBDA (,ignore1) ,(cpsconv/expr cont conseq)))
-              (,altname  (LAMBDA (,ignore2) ,(cpsconv/expr cont alt))))
-          ,(cpsconv/expr
-            (cpsconv/predicate-continuation
-             consname altname
-             (cpsconv/dbg-continuation/make 'PREDICATE form pred))
-            pred)))))
+  (define (general)
+    ;; This does anchor pointing by default?
+    (let ((cons-name  (cpsconv/new-name 'CONS))
+         (alt-name   (cpsconv/new-name 'ALT))
+         (ignore1    (cpsconv/new-ignored-continuation))
+         (ignore2    (cpsconv/new-ignored-continuation)))
+      `(LET ((,cons-name  (LAMBDA (,ignore1) ,(cpsconv/expr cont conseq)))
+            (,alt-name   (LAMBDA (,ignore2) ,(cpsconv/expr cont alt))))
+        ,(cpsconv/expr
+          (cpsconv/predicate-continuation
+           cons-name alt-name
+           (cpsconv/dbg-continuation/make 'PREDICATE form pred))
+          pred))))
+  (define (really-simple)
+    (cpsconv/return form cont (cpsconv/simple/copy form)))
+  (define (simple-predicate)
+    `(IF ,(cpsconv/simple/copy pred)
+        ,(cpsconv/expr cont conseq)
+        ,(cpsconv/expr cont alt)))
+  (cond ((eq? (cpsconv/cont/kind cont) 'BEGIN)
+        (general))
+       ((not (form/simple? pred))
+        (general))
+       ((and (not (eq? (cpsconv/cont/kind cont) 'NAMED))
+             (form/pseudo-simple? conseq)
+             (form/pseudo-simple? alt))
+        (really-simple))
+       (else
+        (simple-predicate))))
 \f
 (define (cpsconv/expr cont expr)
   (if (not (pair? expr))