Define with-temporary-register-copy! for 3 operand instructions.
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 28 Aug 1987 21:54:15 +0000 (21:54 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 28 Aug 1987 21:54:15 +0000 (21:54 +0000)
v7/src/compiler/back/lapgn2.scm

index af6f50d3eb9aeb5a3daf39c27f5217d38d19a449..5a5ef7f9ec043be8334cf07289c245d12b97845b 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/back/lapgn2.scm,v 1.4 1987/08/28 18:51:09 jinx Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/back/lapgn2.scm,v 1.5 1987/08/28 21:54:15 jinx Exp $
 
 Copyright (c) 1987 Massachusetts Institute of Technology
 
@@ -152,31 +152,47 @@ MIT in each case. |#
                   (else (register->register-transfer alias target))))
            (register-reference target))))))
 \f
+;; These procedures are used when the copy is going to be transformed,
+;; and the machine has 3 operand instructions, which allow an implicit
+;; motion in the transformation operation.
+;; For example, on the DEC VAX it is cheaper to do
+;;     bicl3   op1,source,target
+;; than
+;;     movl    source,target
+;;     bicl2   op1,target
+;; The extra arguments are
+;; REC1, invoked if we are resuing an alias of source.
+;;      It already contains the data to operate on.
+;; REC2, invoked if a `brand-new' alias for target has been allocated.
+;;      We must take care of moving the data ourselves.
+
 (define (with-register-copy-alias! source type target rec1 rec2)
-  ;; REC1 is invoked if we are resuing an alias of source.
-  ;;      It already contains the data to operate on.
-  ;; REC2 is invoked if a `brand-new' alias for target has been allocated.
-  ;;      We must take care of moving the data ourselves.
-  ;; This procedure should be used when the copy is going to be transformed,
-  ;; and the machine has 3 operand instructions, which allow an
-  ;; implicit motion in the transformation operation.
-  ;; For example, on the DEC VAX it is cheaper to do
-  ;;   bicl3   op1,source,target
-  ;; than
-  ;;   movl    source,target
-  ;;   bicl2   op1,target
+  (provide-copy-reusing-alias! source type rec1 rec2
+   (lambda (reusable-alias)
+     (add-pseudo-register-alias! target reusable-alias false))
+   (lambda ()
+     (allocate-alias-register! target type))))
+
+(define (with-temporary-register-copy! register type rec1 rec2)
+  (provide-copy-reusing-alias! register type rec1 rec2
+   need-register!
+   (lambda ()
+     (allocate-temporary-register! type))))
+
+(define (provide-copy-reusing-alias! source type rec1 rec2 if-reusable if-not)
+  ;; IF-NOT is assumed to return a machine register.
   (let ((reusable-alias
         (and (dead-register? source)
              (register-alias source type))))
     (if reusable-alias
        (begin (delete-dead-registers!)
-              (add-pseudo-register-alias! target reusable-alias false)
+              (if-reusable reusable-alias)
               (rec1 (register-reference reusable-alias)))
        (let ((alias (if (machine-register? source)
                         source
                         (register-alias source false))))
          (delete-dead-registers!)
-         (let ((target (allocate-alias-register! target type)))
+         (let ((target (if-not)))
            (cond ((not alias)
                   (rec2 (pseudo-register-home source)
                         (register-reference target)))