From: Guillermo J. Rozas Date: Fri, 28 Aug 1987 21:54:15 +0000 (+0000) Subject: Define with-temporary-register-copy! for 3 operand instructions. X-Git-Tag: 20090517-FFI~13101 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=38a723a307b722671d2beba0d034d57274517aa6;p=mit-scheme.git Define with-temporary-register-copy! for 3 operand instructions. --- diff --git a/v7/src/compiler/back/lapgn2.scm b/v7/src/compiler/back/lapgn2.scm index af6f50d3e..5a5ef7f9e 100644 --- a/v7/src/compiler/back/lapgn2.scm +++ b/v7/src/compiler/back/lapgn2.scm @@ -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)))))) +;; 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)))