From: Taylor R Campbell Date: Tue, 15 Jan 2019 03:19:18 +0000 (+0000) Subject: Avoid REGISTER-COPY-IF-AVAILABLE and TEMPORARY-COPY-IF-AVAILABLE. X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~66^2~83 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=136919dcd09d3ef54d9890d41576b1999bc2bc54;p=mit-scheme.git Avoid REGISTER-COPY-IF-AVAILABLE and TEMPORARY-COPY-IF-AVAILABLE. These give out register references, which are a pain. Just use REUSE-PSEUDO-REGISTER-IF-AVAILABLE! to get the machine register number. --- diff --git a/src/compiler/machines/aarch64/rules1.scm b/src/compiler/machines/aarch64/rules1.scm index 55dcfe73c..a75955d84 100644 --- a/src/compiler/machines/aarch64/rules1.scm +++ b/src/compiler/machines/aarch64/rules1.scm @@ -43,25 +43,24 @@ USA. (ASSIGN (REGISTER (? target)) (CONS-POINTER (REGISTER (? type)) (REGISTER (? datum)))) - (cond ((let ((type (register-known-value type))) - (and type (zero? type))) - (assign-register->register target datum)) - ((register-copy-if-available datum 'GENERAL target) - => (lambda (get-target!) - ;; If we already have a suitable register for the target, - ;; use bit field insertion to set the type. - (let* ((type (standard-source! type)) - (target (get-target!)) - (lsb scheme-datum-width) - (width scheme-type-width)) - (LAP (BFI X ,target ,type (&U ,lsb) (&U ,width)))))) - (else - ;; Otherwise, no advantage to using bit field insertion since - ;; we'd need two instructions anyway, so just shift and or. - (standard-binary target type datum - (lambda (target type datum) - (LAP (LSL X ,target ,type (&U ,scheme-datum-width)) - (ORR X ,target ,target ,datum))))))) + (reuse-pseudo-register-alias! datum 'GENERAL + (lambda (alias) + ;; If we already have a reusable machine register loaded with the + ;; datum, use bit field insertion to set the type, and treat it + ;; as an alias for the target. + (let ((type (standard-source! type)) + (lsb scheme-datum-width) + (width scheme-type-width)) + (delete-dead-registers!) + (add-pseudo-register-alias! target alias) + (LAP (BFI X ,alias ,type (&U ,lsb) (&U ,width))))) + (lambda () + ;; No advantage to using bit field insertion since we'd need two + ;; instructions anyway, so just shift and or. + (standard-binary target type datum + (lambda (target type datum) + (LAP (LSL X ,target ,type (&U ,scheme-datum-width)) + (ORR X ,target ,target ,datum))))))) (define-rule statement (ASSIGN (REGISTER (? target)) diff --git a/src/compiler/machines/aarch64/rules2.scm b/src/compiler/machines/aarch64/rules2.scm index bef249b29..382030ebb 100644 --- a/src/compiler/machines/aarch64/rules2.scm +++ b/src/compiler/machines/aarch64/rules2.scm @@ -80,10 +80,20 @@ USA. (define-rule predicate (PRED-1-ARG INDEX-FIXNUM? (REGISTER (? register))) - (let ((temp (standard-move-to-temporary! register))) + (define (operate temp source) (set-equal-branches!) - (LAP (LSR X ,temp (&U ,(- scheme-datum-width 1))) - (CMP X ,temp (&U ,(* 2 type-code:fixnum)))))) + (LAP (LSR X ,temp ,source (&U ,(- scheme-datum-width 1))) + (CMP X ,temp (&U ,(* 2 type-code:fixnum))))) + ;; This basically is WITH-TEMPORARY-REGISTER-COPY! but without + ;; register references getting in the way. + (reuse-pseudo-register-alias! register 'GENERAL + (lambda (temp) + (need-register! temp) + (operate temp temp)) + (lambda () + (let* ((source (standard-source! register)) + (temp (allocate-temporary-register! 'GENERAL))) + (operate temp source))))) (define (zero-test! register) (set-equal-zero-branches! register)