(LAP ,@(load-unsigned-immediate temp imm)
,@(add temp))))))
\f
-(define (affix-type target type datum)
- ;; Note: This must NOT use regnum:scratch-0 or regnum:scratch-1!
- ;; This is used by closure headers to tag the incoming entry.
+(define (affix-type target type datum get-temporary)
(assert (<= scheme-type-width 16))
(assert (<= 48 scheme-datum-width))
(cond ((zero? type)
;;
;; XXX If we know the top few bits of the datum are zero, we
;; could use a single MOVK instruction.
- (let ((imm (shift-left type (- 16 scheme-type-width)))
+ (let ((temp (if (= target datum) (get-temporary) target))
+ (imm (shift-left type (- 16 scheme-type-width)))
(shift 48))
- (LAP (MOVZ X ,target (LSL (&U ,imm) ,shift))
- (ORR X ,target ,target ,datum))))))
+ (LAP (MOVZ X ,temp (LSL (&U ,imm) ,shift))
+ (ORR X ,target ,temp ,datum))))))
(define (object->type target source)
(let ((lsb scheme-datum-width)
(LAP ,@(make-external-label internal-entry-code-word external-label)
;; regnum:applicand holds the untagged entry address.
;; Push and tag it.
- ,@(affix-type regnum:applicand type regnum:applicand)
+ ,@(affix-type regnum:applicand type regnum:applicand
+ (lambda () regnum:scratch-0))
,@(push regnum:applicand)
(LABEL ,internal-label)))
(cond ((zero? nentries)
;; offsets without pre/post-increment.
,@(add-immediate Free Free (* 8 size))
;; Set the last component to be the relocation reference point.
- ,@(affix-type temp type-code:compiled-entry target)
+ ,@(affix-type temp type-code:compiled-entry target
+ (lambda () (allocate-temporary-register! 'GENERAL)))
(STR X ,temp (POST+ ,Free (& 8))))))
(define (generate/cons-multiclosure target nentries size entries)
;; offsets without pre/post-increment.
,@(add-immediate Free Free (* 8 size))
;; Set the last component to be the relocation reference point.
- ,@(affix-type temp type-code:compiled-entry target)
+ ,@(affix-type temp type-code:compiled-entry target
+ (lambda () (allocate-temporary-register! 'GENERAL)))
(STR X ,temp (POST+ ,Free (& 8))))))
\f
(define (generate-closure-entry label padding min max offset temp)