1 ;;;; various primitive memory access VOPs for the x86 VM
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 ;;;; data object ref/set stuff
17 (:args (object :scs (descriptor-reg)))
18 (:info name offset lowtag)
20 (:results (result :scs (descriptor-reg any-reg)))
22 (loadw result object offset lowtag)))
24 (define-vop (set-slot)
25 (:args (object :scs (descriptor-reg))
26 (value :scs (descriptor-reg any-reg immediate)))
27 (:info name offset lowtag)
31 (if (sc-is value immediate)
32 (let ((val (tn-value value)))
36 (make-ea :dword :base object
37 :disp (- (* offset n-word-bytes) lowtag))
41 (make-ea :dword :base object
42 :disp (- (* offset n-word-bytes) lowtag))
43 (+ nil-value (static-symbol-offset val))))
46 (make-ea :dword :base object
47 :disp (- (* offset n-word-bytes) lowtag))
48 (logior (ash (char-code val) n-widetag-bits)
49 character-widetag)))))
50 ;; Else, value not immediate.
51 (storew value object offset lowtag))))
55 ;;;; symbol hacking VOPs
57 ;;; these next two cf the sparc version, by jrd.
58 ;;; FIXME: Deref this ^ reference.
61 ;;; The compiler likes to be able to directly SET symbols.
64 (:args (symbol :scs (descriptor-reg))
65 (value :scs (descriptor-reg any-reg)))
66 (:temporary (:sc descriptor-reg) tls)
67 ;;(:policy :fast-safe)
69 (let ((global-val (gen-label))
71 (loadw tls symbol symbol-tls-index-slot other-pointer-lowtag)
73 (inst jmp :z global-val)
74 (inst fs-segment-prefix)
75 (inst cmp (make-ea :dword :scale 1 :index tls)
76 no-tls-value-marker-widetag)
77 (inst jmp :z global-val)
78 (inst fs-segment-prefix)
79 (inst mov (make-ea :dword :scale 1 :index tls) value)
81 (emit-label global-val)
82 (storew value symbol symbol-value-slot other-pointer-lowtag)
85 ;; unithreaded it's a lot simpler ...
87 (define-vop (set cell-set)
88 (:variant symbol-value-slot other-pointer-lowtag))
90 ;;; Do a cell ref with an error check for being unbound.
91 ;;; XXX stil used? I can't see where -dan
92 (define-vop (checked-cell-ref)
93 (:args (object :scs (descriptor-reg) :target obj-temp))
94 (:results (value :scs (descriptor-reg any-reg)))
97 (:save-p :compute-only)
98 (:temporary (:sc descriptor-reg :from (:argument 0)) obj-temp))
100 ;;; With Symbol-Value, we check that the value isn't the trap object. So
101 ;;; Symbol-Value of NIL is NIL.
103 (define-vop (symbol-value)
104 (:translate symbol-value)
106 (:args (object :scs (descriptor-reg) :to (:result 1)))
107 (:results (value :scs (descriptor-reg any-reg)))
109 (:save-p :compute-only)
111 (let* ((check-unbound-label (gen-label))
112 (err-lab (generate-error-code vop unbound-symbol-error object))
113 (ret-lab (gen-label)))
114 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
115 (inst fs-segment-prefix)
116 (inst mov value (make-ea :dword :index value :scale 1))
117 (inst cmp value no-tls-value-marker-widetag)
118 (inst jmp :ne check-unbound-label)
119 (loadw value object symbol-value-slot other-pointer-lowtag)
120 (emit-label check-unbound-label)
121 (inst cmp value unbound-marker-widetag)
122 (inst jmp :e err-lab)
123 (emit-label ret-lab))))
126 (define-vop (fast-symbol-value symbol-value)
127 ;; KLUDGE: not really fast, in fact, because we're going to have to
128 ;; do a full lookup of the thread-local area anyway. But half of
129 ;; the meaning of FAST-SYMBOL-VALUE is "do not signal an error if
130 ;; unbound", which is used in the implementation of COPY-SYMBOL. --
133 (:translate symbol-value)
135 (let ((ret-lab (gen-label)))
136 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
137 (inst fs-segment-prefix)
138 (inst mov value (make-ea :dword :index value :scale 1))
139 (inst cmp value no-tls-value-marker-widetag)
140 (inst jmp :ne ret-lab)
141 (loadw value object symbol-value-slot other-pointer-lowtag)
142 (emit-label ret-lab))))
145 (define-vop (symbol-value)
146 (:translate symbol-value)
148 (:args (object :scs (descriptor-reg) :to (:result 1)))
149 (:results (value :scs (descriptor-reg any-reg)))
151 (:save-p :compute-only)
153 (let ((err-lab (generate-error-code vop unbound-symbol-error object)))
154 (loadw value object symbol-value-slot other-pointer-lowtag)
155 (inst cmp value unbound-marker-widetag)
156 (inst jmp :e err-lab))))
159 (define-vop (fast-symbol-value cell-ref)
160 (:variant symbol-value-slot other-pointer-lowtag)
162 (:translate symbol-value))
164 (defknown locked-symbol-global-value-add (symbol fixnum) fixnum ())
166 (define-vop (locked-symbol-global-value-add)
167 (:args (object :scs (descriptor-reg) :to :result)
168 (value :scs (any-reg) :target result))
169 (:arg-types * tagged-num)
170 (:results (result :scs (any-reg) :from (:argument 1)))
172 (:translate locked-symbol-global-value-add)
173 (:result-types tagged-num)
178 (inst add (make-ea :dword :base object
179 :disp (- (* symbol-value-slot n-word-bytes)
180 other-pointer-lowtag))
187 (:args (object :scs (descriptor-reg)))
190 (:temporary (:sc descriptor-reg #+nil(:from (:argument 0))) value)
192 (let ((check-unbound-label (gen-label)))
193 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
194 (inst fs-segment-prefix)
195 (inst mov value (make-ea :dword :index value :scale 1))
196 (inst cmp value no-tls-value-marker-widetag)
197 (inst jmp :ne check-unbound-label)
198 (loadw value object symbol-value-slot other-pointer-lowtag)
199 (emit-label check-unbound-label)
200 (inst cmp value unbound-marker-widetag)
201 (inst jmp (if not-p :e :ne) target))))
207 (:args (object :scs (descriptor-reg)))
210 (:temporary (:sc descriptor-reg :from (:argument 0)) value)
212 (loadw value object symbol-value-slot other-pointer-lowtag)
213 (inst cmp value unbound-marker-widetag)
214 (inst jmp (if not-p :e :ne) target)))
217 (define-vop (symbol-hash)
219 (:translate symbol-hash)
220 (:args (symbol :scs (descriptor-reg)))
221 (:results (res :scs (any-reg)))
222 (:result-types positive-fixnum)
224 ;; The symbol-hash slot of NIL holds NIL because it is also the
225 ;; cdr slot, so we have to strip off the two low bits to make sure
226 ;; it is a fixnum. The lowtag selection magic that is required to
227 ;; ensure this is explained in the comment in objdef.lisp
228 (loadw res symbol symbol-hash-slot other-pointer-lowtag)
229 (inst and res (lognot #b11))))
231 ;;;; fdefinition (FDEFN) objects
233 (define-vop (fdefn-fun cell-ref) ; /pfw - alpha
234 (:variant fdefn-fun-slot other-pointer-lowtag))
236 (define-vop (safe-fdefn-fun)
237 (:args (object :scs (descriptor-reg) :to (:result 1)))
238 (:results (value :scs (descriptor-reg any-reg)))
240 (:save-p :compute-only)
242 (loadw value object fdefn-fun-slot other-pointer-lowtag)
243 (inst cmp value nil-value)
244 (let ((err-lab (generate-error-code vop undefined-fun-error object)))
245 (inst jmp :e err-lab))))
247 (define-vop (set-fdefn-fun)
249 (:translate (setf fdefn-fun))
250 (:args (function :scs (descriptor-reg) :target result)
251 (fdefn :scs (descriptor-reg)))
252 (:temporary (:sc unsigned-reg) raw)
253 (:temporary (:sc byte-reg) type)
254 (:results (result :scs (descriptor-reg)))
256 (load-type type function (- fun-pointer-lowtag))
258 (make-ea :byte :base function
259 :disp (- (* simple-fun-code-offset n-word-bytes)
260 fun-pointer-lowtag)))
261 (inst cmp type simple-fun-header-widetag)
262 (inst jmp :e normal-fn)
263 (inst lea raw (make-fixup "closure_tramp" :foreign))
265 (storew function fdefn fdefn-fun-slot other-pointer-lowtag)
266 (storew raw fdefn fdefn-raw-addr-slot other-pointer-lowtag)
267 (move result function)))
269 (define-vop (fdefn-makunbound)
271 (:translate fdefn-makunbound)
272 (:args (fdefn :scs (descriptor-reg) :target result))
273 (:results (result :scs (descriptor-reg)))
275 (storew nil-value fdefn fdefn-fun-slot other-pointer-lowtag)
276 (storew (make-fixup "undefined_tramp" :foreign)
277 fdefn fdefn-raw-addr-slot other-pointer-lowtag)
278 (move result fdefn)))
280 ;;;; binding and unbinding
282 ;;; BIND -- Establish VAL as a binding for SYMBOL. Save the old value and
283 ;;; the symbol on the binding stack and stuff the new value into the
288 (:args (val :scs (any-reg descriptor-reg))
289 (symbol :scs (descriptor-reg)))
290 (:temporary (:sc unsigned-reg) tls-index temp bsp)
292 (let ((tls-index-valid (gen-label)))
293 (load-tl-symbol-value bsp *binding-stack-pointer*)
294 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
295 (inst add bsp (* binding-size n-word-bytes))
296 (store-tl-symbol-value bsp *binding-stack-pointer* temp)
298 (inst or tls-index tls-index)
299 (inst jmp :ne tls-index-valid)
300 ;; allocate a new tls-index
301 (load-symbol-value tls-index *free-tls-index*)
302 (inst add tls-index 4) ;XXX surely we can do this more
303 (store-symbol-value tls-index *free-tls-index*) ;succintly
304 (inst sub tls-index 4)
305 (storew tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
306 (emit-label tls-index-valid)
307 (inst fs-segment-prefix)
308 (inst mov temp (make-ea :dword :scale 1 :index tls-index))
309 (storew temp bsp (- binding-value-slot binding-size))
310 (storew symbol bsp (- binding-symbol-slot binding-size))
311 (inst fs-segment-prefix)
312 (inst mov (make-ea :dword :scale 1 :index tls-index) val))))
316 (:args (val :scs (any-reg descriptor-reg))
317 (symbol :scs (descriptor-reg)))
318 (:temporary (:sc unsigned-reg) temp bsp)
320 (load-symbol-value bsp *binding-stack-pointer*)
321 (loadw temp symbol symbol-value-slot other-pointer-lowtag)
322 (inst add bsp (* binding-size n-word-bytes))
323 (store-symbol-value bsp *binding-stack-pointer*)
324 (storew temp bsp (- binding-value-slot binding-size))
325 (storew symbol bsp (- binding-symbol-slot binding-size))
326 (storew val symbol symbol-value-slot other-pointer-lowtag)))
332 (:temporary (:sc unsigned-reg) symbol value bsp tls-index)
334 (load-tl-symbol-value bsp *binding-stack-pointer*)
335 (loadw symbol bsp (- binding-symbol-slot binding-size))
336 (loadw value bsp (- binding-value-slot binding-size))
338 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
339 (inst fs-segment-prefix)
340 (inst mov (make-ea :dword :scale 1 :index tls-index) value)
342 (storew 0 bsp (- binding-symbol-slot binding-size))
343 (inst sub bsp (* binding-size n-word-bytes))
344 ;; we're done with value, so we can use it as a temp here
345 (store-tl-symbol-value bsp *binding-stack-pointer* value)))
349 (:temporary (:sc unsigned-reg) symbol value bsp)
351 (load-symbol-value bsp *binding-stack-pointer*)
352 (loadw symbol bsp (- binding-symbol-slot binding-size))
353 (loadw value bsp (- binding-value-slot binding-size))
354 (storew value symbol symbol-value-slot other-pointer-lowtag)
355 (storew 0 bsp (- binding-symbol-slot binding-size))
356 (inst sub bsp (* binding-size n-word-bytes))
357 (store-symbol-value bsp *binding-stack-pointer*)))
360 (define-vop (unbind-to-here)
361 (:args (where :scs (descriptor-reg any-reg)))
362 (:temporary (:sc unsigned-reg) symbol value bsp #!+sb-thread tls-index)
364 (load-tl-symbol-value bsp *binding-stack-pointer*)
369 (loadw symbol bsp (- binding-symbol-slot binding-size))
370 (inst or symbol symbol)
372 (loadw value bsp (- binding-value-slot binding-size))
373 #!-sb-thread (storew value symbol symbol-value-slot other-pointer-lowtag)
376 tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
377 #!+sb-thread (inst fs-segment-prefix)
378 #!+sb-thread (inst mov (make-ea :dword :scale 1 :index tls-index) value)
379 (storew 0 bsp (- binding-symbol-slot binding-size))
382 (inst sub bsp (* binding-size n-word-bytes))
385 ;; we're done with value, so can use it as a temporary
386 (store-tl-symbol-value bsp *binding-stack-pointer* value)
392 ;;;; closure indexing
394 (define-full-reffer closure-index-ref *
395 closure-info-offset fun-pointer-lowtag
396 (any-reg descriptor-reg) * %closure-index-ref)
398 (define-full-setter set-funcallable-instance-info *
399 funcallable-instance-info-offset fun-pointer-lowtag
400 (any-reg descriptor-reg) * %set-funcallable-instance-info)
402 (define-full-reffer funcallable-instance-info *
403 funcallable-instance-info-offset fun-pointer-lowtag
404 (descriptor-reg any-reg) * %funcallable-instance-info)
406 (define-vop (funcallable-instance-lexenv cell-ref)
407 (:variant funcallable-instance-lexenv-slot fun-pointer-lowtag))
409 (define-vop (closure-ref slot-ref)
410 (:variant closure-info-offset fun-pointer-lowtag))
412 (define-vop (closure-init slot-set)
413 (:variant closure-info-offset fun-pointer-lowtag))
415 ;;;; value cell hackery
417 (define-vop (value-cell-ref cell-ref)
418 (:variant value-cell-value-slot other-pointer-lowtag))
420 (define-vop (value-cell-set cell-set)
421 (:variant value-cell-value-slot other-pointer-lowtag))
423 ;;;; structure hackery
425 (define-vop (instance-length)
427 (:translate %instance-length)
428 (:args (struct :scs (descriptor-reg)))
429 (:results (res :scs (unsigned-reg)))
430 (:result-types positive-fixnum)
432 (loadw res struct 0 instance-pointer-lowtag)
433 (inst shr res n-widetag-bits)))
435 (define-vop (instance-ref slot-ref)
436 (:variant instance-slots-offset instance-pointer-lowtag)
438 (:translate %instance-ref)
439 (:arg-types instance (:constant index)))
441 (define-vop (instance-set slot-set)
443 (:translate %instance-set)
444 (:variant instance-slots-offset instance-pointer-lowtag)
445 (:arg-types instance (:constant index) *))
447 (define-full-reffer instance-index-ref * instance-slots-offset
448 instance-pointer-lowtag (any-reg descriptor-reg) * %instance-ref)
450 (define-full-setter instance-index-set * instance-slots-offset
451 instance-pointer-lowtag (any-reg descriptor-reg) * %instance-set)
454 (defknown %instance-set-conditional (instance index t t) t
457 (define-vop (instance-set-conditional)
458 (:translate %instance-set-conditional)
459 (:args (object :scs (descriptor-reg) :to :eval)
460 (slot :scs (any-reg) :to :result)
461 (old-value :scs (descriptor-reg any-reg) :target eax)
462 (new-value :scs (descriptor-reg any-reg)))
463 (:arg-types instance positive-fixnum * *)
464 (:temporary (:sc descriptor-reg :offset eax-offset
465 :from (:argument 2) :to :result :target result) eax)
466 (:results (result :scs (descriptor-reg any-reg)))
467 ;(:guard (backend-featurep :i486))
472 (inst cmpxchg (make-ea :dword :base object :index slot :scale 1
473 :disp (- (* instance-slots-offset n-word-bytes)
474 instance-pointer-lowtag))
480 ;;;; code object frobbing
482 (define-full-reffer code-header-ref * 0 other-pointer-lowtag
483 (any-reg descriptor-reg) * code-header-ref)
485 (define-full-setter code-header-set * 0 other-pointer-lowtag
486 (any-reg descriptor-reg) * code-header-set)
490 ;;;; raw instance slot accessors
492 (define-vop (raw-instance-ref/word)
493 (:translate %raw-instance-ref/word)
495 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
496 (:arg-types * tagged-num)
497 (:temporary (:sc unsigned-reg) tmp)
498 (:results (value :scs (unsigned-reg)))
499 (:result-types unsigned-num)
501 (loadw tmp object 0 instance-pointer-lowtag)
502 (inst shr tmp n-widetag-bits)
510 :disp (- (* (1- instance-slots-offset) n-word-bytes)
511 instance-pointer-lowtag)))))
513 (define-vop (raw-instance-set/word)
514 (:translate %raw-instance-set/word)
516 (:args (object :scs (descriptor-reg))
517 (index :scs (any-reg))
518 (value :scs (unsigned-reg) :target result))
519 (:arg-types * tagged-num unsigned-num)
520 (:temporary (:sc unsigned-reg) tmp)
521 (:results (result :scs (unsigned-reg)))
522 (:result-types unsigned-num)
524 (loadw tmp object 0 instance-pointer-lowtag)
525 (inst shr tmp n-widetag-bits)
532 :disp (- (* (1- instance-slots-offset) n-word-bytes)
533 instance-pointer-lowtag))
535 (move result value)))
537 (define-vop (raw-instance-ref/single)
538 (:translate %raw-instance-ref/single)
540 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
541 (:arg-types * tagged-num)
542 (:temporary (:sc unsigned-reg) tmp)
543 (:results (value :scs (single-reg)))
544 (:result-types single-float)
546 (loadw tmp object 0 instance-pointer-lowtag)
547 (inst shr tmp n-widetag-bits)
550 (with-empty-tn@fp-top(value)
555 :disp (- (* (1- instance-slots-offset) n-word-bytes)
556 instance-pointer-lowtag))))))
558 (define-vop (raw-instance-set/single)
559 (:translate %raw-instance-set/single)
561 (:args (object :scs (descriptor-reg))
562 (index :scs (any-reg))
563 (value :scs (single-reg) :target result))
564 (:arg-types * tagged-num single-float)
565 (:temporary (:sc unsigned-reg) tmp)
566 (:results (result :scs (single-reg)))
567 (:result-types single-float)
569 (loadw tmp object 0 instance-pointer-lowtag)
570 (inst shr tmp n-widetag-bits)
573 (unless (zerop (tn-offset value))
579 :disp (- (* (1- instance-slots-offset) n-word-bytes)
580 instance-pointer-lowtag)))
582 ((zerop (tn-offset value))
583 (unless (zerop (tn-offset result))
585 ((zerop (tn-offset result))
588 (unless (location= value result)
590 (inst fxch value)))))
592 (define-vop (raw-instance-ref/double)
593 (:translate %raw-instance-ref/double)
595 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
596 (:arg-types * tagged-num)
597 (:temporary (:sc unsigned-reg) tmp)
598 (:results (value :scs (double-reg)))
599 (:result-types double-float)
601 (loadw tmp object 0 instance-pointer-lowtag)
602 (inst shr tmp n-widetag-bits)
605 (with-empty-tn@fp-top(value)
610 :disp (- (* (- instance-slots-offset 2) n-word-bytes)
611 instance-pointer-lowtag))))))
613 (define-vop (raw-instance-set/double)
614 (:translate %raw-instance-set/double)
616 (:args (object :scs (descriptor-reg))
617 (index :scs (any-reg))
618 (value :scs (double-reg) :target result))
619 (:arg-types * tagged-num double-float)
620 (:temporary (:sc unsigned-reg) tmp)
621 (:results (result :scs (double-reg)))
622 (:result-types double-float)
624 (loadw tmp object 0 instance-pointer-lowtag)
625 (inst shr tmp n-widetag-bits)
628 (unless (zerop (tn-offset value))
634 :disp (- (* (- instance-slots-offset 2) n-word-bytes)
635 instance-pointer-lowtag)))
637 ((zerop (tn-offset value))
638 (unless (zerop (tn-offset result))
640 ((zerop (tn-offset result))
643 (unless (location= value result)
645 (inst fxch value)))))
647 (define-vop (raw-instance-ref/complex-single)
648 (:translate %raw-instance-ref/complex-single)
650 (:args (object :scs (descriptor-reg))
651 (index :scs (any-reg)))
652 (:arg-types * positive-fixnum)
653 (:temporary (:sc unsigned-reg) tmp)
654 (:results (value :scs (complex-single-reg)))
655 (:result-types complex-single-float)
657 (loadw tmp object 0 instance-pointer-lowtag)
658 (inst shr tmp n-widetag-bits)
661 (let ((real-tn (complex-single-reg-real-tn value)))
662 (with-empty-tn@fp-top (real-tn)
663 (inst fld (make-ea :dword
666 :disp (- (* (- instance-slots-offset 2)
668 instance-pointer-lowtag)))))
669 (let ((imag-tn (complex-single-reg-imag-tn value)))
670 (with-empty-tn@fp-top (imag-tn)
671 (inst fld (make-ea :dword
674 :disp (- (* (1- instance-slots-offset)
676 instance-pointer-lowtag)))))))
678 (define-vop (raw-instance-set/complex-single)
679 (:translate %raw-instance-set/complex-single)
681 (:args (object :scs (descriptor-reg))
682 (index :scs (any-reg))
683 (value :scs (complex-single-reg) :target result))
684 (:arg-types * positive-fixnum complex-single-float)
685 (:temporary (:sc unsigned-reg) tmp)
686 (:results (result :scs (complex-single-reg)))
687 (:result-types complex-single-float)
689 (loadw tmp object 0 instance-pointer-lowtag)
690 (inst shr tmp n-widetag-bits)
693 (let ((value-real (complex-single-reg-real-tn value))
694 (result-real (complex-single-reg-real-tn result)))
695 (cond ((zerop (tn-offset value-real))
697 (inst fst (make-ea :dword
700 :disp (- (* (- instance-slots-offset 2)
702 instance-pointer-lowtag)))
703 (unless (zerop (tn-offset result-real))
704 ;; Value is in ST0 but not result.
705 (inst fst result-real)))
707 ;; Value is not in ST0.
708 (inst fxch value-real)
709 (inst fst (make-ea :dword
712 :disp (- (* (- instance-slots-offset 2)
714 instance-pointer-lowtag)))
715 (cond ((zerop (tn-offset result-real))
716 ;; The result is in ST0.
717 (inst fst value-real))
719 ;; Neither value or result are in ST0
720 (unless (location= value-real result-real)
721 (inst fst result-real))
722 (inst fxch value-real))))))
723 (let ((value-imag (complex-single-reg-imag-tn value))
724 (result-imag (complex-single-reg-imag-tn result)))
725 (inst fxch value-imag)
726 (inst fst (make-ea :dword
729 :disp (- (* (1- instance-slots-offset)
731 instance-pointer-lowtag)))
732 (unless (location= value-imag result-imag)
733 (inst fst result-imag))
734 (inst fxch value-imag))))
736 (define-vop (raw-instance-ref/complex-double)
737 (:translate %raw-instance-ref/complex-double)
739 (:args (object :scs (descriptor-reg))
740 (index :scs (any-reg)))
741 (:arg-types * positive-fixnum)
742 (:temporary (:sc unsigned-reg) tmp)
743 (:results (value :scs (complex-double-reg)))
744 (:result-types complex-double-float)
746 (loadw tmp object 0 instance-pointer-lowtag)
747 (inst shr tmp n-widetag-bits)
750 (let ((real-tn (complex-double-reg-real-tn value)))
751 (with-empty-tn@fp-top (real-tn)
752 (inst fldd (make-ea :dword
755 :disp (- (* (- instance-slots-offset 4)
757 instance-pointer-lowtag)))))
758 (let ((imag-tn (complex-double-reg-imag-tn value)))
759 (with-empty-tn@fp-top (imag-tn)
760 (inst fldd (make-ea :dword
763 :disp (- (* (- instance-slots-offset 2)
765 instance-pointer-lowtag)))))))
767 (define-vop (raw-instance-set/complex-double)
768 (:translate %raw-instance-set/complex-double)
770 (:args (object :scs (descriptor-reg))
771 (index :scs (any-reg))
772 (value :scs (complex-double-reg) :target result))
773 (:arg-types * positive-fixnum complex-double-float)
774 (:temporary (:sc unsigned-reg) tmp)
775 (:results (result :scs (complex-double-reg)))
776 (:result-types complex-double-float)
778 (loadw tmp object 0 instance-pointer-lowtag)
779 (inst shr tmp n-widetag-bits)
782 (let ((value-real (complex-double-reg-real-tn value))
783 (result-real (complex-double-reg-real-tn result)))
784 (cond ((zerop (tn-offset value-real))
786 (inst fstd (make-ea :dword
789 :disp (- (* (- instance-slots-offset 4)
791 instance-pointer-lowtag)))
792 (unless (zerop (tn-offset result-real))
793 ;; Value is in ST0 but not result.
794 (inst fstd result-real)))
796 ;; Value is not in ST0.
797 (inst fxch value-real)
798 (inst fstd (make-ea :dword
801 :disp (- (* (- instance-slots-offset 4)
803 instance-pointer-lowtag)))
804 (cond ((zerop (tn-offset result-real))
805 ;; The result is in ST0.
806 (inst fstd value-real))
808 ;; Neither value or result are in ST0
809 (unless (location= value-real result-real)
810 (inst fstd result-real))
811 (inst fxch value-real))))))
812 (let ((value-imag (complex-double-reg-imag-tn value))
813 (result-imag (complex-double-reg-imag-tn result)))
814 (inst fxch value-imag)
815 (inst fstd (make-ea :dword
818 :disp (- (* (- instance-slots-offset 2)
820 instance-pointer-lowtag)))
821 (unless (location= value-imag result-imag)
822 (inst fstd result-imag))
823 (inst fxch value-imag))))