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) unbound-marker-widetag)
76 (inst jmp :z global-val)
77 (inst fs-segment-prefix)
78 (inst mov (make-ea :dword :scale 1 :index tls) value)
80 (emit-label global-val)
81 (storew value symbol symbol-value-slot other-pointer-lowtag)
84 ;; unithreaded it's a lot simpler ...
86 (define-vop (set cell-set)
87 (:variant symbol-value-slot other-pointer-lowtag))
89 ;;; Do a cell ref with an error check for being unbound.
90 ;;; XXX stil used? I can't see where -dan
91 (define-vop (checked-cell-ref)
92 (:args (object :scs (descriptor-reg) :target obj-temp))
93 (:results (value :scs (descriptor-reg any-reg)))
96 (:save-p :compute-only)
97 (:temporary (:sc descriptor-reg :from (:argument 0)) obj-temp))
99 ;;; With Symbol-Value, we check that the value isn't the trap object. So
100 ;;; Symbol-Value of NIL is NIL.
102 (define-vop (symbol-value)
103 (:translate symbol-value)
105 (:args (object :scs (descriptor-reg) :to (:result 1)))
106 (:results (value :scs (descriptor-reg any-reg)))
108 (:save-p :compute-only)
110 (let* ((err-lab (generate-error-code vop unbound-symbol-error object))
111 (ret-lab (gen-label)))
112 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
113 (inst fs-segment-prefix)
114 (inst mov value (make-ea :dword :index value :scale 1))
115 (inst cmp value unbound-marker-widetag)
116 (inst jmp :ne ret-lab)
117 (loadw value object symbol-value-slot other-pointer-lowtag)
118 (inst cmp value unbound-marker-widetag)
119 (inst jmp :e err-lab)
120 (emit-label ret-lab))))
123 (define-vop (fast-symbol-value symbol-value)
124 ;; KLUDGE: not really fast, in fact, because we're going to have to
125 ;; do a full lookup of the thread-local area anyway. But half of
126 ;; the meaning of FAST-SYMBOL-VALUE is "do not signal an error if
127 ;; unbound", which is used in the implementation of COPY-SYMBOL. --
130 (:translate symbol-value)
132 (let ((ret-lab (gen-label)))
133 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
134 (inst fs-segment-prefix)
135 (inst mov value (make-ea :dword :index value :scale 1))
136 (inst cmp value unbound-marker-widetag)
137 (inst jmp :ne ret-lab)
138 (loadw value object symbol-value-slot other-pointer-lowtag)
139 (emit-label ret-lab))))
142 (define-vop (symbol-value)
143 (:translate symbol-value)
145 (:args (object :scs (descriptor-reg) :to (:result 1)))
146 (:results (value :scs (descriptor-reg any-reg)))
148 (:save-p :compute-only)
150 (let ((err-lab (generate-error-code vop unbound-symbol-error object)))
151 (loadw value object symbol-value-slot other-pointer-lowtag)
152 (inst cmp value unbound-marker-widetag)
153 (inst jmp :e err-lab))))
156 (define-vop (fast-symbol-value cell-ref)
157 (:variant symbol-value-slot other-pointer-lowtag)
159 (:translate symbol-value))
161 (defknown locked-symbol-global-value-add (symbol fixnum) fixnum ())
163 (define-vop (locked-symbol-global-value-add)
164 (:args (object :scs (descriptor-reg) :to :result)
165 (value :scs (any-reg) :target result))
166 (:arg-types * tagged-num)
167 (:results (result :scs (any-reg) :from (:argument 1)))
169 (:translate locked-symbol-global-value-add)
170 (:result-types tagged-num)
175 (inst add (make-ea :dword :base object
176 :disp (- (* symbol-value-slot n-word-bytes)
177 other-pointer-lowtag))
184 (:args (object :scs (descriptor-reg)))
187 (:temporary (:sc descriptor-reg #+nil(:from (:argument 0))) value)
190 (let ((not-target (gen-label)))
191 (loadw value object symbol-value-slot other-pointer-lowtag)
192 (inst cmp value unbound-marker-widetag)
193 (inst jmp :ne not-target)
194 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
195 (inst fs-segment-prefix)
196 (inst cmp (make-ea :dword :index value :scale 1) unbound-marker-widetag)
198 (emit-label not-target))
200 (loadw value object symbol-value-slot other-pointer-lowtag)
201 (inst cmp value unbound-marker-widetag)
202 (inst jmp :ne target)
203 (loadw value object symbol-tls-index-slot other-pointer-lowtag)
204 (inst fs-segment-prefix)
205 (inst cmp (make-ea :dword :index value :scale 1) unbound-marker-widetag)
206 (inst jmp :ne target)))))
212 (:args (object :scs (descriptor-reg)))
215 (:temporary (:sc descriptor-reg :from (:argument 0)) value)
217 (loadw value object symbol-value-slot other-pointer-lowtag)
218 (inst cmp value unbound-marker-widetag)
219 (inst jmp (if not-p :e :ne) target)))
222 (define-vop (symbol-hash)
224 (:translate symbol-hash)
225 (:args (symbol :scs (descriptor-reg)))
226 (:results (res :scs (any-reg)))
227 (:result-types positive-fixnum)
229 ;; The symbol-hash slot of NIL holds NIL because it is also the
230 ;; cdr slot, so we have to strip off the two low bits to make sure
231 ;; it is a fixnum. The lowtag selection magic that is required to
232 ;; ensure this is explained in the comment in objdef.lisp
233 (loadw res symbol symbol-hash-slot other-pointer-lowtag)
234 (inst and res (lognot #b11))))
236 ;;;; fdefinition (FDEFN) objects
238 (define-vop (fdefn-fun cell-ref) ; /pfw - alpha
239 (:variant fdefn-fun-slot other-pointer-lowtag))
241 (define-vop (safe-fdefn-fun)
242 (:args (object :scs (descriptor-reg) :to (:result 1)))
243 (:results (value :scs (descriptor-reg any-reg)))
245 (:save-p :compute-only)
247 (loadw value object fdefn-fun-slot other-pointer-lowtag)
248 (inst cmp value nil-value)
249 (let ((err-lab (generate-error-code vop undefined-fun-error object)))
250 (inst jmp :e err-lab))))
252 (define-vop (set-fdefn-fun)
254 (:translate (setf fdefn-fun))
255 (:args (function :scs (descriptor-reg) :target result)
256 (fdefn :scs (descriptor-reg)))
257 (:temporary (:sc unsigned-reg) raw)
258 (:temporary (:sc byte-reg) type)
259 (:results (result :scs (descriptor-reg)))
261 (load-type type function (- fun-pointer-lowtag))
263 (make-ea :byte :base function
264 :disp (- (* simple-fun-code-offset n-word-bytes)
265 fun-pointer-lowtag)))
266 (inst cmp type simple-fun-header-widetag)
267 (inst jmp :e normal-fn)
268 (inst lea raw (make-fixup "closure_tramp" :foreign))
270 (storew function fdefn fdefn-fun-slot other-pointer-lowtag)
271 (storew raw fdefn fdefn-raw-addr-slot other-pointer-lowtag)
272 (move result function)))
274 (define-vop (fdefn-makunbound)
276 (:translate fdefn-makunbound)
277 (:args (fdefn :scs (descriptor-reg) :target result))
278 (:results (result :scs (descriptor-reg)))
280 (storew nil-value fdefn fdefn-fun-slot other-pointer-lowtag)
281 (storew (make-fixup "undefined_tramp" :foreign)
282 fdefn fdefn-raw-addr-slot other-pointer-lowtag)
283 (move result fdefn)))
285 ;;;; binding and unbinding
287 ;;; BIND -- Establish VAL as a binding for SYMBOL. Save the old value and
288 ;;; the symbol on the binding stack and stuff the new value into the
293 (:args (val :scs (any-reg descriptor-reg))
294 (symbol :scs (descriptor-reg)))
295 (:temporary (:sc unsigned-reg) tls-index temp bsp)
297 (let ((tls-index-valid (gen-label)))
298 (load-tl-symbol-value bsp *binding-stack-pointer*)
299 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
300 (inst add bsp (* binding-size n-word-bytes))
301 (store-tl-symbol-value bsp *binding-stack-pointer* temp)
303 (inst or tls-index tls-index)
304 (inst jmp :ne tls-index-valid)
305 ;; allocate a new tls-index
306 (load-symbol-value tls-index *free-tls-index*)
307 (inst add tls-index 4) ;XXX surely we can do this more
308 (store-symbol-value tls-index *free-tls-index*) ;succintly
309 (inst sub tls-index 4)
310 (storew tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
311 (emit-label tls-index-valid)
312 (inst fs-segment-prefix)
313 (inst mov temp (make-ea :dword :scale 1 :index tls-index))
314 (storew temp bsp (- binding-value-slot binding-size))
315 (storew symbol bsp (- binding-symbol-slot binding-size))
316 (inst fs-segment-prefix)
317 (inst mov (make-ea :dword :scale 1 :index tls-index) val))))
321 (:args (val :scs (any-reg descriptor-reg))
322 (symbol :scs (descriptor-reg)))
323 (:temporary (:sc unsigned-reg) temp bsp)
325 (load-symbol-value bsp *binding-stack-pointer*)
326 (loadw temp symbol symbol-value-slot other-pointer-lowtag)
327 (inst add bsp (* binding-size n-word-bytes))
328 (store-symbol-value bsp *binding-stack-pointer*)
329 (storew temp bsp (- binding-value-slot binding-size))
330 (storew symbol bsp (- binding-symbol-slot binding-size))
331 (storew val symbol symbol-value-slot other-pointer-lowtag)))
337 (:temporary (:sc unsigned-reg) symbol value bsp tls-index)
339 (load-tl-symbol-value bsp *binding-stack-pointer*)
340 (loadw symbol bsp (- binding-symbol-slot binding-size))
341 (loadw value bsp (- binding-value-slot binding-size))
343 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
344 (inst fs-segment-prefix)
345 (inst mov (make-ea :dword :scale 1 :index tls-index) value)
347 (storew 0 bsp (- binding-symbol-slot binding-size))
348 (inst sub bsp (* binding-size n-word-bytes))
349 ;; we're done with value, so we can use it as a temp here
350 (store-tl-symbol-value bsp *binding-stack-pointer* value)))
354 (:temporary (:sc unsigned-reg) symbol value bsp)
356 (load-symbol-value bsp *binding-stack-pointer*)
357 (loadw symbol bsp (- binding-symbol-slot binding-size))
358 (loadw value bsp (- binding-value-slot binding-size))
359 (storew value symbol symbol-value-slot other-pointer-lowtag)
360 (storew 0 bsp (- binding-symbol-slot binding-size))
361 (inst sub bsp (* binding-size n-word-bytes))
362 (store-symbol-value bsp *binding-stack-pointer*)))
365 (define-vop (unbind-to-here)
366 (:args (where :scs (descriptor-reg any-reg)))
367 (:temporary (:sc unsigned-reg) symbol value bsp #!+sb-thread tls-index)
369 (load-tl-symbol-value bsp *binding-stack-pointer*)
374 (loadw symbol bsp (- binding-symbol-slot binding-size))
375 (inst or symbol symbol)
377 (loadw value bsp (- binding-value-slot binding-size))
378 #!-sb-thread (storew value symbol symbol-value-slot other-pointer-lowtag)
381 tls-index symbol symbol-tls-index-slot other-pointer-lowtag)
382 #!+sb-thread (inst fs-segment-prefix)
383 #!+sb-thread (inst mov (make-ea :dword :scale 1 :index tls-index) value)
384 (storew 0 bsp (- binding-symbol-slot binding-size))
387 (inst sub bsp (* binding-size n-word-bytes))
390 ;; we're done with value, so can use it as a temporary
391 (store-tl-symbol-value bsp *binding-stack-pointer* value)
397 ;;;; closure indexing
399 (define-full-reffer closure-index-ref *
400 closure-info-offset fun-pointer-lowtag
401 (any-reg descriptor-reg) * %closure-index-ref)
403 (define-full-setter set-funcallable-instance-info *
404 funcallable-instance-info-offset fun-pointer-lowtag
405 (any-reg descriptor-reg) * %set-funcallable-instance-info)
407 (define-full-reffer funcallable-instance-info *
408 funcallable-instance-info-offset fun-pointer-lowtag
409 (descriptor-reg any-reg) * %funcallable-instance-info)
411 (define-vop (funcallable-instance-lexenv cell-ref)
412 (:variant funcallable-instance-lexenv-slot fun-pointer-lowtag))
414 (define-vop (closure-ref slot-ref)
415 (:variant closure-info-offset fun-pointer-lowtag))
417 (define-vop (closure-init slot-set)
418 (:variant closure-info-offset fun-pointer-lowtag))
420 ;;;; value cell hackery
422 (define-vop (value-cell-ref cell-ref)
423 (:variant value-cell-value-slot other-pointer-lowtag))
425 (define-vop (value-cell-set cell-set)
426 (:variant value-cell-value-slot other-pointer-lowtag))
428 ;;;; structure hackery
430 (define-vop (instance-length)
432 (:translate %instance-length)
433 (:args (struct :scs (descriptor-reg)))
434 (:results (res :scs (unsigned-reg)))
435 (:result-types positive-fixnum)
437 (loadw res struct 0 instance-pointer-lowtag)
438 (inst shr res n-widetag-bits)))
440 (define-vop (instance-ref slot-ref)
441 (:variant instance-slots-offset instance-pointer-lowtag)
443 (:translate %instance-ref)
444 (:arg-types instance (:constant index)))
446 (define-vop (instance-set slot-set)
448 (:translate %instance-set)
449 (:variant instance-slots-offset instance-pointer-lowtag)
450 (:arg-types instance (:constant index) *))
452 (define-full-reffer instance-index-ref * instance-slots-offset
453 instance-pointer-lowtag (any-reg descriptor-reg) * %instance-ref)
455 (define-full-setter instance-index-set * instance-slots-offset
456 instance-pointer-lowtag (any-reg descriptor-reg) * %instance-set)
459 (defknown %instance-set-conditional (instance index t t) t
462 (define-vop (instance-set-conditional)
463 (:translate %instance-set-conditional)
464 (:args (object :scs (descriptor-reg) :to :eval)
465 (slot :scs (any-reg) :to :result)
466 (old-value :scs (descriptor-reg any-reg) :target eax)
467 (new-value :scs (descriptor-reg any-reg)))
468 (:arg-types instance positive-fixnum * *)
469 (:temporary (:sc descriptor-reg :offset eax-offset
470 :from (:argument 2) :to :result :target result) eax)
471 (:results (result :scs (descriptor-reg any-reg)))
472 ;(:guard (backend-featurep :i486))
477 (inst cmpxchg (make-ea :dword :base object :index slot :scale 1
478 :disp (- (* instance-slots-offset n-word-bytes)
479 instance-pointer-lowtag))
485 ;;;; code object frobbing
487 (define-full-reffer code-header-ref * 0 other-pointer-lowtag
488 (any-reg descriptor-reg) * code-header-ref)
490 (define-full-setter code-header-set * 0 other-pointer-lowtag
491 (any-reg descriptor-reg) * code-header-set)
495 ;;;; raw instance slot accessors
497 (define-vop (raw-instance-ref/word)
498 (:translate %raw-instance-ref/word)
500 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
501 (:arg-types * tagged-num)
502 (:temporary (:sc unsigned-reg) tmp)
503 (:results (value :scs (unsigned-reg)))
504 (:result-types unsigned-num)
506 (loadw tmp object 0 instance-pointer-lowtag)
507 (inst shr tmp n-widetag-bits)
515 :disp (- (* (1- instance-slots-offset) n-word-bytes)
516 instance-pointer-lowtag)))))
518 (define-vop (raw-instance-set/word)
519 (:translate %raw-instance-set/word)
521 (:args (object :scs (descriptor-reg))
522 (index :scs (any-reg))
523 (value :scs (unsigned-reg) :target result))
524 (:arg-types * tagged-num unsigned-num)
525 (:temporary (:sc unsigned-reg) tmp)
526 (:results (result :scs (unsigned-reg)))
527 (:result-types unsigned-num)
529 (loadw tmp object 0 instance-pointer-lowtag)
530 (inst shr tmp n-widetag-bits)
537 :disp (- (* (1- instance-slots-offset) n-word-bytes)
538 instance-pointer-lowtag))
540 (move result value)))
542 (define-vop (raw-instance-ref/single)
543 (:translate %raw-instance-ref/single)
545 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
546 (:arg-types * tagged-num)
547 (:temporary (:sc unsigned-reg) tmp)
548 (:results (value :scs (single-reg)))
549 (:result-types single-float)
551 (loadw tmp object 0 instance-pointer-lowtag)
552 (inst shr tmp n-widetag-bits)
555 (with-empty-tn@fp-top(value)
560 :disp (- (* (1- instance-slots-offset) n-word-bytes)
561 instance-pointer-lowtag))))))
563 (define-vop (raw-instance-set/single)
564 (:translate %raw-instance-set/single)
566 (:args (object :scs (descriptor-reg))
567 (index :scs (any-reg))
568 (value :scs (single-reg) :target result))
569 (:arg-types * tagged-num single-float)
570 (:temporary (:sc unsigned-reg) tmp)
571 (:results (result :scs (single-reg)))
572 (:result-types single-float)
574 (loadw tmp object 0 instance-pointer-lowtag)
575 (inst shr tmp n-widetag-bits)
578 (unless (zerop (tn-offset value))
584 :disp (- (* (1- instance-slots-offset) n-word-bytes)
585 instance-pointer-lowtag)))
587 ((zerop (tn-offset value))
588 (unless (zerop (tn-offset result))
590 ((zerop (tn-offset result))
593 (unless (location= value result)
595 (inst fxch value)))))
597 (define-vop (raw-instance-ref/double)
598 (:translate %raw-instance-ref/double)
600 (:args (object :scs (descriptor-reg)) (index :scs (any-reg)))
601 (:arg-types * tagged-num)
602 (:temporary (:sc unsigned-reg) tmp)
603 (:results (value :scs (double-reg)))
604 (:result-types double-float)
606 (loadw tmp object 0 instance-pointer-lowtag)
607 (inst shr tmp n-widetag-bits)
610 (with-empty-tn@fp-top(value)
615 :disp (- (* (- instance-slots-offset 2) n-word-bytes)
616 instance-pointer-lowtag))))))
618 (define-vop (raw-instance-set/double)
619 (:translate %raw-instance-set/double)
621 (:args (object :scs (descriptor-reg))
622 (index :scs (any-reg))
623 (value :scs (double-reg) :target result))
624 (:arg-types * tagged-num double-float)
625 (:temporary (:sc unsigned-reg) tmp)
626 (:results (result :scs (double-reg)))
627 (:result-types double-float)
629 (loadw tmp object 0 instance-pointer-lowtag)
630 (inst shr tmp n-widetag-bits)
633 (unless (zerop (tn-offset value))
639 :disp (- (* (- instance-slots-offset 2) n-word-bytes)
640 instance-pointer-lowtag)))
642 ((zerop (tn-offset value))
643 (unless (zerop (tn-offset result))
645 ((zerop (tn-offset result))
648 (unless (location= value result)
650 (inst fxch value)))))
652 (define-vop (raw-instance-ref/complex-single)
653 (:translate %raw-instance-ref/complex-single)
655 (:args (object :scs (descriptor-reg))
656 (index :scs (any-reg)))
657 (:arg-types * positive-fixnum)
658 (:temporary (:sc unsigned-reg) tmp)
659 (:results (value :scs (complex-single-reg)))
660 (:result-types complex-single-float)
662 (loadw tmp object 0 instance-pointer-lowtag)
663 (inst shr tmp n-widetag-bits)
666 (let ((real-tn (complex-single-reg-real-tn value)))
667 (with-empty-tn@fp-top (real-tn)
668 (inst fld (make-ea :dword
671 :disp (- (* (- instance-slots-offset 2)
673 instance-pointer-lowtag)))))
674 (let ((imag-tn (complex-single-reg-imag-tn value)))
675 (with-empty-tn@fp-top (imag-tn)
676 (inst fld (make-ea :dword
679 :disp (- (* (1- instance-slots-offset)
681 instance-pointer-lowtag)))))))
683 (define-vop (raw-instance-set/complex-single)
684 (:translate %raw-instance-set/complex-single)
686 (:args (object :scs (descriptor-reg))
687 (index :scs (any-reg))
688 (value :scs (complex-single-reg) :target result))
689 (:arg-types * positive-fixnum complex-single-float)
690 (:temporary (:sc unsigned-reg) tmp)
691 (:results (result :scs (complex-single-reg)))
692 (:result-types complex-single-float)
694 (loadw tmp object 0 instance-pointer-lowtag)
695 (inst shr tmp n-widetag-bits)
698 (let ((value-real (complex-single-reg-real-tn value))
699 (result-real (complex-single-reg-real-tn result)))
700 (cond ((zerop (tn-offset value-real))
702 (inst fst (make-ea :dword
705 :disp (- (* (- instance-slots-offset 2)
707 instance-pointer-lowtag)))
708 (unless (zerop (tn-offset result-real))
709 ;; Value is in ST0 but not result.
710 (inst fst result-real)))
712 ;; Value is not in ST0.
713 (inst fxch value-real)
714 (inst fst (make-ea :dword
717 :disp (- (* (- instance-slots-offset 2)
719 instance-pointer-lowtag)))
720 (cond ((zerop (tn-offset result-real))
721 ;; The result is in ST0.
722 (inst fst value-real))
724 ;; Neither value or result are in ST0
725 (unless (location= value-real result-real)
726 (inst fst result-real))
727 (inst fxch value-real))))))
728 (let ((value-imag (complex-single-reg-imag-tn value))
729 (result-imag (complex-single-reg-imag-tn result)))
730 (inst fxch value-imag)
731 (inst fst (make-ea :dword
734 :disp (- (* (1- instance-slots-offset)
736 instance-pointer-lowtag)))
737 (unless (location= value-imag result-imag)
738 (inst fst result-imag))
739 (inst fxch value-imag))))
741 (define-vop (raw-instance-ref/complex-double)
742 (:translate %raw-instance-ref/complex-double)
744 (:args (object :scs (descriptor-reg))
745 (index :scs (any-reg)))
746 (:arg-types * positive-fixnum)
747 (:temporary (:sc unsigned-reg) tmp)
748 (:results (value :scs (complex-double-reg)))
749 (:result-types complex-double-float)
751 (loadw tmp object 0 instance-pointer-lowtag)
752 (inst shr tmp n-widetag-bits)
755 (let ((real-tn (complex-double-reg-real-tn value)))
756 (with-empty-tn@fp-top (real-tn)
757 (inst fldd (make-ea :dword
760 :disp (- (* (- instance-slots-offset 4)
762 instance-pointer-lowtag)))))
763 (let ((imag-tn (complex-double-reg-imag-tn value)))
764 (with-empty-tn@fp-top (imag-tn)
765 (inst fldd (make-ea :dword
768 :disp (- (* (- instance-slots-offset 2)
770 instance-pointer-lowtag)))))))
772 (define-vop (raw-instance-set/complex-double)
773 (:translate %raw-instance-set/complex-double)
775 (:args (object :scs (descriptor-reg))
776 (index :scs (any-reg))
777 (value :scs (complex-double-reg) :target result))
778 (:arg-types * positive-fixnum complex-double-float)
779 (:temporary (:sc unsigned-reg) tmp)
780 (:results (result :scs (complex-double-reg)))
781 (:result-types complex-double-float)
783 (loadw tmp object 0 instance-pointer-lowtag)
784 (inst shr tmp n-widetag-bits)
787 (let ((value-real (complex-double-reg-real-tn value))
788 (result-real (complex-double-reg-real-tn result)))
789 (cond ((zerop (tn-offset value-real))
791 (inst fstd (make-ea :dword
794 :disp (- (* (- instance-slots-offset 4)
796 instance-pointer-lowtag)))
797 (unless (zerop (tn-offset result-real))
798 ;; Value is in ST0 but not result.
799 (inst fstd result-real)))
801 ;; Value is not in ST0.
802 (inst fxch value-real)
803 (inst fstd (make-ea :dword
806 :disp (- (* (- instance-slots-offset 4)
808 instance-pointer-lowtag)))
809 (cond ((zerop (tn-offset result-real))
810 ;; The result is in ST0.
811 (inst fstd value-real))
813 ;; Neither value or result are in ST0
814 (unless (location= value-real result-real)
815 (inst fstd result-real))
816 (inst fxch value-real))))))
817 (let ((value-imag (complex-double-reg-imag-tn value))
818 (result-imag (complex-double-reg-imag-tn result)))
819 (inst fxch value-imag)
820 (inst fstd (make-ea :dword
823 :disp (- (* (- instance-slots-offset 2)
825 instance-pointer-lowtag)))
826 (unless (location= value-imag result-imag)
827 (inst fstd result-imag))
828 (inst fxch value-imag))))