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 (:temporary
(:sc descriptor-reg
) temp
)
28 (:info name offset lowtag
)
32 (if (sc-is value immediate
)
33 (let ((val (tn-value value
)))
34 (move-immediate (make-ea :qword
36 :disp
(- (* offset n-word-bytes
)
42 (+ nil-value
(static-symbol-offset val
)))
44 (logior (ash (char-code val
) n-widetag-bits
)
47 ;; Else, value not immediate.
48 (storew value object offset lowtag
))))
50 (define-vop (compare-and-swap-slot)
51 (:args
(object :scs
(descriptor-reg) :to
:eval
)
52 (old :scs
(descriptor-reg any-reg
) :target rax
)
53 (new :scs
(descriptor-reg any-reg
)))
54 (:temporary
(:sc descriptor-reg
:offset rax-offset
55 :from
(:argument
1) :to
:result
:target result
)
57 (:info name offset lowtag
)
59 (:results
(result :scs
(descriptor-reg any-reg
)))
62 (inst cmpxchg
(make-ea :qword
:base object
63 :disp
(- (* offset n-word-bytes
) lowtag
))
67 ;;;; symbol hacking VOPs
69 (define-vop (%compare-and-swap-symbol-value
)
70 (:translate %compare-and-swap-symbol-value
)
71 (:args
(symbol :scs
(descriptor-reg) :to
(:result
1))
72 (old :scs
(descriptor-reg any-reg
) :target rax
)
73 (new :scs
(descriptor-reg any-reg
)))
74 (:temporary
(:sc descriptor-reg
:offset rax-offset
) rax
)
76 (:temporary
(:sc descriptor-reg
) tls
)
77 (:results
(result :scs
(descriptor-reg any-reg
)))
81 ;; This code has two pathological cases: NO-TLS-VALUE-MARKER
82 ;; or UNBOUND-MARKER as NEW: in either case we would end up
83 ;; doing possible damage with CMPXCHG -- so don't do that!
84 (let ((unbound (generate-error-code vop
'unbound-symbol-error symbol
))
89 (loadw tls symbol symbol-tls-index-slot other-pointer-lowtag
)
90 ;; Thread-local area, no LOCK needed.
91 (inst cmpxchg
(make-ea :qword
:base thread-base-tn
94 (inst cmp rax no-tls-value-marker-widetag
)
97 (inst cmpxchg
(make-ea :qword
:base symbol
98 :disp
(- (* symbol-value-slot n-word-bytes
)
104 (inst cmp result unbound-marker-widetag
)
105 (inst jmp
:e unbound
))))
107 ;;; these next two cf the sparc version, by jrd.
108 ;;; FIXME: Deref this ^ reference.
111 ;;; The compiler likes to be able to directly SET symbols.
114 (:args
(symbol :scs
(descriptor-reg))
115 (value :scs
(descriptor-reg any-reg
)))
116 (:temporary
(:sc descriptor-reg
) tls
)
117 ;;(:policy :fast-safe)
119 (let ((global-val (gen-label))
121 (loadw tls symbol symbol-tls-index-slot other-pointer-lowtag
)
122 (inst cmp
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls
)
123 no-tls-value-marker-widetag
)
124 (inst jmp
:z global-val
)
125 (inst mov
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls
)
128 (emit-label global-val
)
129 (storew value symbol symbol-value-slot other-pointer-lowtag
)
132 ;; unithreaded it's a lot simpler ...
134 (define-vop (set cell-set
)
135 (:variant symbol-value-slot other-pointer-lowtag
))
137 ;;; With Symbol-Value, we check that the value isn't the trap object. So
138 ;;; Symbol-Value of NIL is NIL.
140 (define-vop (symbol-value)
141 (:translate symbol-value
)
143 (:args
(object :scs
(descriptor-reg) :to
(:result
1)))
144 (:results
(value :scs
(descriptor-reg any-reg
)))
146 (:save-p
:compute-only
)
148 (let* ((check-unbound-label (gen-label))
149 (err-lab (generate-error-code vop
'unbound-symbol-error object
))
150 (ret-lab (gen-label)))
151 (loadw value object symbol-tls-index-slot other-pointer-lowtag
)
152 (inst mov value
(make-ea :qword
:base thread-base-tn
153 :index value
:scale
1))
154 (inst cmp value no-tls-value-marker-widetag
)
155 (inst jmp
:ne check-unbound-label
)
156 (loadw value object symbol-value-slot other-pointer-lowtag
)
157 (emit-label check-unbound-label
)
158 (inst cmp value unbound-marker-widetag
)
159 (inst jmp
:e err-lab
)
160 (emit-label ret-lab
))))
163 (define-vop (fast-symbol-value symbol-value
)
164 ;; KLUDGE: not really fast, in fact, because we're going to have to
165 ;; do a full lookup of the thread-local area anyway. But half of
166 ;; the meaning of FAST-SYMBOL-VALUE is "do not signal an error if
167 ;; unbound", which is used in the implementation of COPY-SYMBOL. --
170 (:translate symbol-value
)
172 (let ((ret-lab (gen-label)))
173 (loadw value object symbol-tls-index-slot other-pointer-lowtag
)
175 (make-ea :qword
:base thread-base-tn
:index value
:scale
1))
176 (inst cmp value no-tls-value-marker-widetag
)
177 (inst jmp
:ne ret-lab
)
178 (loadw value object symbol-value-slot other-pointer-lowtag
)
179 (emit-label ret-lab
))))
182 (define-vop (symbol-value)
183 (:translate symbol-value
)
185 (:args
(object :scs
(descriptor-reg) :to
(:result
1)))
186 (:results
(value :scs
(descriptor-reg any-reg
)))
188 (:save-p
:compute-only
)
190 (let ((err-lab (generate-error-code vop
'unbound-symbol-error object
)))
191 (loadw value object symbol-value-slot other-pointer-lowtag
)
192 (inst cmp value unbound-marker-widetag
)
193 (inst jmp
:e err-lab
))))
196 (define-vop (fast-symbol-value cell-ref
)
197 (:variant symbol-value-slot other-pointer-lowtag
)
199 (:translate symbol-value
))
201 (defknown locked-symbol-global-value-add
(symbol fixnum
) fixnum
())
203 (define-vop (locked-symbol-global-value-add)
204 (:args
(object :scs
(descriptor-reg) :to
:result
)
205 (value :scs
(any-reg) :target result
))
206 (:arg-types
* tagged-num
)
207 (:results
(result :scs
(any-reg) :from
(:argument
1)))
209 (:translate locked-symbol-global-value-add
)
210 (:result-types tagged-num
)
214 (inst add
(make-ea :qword
:base object
215 :disp
(- (* symbol-value-slot n-word-bytes
)
216 other-pointer-lowtag
))
223 (:args
(object :scs
(descriptor-reg)))
225 (:temporary
(:sc descriptor-reg
#+nil
(:from
(:argument
0))) value
)
227 (let ((check-unbound-label (gen-label)))
228 (loadw value object symbol-tls-index-slot other-pointer-lowtag
)
230 (make-ea :qword
:base thread-base-tn
:index value
:scale
1))
231 (inst cmp value no-tls-value-marker-widetag
)
232 (inst jmp
:ne check-unbound-label
)
233 (loadw value object symbol-value-slot other-pointer-lowtag
)
234 (emit-label check-unbound-label
)
235 (inst cmp value unbound-marker-widetag
))))
241 (:args
(object :scs
(descriptor-reg)))
244 (inst cmp
(make-ea-for-object-slot object symbol-value-slot
245 other-pointer-lowtag
)
246 unbound-marker-widetag
)))
249 (define-vop (symbol-hash)
251 (:translate symbol-hash
)
252 (:args
(symbol :scs
(descriptor-reg)))
253 (:results
(res :scs
(any-reg)))
254 (:result-types positive-fixnum
)
256 ;; The symbol-hash slot of NIL holds NIL because it is also the
257 ;; cdr slot, so we have to strip off the three low bits to make sure
258 ;; it is a fixnum. The lowtag selection magic that is required to
259 ;; ensure this is explained in the comment in objdef.lisp
260 (loadw res symbol symbol-hash-slot other-pointer-lowtag
)
261 (inst and res
(lognot #b111
))))
263 ;;;; fdefinition (FDEFN) objects
265 (define-vop (fdefn-fun cell-ref
) ; /pfw - alpha
266 (:variant fdefn-fun-slot other-pointer-lowtag
))
268 (define-vop (safe-fdefn-fun)
269 (:args
(object :scs
(descriptor-reg) :to
(:result
1)))
270 (:results
(value :scs
(descriptor-reg any-reg
)))
272 (:save-p
:compute-only
)
274 (loadw value object fdefn-fun-slot other-pointer-lowtag
)
275 (inst cmp value nil-value
)
276 (let ((err-lab (generate-error-code vop
'undefined-fun-error object
)))
277 (inst jmp
:e err-lab
))))
279 (define-vop (set-fdefn-fun)
281 (:translate
(setf fdefn-fun
))
282 (:args
(function :scs
(descriptor-reg) :target result
)
283 (fdefn :scs
(descriptor-reg)))
284 (:temporary
(:sc unsigned-reg
) raw
)
285 (:temporary
(:sc byte-reg
) type
)
286 (:results
(result :scs
(descriptor-reg)))
288 (load-type type function
(- fun-pointer-lowtag
))
290 (make-ea :byte
:base function
291 :disp
(- (* simple-fun-code-offset n-word-bytes
)
292 fun-pointer-lowtag
)))
293 (inst cmp type simple-fun-header-widetag
)
294 (inst jmp
:e NORMAL-FUN
)
295 (inst lea raw
(make-fixup "closure_tramp" :foreign
))
297 (storew function fdefn fdefn-fun-slot other-pointer-lowtag
)
298 (storew raw fdefn fdefn-raw-addr-slot other-pointer-lowtag
)
299 (move result function
)))
301 (define-vop (fdefn-makunbound)
303 (:translate fdefn-makunbound
)
304 (:args
(fdefn :scs
(descriptor-reg) :target result
))
305 (:results
(result :scs
(descriptor-reg)))
307 (storew nil-value fdefn fdefn-fun-slot other-pointer-lowtag
)
308 (storew (make-fixup "undefined_tramp" :foreign
)
309 fdefn fdefn-raw-addr-slot other-pointer-lowtag
)
310 (move result fdefn
)))
312 ;;;; binding and unbinding
314 ;;; BIND -- Establish VAL as a binding for SYMBOL. Save the old value and
315 ;;; the symbol on the binding stack and stuff the new value into the
320 (:args
(val :scs
(any-reg descriptor-reg
))
321 (symbol :scs
(descriptor-reg)))
322 (:temporary
(:sc unsigned-reg
) tls-index bsp
)
324 (let ((tls-index-valid (gen-label)))
325 (load-binding-stack-pointer bsp
)
326 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag
)
327 (inst add bsp
(* binding-size n-word-bytes
))
328 (store-binding-stack-pointer bsp
)
329 (inst or tls-index tls-index
)
330 (inst jmp
:ne tls-index-valid
)
331 (inst mov tls-index symbol
)
332 (inst lea temp-reg-tn
333 (make-ea :qword
:disp
334 (make-fixup (ecase (tn-offset tls-index
)
335 (#.rax-offset
'alloc-tls-index-in-rax
)
336 (#.rcx-offset
'alloc-tls-index-in-rcx
)
337 (#.rdx-offset
'alloc-tls-index-in-rdx
)
338 (#.rbx-offset
'alloc-tls-index-in-rbx
)
339 (#.rsi-offset
'alloc-tls-index-in-rsi
)
340 (#.rdi-offset
'alloc-tls-index-in-rdi
)
341 (#.r8-offset
'alloc-tls-index-in-r8
)
342 (#.r9-offset
'alloc-tls-index-in-r9
)
343 (#.r10-offset
'alloc-tls-index-in-r10
)
344 (#.r12-offset
'alloc-tls-index-in-r12
)
345 (#.r13-offset
'alloc-tls-index-in-r13
)
346 (#.r14-offset
'alloc-tls-index-in-r14
)
347 (#.r15-offset
'alloc-tls-index-in-r15
))
349 (inst call temp-reg-tn
)
350 (emit-label tls-index-valid
)
351 (inst push
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls-index
))
352 (popw bsp
(- binding-value-slot binding-size
))
353 (storew symbol bsp
(- binding-symbol-slot binding-size
))
354 (inst mov
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls-index
)
359 (:args
(val :scs
(any-reg descriptor-reg
))
360 (symbol :scs
(descriptor-reg)))
361 (:temporary
(:sc unsigned-reg
) temp bsp
)
363 (load-symbol-value bsp
*binding-stack-pointer
*)
364 (loadw temp symbol symbol-value-slot other-pointer-lowtag
)
365 (inst add bsp
(* binding-size n-word-bytes
))
366 (store-symbol-value bsp
*binding-stack-pointer
*)
367 (storew temp bsp
(- binding-value-slot binding-size
))
368 (storew symbol bsp
(- binding-symbol-slot binding-size
))
369 (storew val symbol symbol-value-slot other-pointer-lowtag
)))
373 (:temporary
(:sc unsigned-reg
) temp bsp tls-index
)
375 (load-binding-stack-pointer bsp
)
376 ;; Load SYMBOL from stack, and get the TLS-INDEX
377 (loadw temp bsp
(- binding-symbol-slot binding-size
))
378 (loadw tls-index temp symbol-tls-index-slot other-pointer-lowtag
)
379 ;; Load VALUE from stack, the restore it to the TLS area.
380 (loadw temp bsp
(- binding-value-slot binding-size
))
381 (inst mov
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls-index
)
383 ;; Zero out the stack.
384 (storew 0 bsp
(- binding-symbol-slot binding-size
))
385 (storew 0 bsp
(- binding-value-slot binding-size
))
386 (inst sub bsp
(* binding-size n-word-bytes
))
387 (store-binding-stack-pointer bsp
)))
391 (:temporary
(:sc unsigned-reg
) symbol value bsp
)
393 (load-symbol-value bsp
*binding-stack-pointer
*)
394 (loadw symbol bsp
(- binding-symbol-slot binding-size
))
395 (loadw value bsp
(- binding-value-slot binding-size
))
396 (storew value symbol symbol-value-slot other-pointer-lowtag
)
397 (storew 0 bsp
(- binding-symbol-slot binding-size
))
398 (storew 0 bsp
(- binding-value-slot binding-size
))
399 (inst sub bsp
(* binding-size n-word-bytes
))
400 (store-symbol-value bsp
*binding-stack-pointer
*)))
402 (define-vop (unbind-to-here)
403 (:args
(where :scs
(descriptor-reg any-reg
)))
404 (:temporary
(:sc unsigned-reg
) symbol value bsp
#!+sb-thread tls-index
)
406 (load-binding-stack-pointer bsp
)
411 (loadw symbol bsp
(- binding-symbol-slot binding-size
))
412 (inst or symbol symbol
)
414 ;; Bind stack debug sentinels have the unbound marker in the symbol slot
415 (inst cmp symbol unbound-marker-widetag
)
417 (loadw value bsp
(- binding-value-slot binding-size
))
419 (storew value symbol symbol-value-slot other-pointer-lowtag
)
421 (loadw tls-index symbol symbol-tls-index-slot other-pointer-lowtag
)
423 (inst mov
(make-ea :qword
:base thread-base-tn
:scale
1 :index tls-index
)
425 (storew 0 bsp
(- binding-symbol-slot binding-size
))
428 (storew 0 bsp
(- binding-value-slot binding-size
))
429 (inst sub bsp
(* binding-size n-word-bytes
))
432 (store-binding-stack-pointer bsp
)
436 (define-vop (bind-sentinel)
437 (:temporary
(:sc unsigned-reg
) bsp
)
439 (load-binding-stack-pointer bsp
)
440 (inst add bsp
(* binding-size n-word-bytes
))
441 (storew unbound-marker-widetag bsp
(- binding-symbol-slot binding-size
))
442 (storew rbp-tn bsp
(- binding-value-slot binding-size
))
443 (store-binding-stack-pointer bsp
)))
445 (define-vop (unbind-sentinel)
446 (:temporary
(:sc unsigned-reg
) bsp
)
448 (load-binding-stack-pointer bsp
)
449 (storew 0 bsp
(- binding-value-slot binding-size
))
450 (storew 0 bsp
(- binding-symbol-slot binding-size
))
451 (inst sub bsp
(* binding-size n-word-bytes
))
452 (store-binding-stack-pointer bsp
)))
457 ;;;; closure indexing
459 (define-full-reffer closure-index-ref
*
460 closure-info-offset fun-pointer-lowtag
461 (any-reg descriptor-reg
) * %closure-index-ref
)
463 (define-full-setter set-funcallable-instance-info
*
464 funcallable-instance-info-offset fun-pointer-lowtag
465 (any-reg descriptor-reg
) * %set-funcallable-instance-info
)
467 (define-full-reffer funcallable-instance-info
*
468 funcallable-instance-info-offset fun-pointer-lowtag
469 (descriptor-reg any-reg
) * %funcallable-instance-info
)
471 (define-vop (closure-ref slot-ref
)
472 (:variant closure-info-offset fun-pointer-lowtag
))
474 (define-vop (closure-init slot-set
)
475 (:variant closure-info-offset fun-pointer-lowtag
))
477 ;;;; value cell hackery
479 (define-vop (value-cell-ref cell-ref
)
480 (:variant value-cell-value-slot other-pointer-lowtag
))
482 (define-vop (value-cell-set cell-set
)
483 (:variant value-cell-value-slot other-pointer-lowtag
))
485 ;;;; structure hackery
487 (define-vop (instance-length)
489 (:translate %instance-length
)
490 (:args
(struct :scs
(descriptor-reg)))
491 (:results
(res :scs
(unsigned-reg)))
492 (:result-types positive-fixnum
)
494 (loadw res struct
0 instance-pointer-lowtag
)
495 (inst shr res n-widetag-bits
)))
497 (define-full-reffer instance-index-ref
* instance-slots-offset
498 instance-pointer-lowtag
(any-reg descriptor-reg
) * %instance-ref
)
500 (define-full-setter instance-index-set
* instance-slots-offset
501 instance-pointer-lowtag
(any-reg descriptor-reg
) * %instance-set
)
503 (define-full-compare-and-swap %compare-and-swap-instance-ref instance
504 instance-slots-offset instance-pointer-lowtag
505 (any-reg descriptor-reg
) *
506 %compare-and-swap-instance-ref
)
508 ;;;; code object frobbing
510 (define-full-reffer code-header-ref
* 0 other-pointer-lowtag
511 (any-reg descriptor-reg
) * code-header-ref
)
513 (define-full-setter code-header-set
* 0 other-pointer-lowtag
514 (any-reg descriptor-reg
) * code-header-set
)
516 ;;;; raw instance slot accessors
518 (defun make-ea-for-raw-slot (object index instance-length
519 &optional
(adjustment 0))
520 (if (integerp instance-length
)
521 ;; For RAW-INSTANCE-INIT/* VOPs, which know the exact instance length
525 :disp
(+ (* (- instance-length instance-slots-offset index
)
527 (- instance-pointer-lowtag
)
531 (make-ea :qword
:base object
:index instance-length
532 :disp
(+ (* (1- instance-slots-offset
) n-word-bytes
)
533 (- instance-pointer-lowtag
)
536 (make-ea :qword
:base object
:index instance-length
538 :disp
(+ (* (1- instance-slots-offset
) n-word-bytes
)
539 (- instance-pointer-lowtag
)
541 (* index
(- n-word-bytes
))))))))
543 (define-vop (raw-instance-ref/word
)
544 (:translate %raw-instance-ref
/word
)
546 (:args
(object :scs
(descriptor-reg)) (index :scs
(any-reg)))
547 (:arg-types
* tagged-num
)
548 (:temporary
(:sc unsigned-reg
) tmp
)
549 (:results
(value :scs
(unsigned-reg)))
550 (:result-types unsigned-num
)
552 (loadw tmp object
0 instance-pointer-lowtag
)
553 (inst shr tmp n-widetag-bits
)
556 (inst mov value
(make-ea-for-raw-slot object index tmp
))))
558 (define-vop (raw-instance-ref-c/word
)
559 (:translate %raw-instance-ref
/word
)
561 (:args
(object :scs
(descriptor-reg)))
562 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
563 #.instance-pointer-lowtag
564 #.instance-slots-offset
)))
566 (:temporary
(:sc unsigned-reg
) tmp
)
567 (:results
(value :scs
(unsigned-reg)))
568 (:result-types unsigned-num
)
570 (loadw tmp object
0 instance-pointer-lowtag
)
571 (inst shr tmp n-widetag-bits
)
572 (inst mov value
(make-ea-for-raw-slot object index tmp
))))
574 (define-vop (raw-instance-set/word
)
575 (:translate %raw-instance-set
/word
)
577 (:args
(object :scs
(descriptor-reg))
578 (index :scs
(any-reg))
579 (value :scs
(unsigned-reg) :target result
))
580 (:arg-types
* tagged-num unsigned-num
)
581 (:temporary
(:sc unsigned-reg
) tmp
)
582 (:results
(result :scs
(unsigned-reg)))
583 (:result-types unsigned-num
)
585 (loadw tmp object
0 instance-pointer-lowtag
)
586 (inst shr tmp n-widetag-bits
)
589 (inst mov
(make-ea-for-raw-slot object index tmp
) value
)
590 (move result value
)))
592 (define-vop (raw-instance-set-c/word
)
593 (:translate %raw-instance-set
/word
)
595 (:args
(object :scs
(descriptor-reg))
596 (value :scs
(unsigned-reg) :target result
))
597 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
598 #.instance-pointer-lowtag
599 #.instance-slots-offset
))
602 (:temporary
(:sc unsigned-reg
) tmp
)
603 (:results
(result :scs
(unsigned-reg)))
604 (:result-types unsigned-num
)
606 (loadw tmp object
0 instance-pointer-lowtag
)
607 (inst shr tmp n-widetag-bits
)
608 (inst mov
(make-ea-for-raw-slot object index tmp
) value
)
609 (move result value
)))
611 (define-vop (raw-instance-init/word
)
612 (:args
(object :scs
(descriptor-reg))
613 (value :scs
(unsigned-reg)))
614 (:arg-types
* unsigned-num
)
615 (:info instance-length index
)
617 (inst mov
(make-ea-for-raw-slot object index instance-length
) value
)))
619 (define-vop (raw-instance-atomic-incf-c/word
)
620 (:translate %raw-instance-atomic-incf
/word
)
622 (:args
(object :scs
(descriptor-reg))
623 (diff :scs
(signed-reg) :target result
))
624 (:arg-types
* (:constant
(load/store-index
#.n-word-bytes
625 #.instance-pointer-lowtag
626 #.instance-slots-offset
))
629 (:temporary
(:sc unsigned-reg
) tmp
)
630 (:results
(result :scs
(unsigned-reg)))
631 (:result-types unsigned-num
)
633 (loadw tmp object
0 instance-pointer-lowtag
)
634 (inst shr tmp n-widetag-bits
)
635 (inst xadd
(make-ea-for-raw-slot object index tmp
) diff
:lock
)
638 (define-vop (raw-instance-ref/single
)
639 (:translate %raw-instance-ref
/single
)
641 (:args
(object :scs
(descriptor-reg))
642 (index :scs
(any-reg)))
643 (:arg-types
* positive-fixnum
)
644 (:temporary
(:sc unsigned-reg
) tmp
)
645 (:results
(value :scs
(single-reg)))
646 (:result-types single-float
)
648 (loadw tmp object
0 instance-pointer-lowtag
)
649 (inst shr tmp n-widetag-bits
)
652 (inst movss value
(make-ea-for-raw-slot object index tmp
))))
654 (define-vop (raw-instance-ref-c/single
)
655 (:translate %raw-instance-ref
/single
)
657 (:args
(object :scs
(descriptor-reg)))
658 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
659 #.instance-pointer-lowtag
660 #.instance-slots-offset
)))
662 (:temporary
(:sc unsigned-reg
) tmp
)
663 (:results
(value :scs
(single-reg)))
664 (:result-types single-float
)
666 (loadw tmp object
0 instance-pointer-lowtag
)
667 (inst shr tmp n-widetag-bits
)
668 (inst movss value
(make-ea-for-raw-slot object index tmp
))))
670 (define-vop (raw-instance-set/single
)
671 (:translate %raw-instance-set
/single
)
673 (:args
(object :scs
(descriptor-reg))
674 (index :scs
(any-reg))
675 (value :scs
(single-reg) :target result
))
676 (:arg-types
* positive-fixnum single-float
)
677 (:temporary
(:sc unsigned-reg
) tmp
)
678 (:results
(result :scs
(single-reg)))
679 (:result-types single-float
)
681 (loadw tmp object
0 instance-pointer-lowtag
)
682 (inst shr tmp n-widetag-bits
)
685 (inst movss
(make-ea-for-raw-slot object index tmp
) value
)
686 (unless (location= result value
)
687 (inst movss result value
))))
689 (define-vop (raw-instance-set-c/single
)
690 (:translate %raw-instance-set
/single
)
692 (:args
(object :scs
(descriptor-reg))
693 (value :scs
(single-reg) :target result
))
694 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
695 #.instance-pointer-lowtag
696 #.instance-slots-offset
))
699 (:temporary
(:sc unsigned-reg
) tmp
)
700 (:results
(result :scs
(single-reg)))
701 (:result-types single-float
)
703 (loadw tmp object
0 instance-pointer-lowtag
)
704 (inst shr tmp n-widetag-bits
)
705 (inst movss
(make-ea-for-raw-slot object index tmp
) value
)
706 (unless (location= result value
)
707 (inst movss result value
))))
709 (define-vop (raw-instance-init/single
)
710 (:args
(object :scs
(descriptor-reg))
711 (value :scs
(single-reg)))
712 (:arg-types
* single-float
)
713 (:info instance-length index
)
715 (inst movss
(make-ea-for-raw-slot object index instance-length
) value
)))
717 (define-vop (raw-instance-ref/double
)
718 (:translate %raw-instance-ref
/double
)
720 (:args
(object :scs
(descriptor-reg))
721 (index :scs
(any-reg)))
722 (:arg-types
* positive-fixnum
)
723 (:temporary
(:sc unsigned-reg
) tmp
)
724 (:results
(value :scs
(double-reg)))
725 (:result-types double-float
)
727 (loadw tmp object
0 instance-pointer-lowtag
)
728 (inst shr tmp n-widetag-bits
)
731 (inst movsd value
(make-ea-for-raw-slot object index tmp
))))
733 (define-vop (raw-instance-ref-c/double
)
734 (:translate %raw-instance-ref
/double
)
736 (:args
(object :scs
(descriptor-reg)))
737 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
738 #.instance-pointer-lowtag
739 #.instance-slots-offset
)))
741 (:temporary
(:sc unsigned-reg
) tmp
)
742 (:results
(value :scs
(double-reg)))
743 (:result-types double-float
)
745 (loadw tmp object
0 instance-pointer-lowtag
)
746 (inst shr tmp n-widetag-bits
)
747 (inst movsd value
(make-ea-for-raw-slot object index tmp
))))
749 (define-vop (raw-instance-set/double
)
750 (:translate %raw-instance-set
/double
)
752 (:args
(object :scs
(descriptor-reg))
753 (index :scs
(any-reg))
754 (value :scs
(double-reg) :target result
))
755 (:arg-types
* positive-fixnum double-float
)
756 (:temporary
(:sc unsigned-reg
) tmp
)
757 (:results
(result :scs
(double-reg)))
758 (:result-types double-float
)
760 (loadw tmp object
0 instance-pointer-lowtag
)
761 (inst shr tmp n-widetag-bits
)
764 (inst movsd
(make-ea-for-raw-slot object index tmp
) value
)
765 (unless (location= result value
)
766 (inst movsd result value
))))
768 (define-vop (raw-instance-set-c/double
)
769 (:translate %raw-instance-set
/double
)
771 (:args
(object :scs
(descriptor-reg))
772 (value :scs
(double-reg) :target result
))
773 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
774 #.instance-pointer-lowtag
775 #.instance-slots-offset
))
778 (:temporary
(:sc unsigned-reg
) tmp
)
779 (:results
(result :scs
(double-reg)))
780 (:result-types double-float
)
782 (loadw tmp object
0 instance-pointer-lowtag
)
783 (inst shr tmp n-widetag-bits
)
784 (inst movsd
(make-ea-for-raw-slot object index tmp
) value
)
785 (unless (location= result value
)
786 (inst movsd result value
))))
788 (define-vop (raw-instance-init/double
)
789 (:args
(object :scs
(descriptor-reg))
790 (value :scs
(double-reg)))
791 (:arg-types
* double-float
)
792 (:info instance-length index
)
794 (inst movsd
(make-ea-for-raw-slot object index instance-length
) value
)))
796 (define-vop (raw-instance-ref/complex-single
)
797 (:translate %raw-instance-ref
/complex-single
)
799 (:args
(object :scs
(descriptor-reg))
800 (index :scs
(any-reg)))
801 (:arg-types
* positive-fixnum
)
802 (:temporary
(:sc unsigned-reg
) tmp
)
803 (:results
(value :scs
(complex-single-reg)))
804 (:result-types complex-single-float
)
806 (loadw tmp object
0 instance-pointer-lowtag
)
807 (inst shr tmp n-widetag-bits
)
810 (let ((real-tn (complex-single-reg-real-tn value
)))
811 (inst movss real-tn
(make-ea-for-raw-slot object index tmp
)))
812 (let ((imag-tn (complex-single-reg-imag-tn value
)))
813 (inst movss imag-tn
(make-ea-for-raw-slot object index tmp
4)))))
815 (define-vop (raw-instance-ref-c/complex-single
)
816 (:translate %raw-instance-ref
/complex-single
)
818 (:args
(object :scs
(descriptor-reg)))
819 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
820 #.instance-pointer-lowtag
821 #.instance-slots-offset
)))
823 (:temporary
(:sc unsigned-reg
) tmp
)
824 (:results
(value :scs
(complex-single-reg)))
825 (:result-types complex-single-float
)
827 (loadw tmp object
0 instance-pointer-lowtag
)
828 (inst shr tmp n-widetag-bits
)
829 (let ((real-tn (complex-single-reg-real-tn value
)))
830 (inst movss real-tn
(make-ea-for-raw-slot object index tmp
)))
831 (let ((imag-tn (complex-single-reg-imag-tn value
)))
832 (inst movss imag-tn
(make-ea-for-raw-slot object index tmp
4)))))
834 (define-vop (raw-instance-set/complex-single
)
835 (:translate %raw-instance-set
/complex-single
)
837 (:args
(object :scs
(descriptor-reg))
838 (index :scs
(any-reg))
839 (value :scs
(complex-single-reg) :target result
))
840 (:arg-types
* positive-fixnum complex-single-float
)
841 (:temporary
(:sc unsigned-reg
) tmp
)
842 (:results
(result :scs
(complex-single-reg)))
843 (:result-types complex-single-float
)
845 (loadw tmp object
0 instance-pointer-lowtag
)
846 (inst shr tmp n-widetag-bits
)
849 (let ((value-real (complex-single-reg-real-tn value
))
850 (result-real (complex-single-reg-real-tn result
)))
851 (inst movss
(make-ea-for-raw-slot object index tmp
) value-real
)
852 (unless (location= value-real result-real
)
853 (inst movss result-real value-real
)))
854 (let ((value-imag (complex-single-reg-imag-tn value
))
855 (result-imag (complex-single-reg-imag-tn result
)))
856 (inst movss
(make-ea-for-raw-slot object index tmp
4) value-imag
)
857 (unless (location= value-imag result-imag
)
858 (inst movss result-imag value-imag
)))))
860 (define-vop (raw-instance-set-c/complex-single
)
861 (:translate %raw-instance-set
/complex-single
)
863 (:args
(object :scs
(descriptor-reg))
864 (value :scs
(complex-single-reg) :target result
))
865 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
866 #.instance-pointer-lowtag
867 #.instance-slots-offset
))
868 complex-single-float
)
870 (:temporary
(:sc unsigned-reg
) tmp
)
871 (:results
(result :scs
(complex-single-reg)))
872 (:result-types complex-single-float
)
874 (loadw tmp object
0 instance-pointer-lowtag
)
875 (inst shr tmp n-widetag-bits
)
876 (let ((value-real (complex-single-reg-real-tn value
))
877 (result-real (complex-single-reg-real-tn result
)))
878 (inst movss
(make-ea-for-raw-slot object index tmp
) value-real
)
879 (unless (location= value-real result-real
)
880 (inst movss result-real value-real
)))
881 (let ((value-imag (complex-single-reg-imag-tn value
))
882 (result-imag (complex-single-reg-imag-tn result
)))
883 (inst movss
(make-ea-for-raw-slot object index tmp
4) value-imag
)
884 (unless (location= value-imag result-imag
)
885 (inst movss result-imag value-imag
)))))
887 (define-vop (raw-instance-init/complex-single
)
888 (:args
(object :scs
(descriptor-reg))
889 (value :scs
(complex-single-reg)))
890 (:arg-types
* complex-single-float
)
891 (:info instance-length index
)
893 (let ((value-real (complex-single-reg-real-tn value
)))
894 (inst movss
(make-ea-for-raw-slot object index instance-length
) value-real
))
895 (let ((value-imag (complex-single-reg-imag-tn value
)))
896 (inst movss
(make-ea-for-raw-slot object index instance-length
4) value-imag
))))
898 (define-vop (raw-instance-ref/complex-double
)
899 (:translate %raw-instance-ref
/complex-double
)
901 (:args
(object :scs
(descriptor-reg))
902 (index :scs
(any-reg)))
903 (:arg-types
* positive-fixnum
)
904 (:temporary
(:sc unsigned-reg
) tmp
)
905 (:results
(value :scs
(complex-double-reg)))
906 (:result-types complex-double-float
)
908 (loadw tmp object
0 instance-pointer-lowtag
)
909 (inst shr tmp n-widetag-bits
)
912 (let ((real-tn (complex-double-reg-real-tn value
)))
913 (inst movsd real-tn
(make-ea-for-raw-slot object index tmp -
8)))
914 (let ((imag-tn (complex-double-reg-imag-tn value
)))
915 (inst movsd imag-tn
(make-ea-for-raw-slot object index tmp
)))))
917 (define-vop (raw-instance-ref-c/complex-double
)
918 (:translate %raw-instance-ref
/complex-double
)
920 (:args
(object :scs
(descriptor-reg)))
921 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
922 #.instance-pointer-lowtag
923 #.instance-slots-offset
)))
925 (:temporary
(:sc unsigned-reg
) tmp
)
926 (:results
(value :scs
(complex-double-reg)))
927 (:result-types complex-double-float
)
929 (loadw tmp object
0 instance-pointer-lowtag
)
930 (inst shr tmp n-widetag-bits
)
931 (let ((real-tn (complex-double-reg-real-tn value
)))
932 (inst movsd real-tn
(make-ea-for-raw-slot object index tmp -
8)))
933 (let ((imag-tn (complex-double-reg-imag-tn value
)))
934 (inst movsd imag-tn
(make-ea-for-raw-slot object index tmp
)))))
936 (define-vop (raw-instance-set/complex-double
)
937 (:translate %raw-instance-set
/complex-double
)
939 (:args
(object :scs
(descriptor-reg))
940 (index :scs
(any-reg))
941 (value :scs
(complex-double-reg) :target result
))
942 (:arg-types
* positive-fixnum complex-double-float
)
943 (:temporary
(:sc unsigned-reg
) tmp
)
944 (:results
(result :scs
(complex-double-reg)))
945 (:result-types complex-double-float
)
947 (loadw tmp object
0 instance-pointer-lowtag
)
948 (inst shr tmp n-widetag-bits
)
951 (let ((value-real (complex-double-reg-real-tn value
))
952 (result-real (complex-double-reg-real-tn result
)))
953 (inst movsd
(make-ea-for-raw-slot object index tmp -
8) value-real
)
954 (unless (location= value-real result-real
)
955 (inst movsd result-real value-real
)))
956 (let ((value-imag (complex-double-reg-imag-tn value
))
957 (result-imag (complex-double-reg-imag-tn result
)))
958 (inst movsd
(make-ea-for-raw-slot object index tmp
) value-imag
)
959 (unless (location= value-imag result-imag
)
960 (inst movsd result-imag value-imag
)))))
962 (define-vop (raw-instance-set-c/complex-double
)
963 (:translate %raw-instance-set
/complex-double
)
965 (:args
(object :scs
(descriptor-reg))
966 (value :scs
(complex-double-reg) :target result
))
967 (:arg-types
* (:constant
(load/store-index
#.sb
!vm
:n-word-bytes
968 #.instance-pointer-lowtag
969 #.instance-slots-offset
))
970 complex-double-float
)
972 (:temporary
(:sc unsigned-reg
) tmp
)
973 (:results
(result :scs
(complex-double-reg)))
974 (:result-types complex-double-float
)
976 (loadw tmp object
0 instance-pointer-lowtag
)
977 (inst shr tmp n-widetag-bits
)
978 (let ((value-real (complex-double-reg-real-tn value
))
979 (result-real (complex-double-reg-real-tn result
)))
980 (inst movsd
(make-ea-for-raw-slot object index tmp -
8) value-real
)
981 (unless (location= value-real result-real
)
982 (inst movsd result-real value-real
)))
983 (let ((value-imag (complex-double-reg-imag-tn value
))
984 (result-imag (complex-double-reg-imag-tn result
)))
985 (inst movsd
(make-ea-for-raw-slot object index tmp
) value-imag
)
986 (unless (location= value-imag result-imag
)
987 (inst movsd result-imag value-imag
)))))
989 (define-vop (raw-instance-init/complex-double
)
990 (:args
(object :scs
(descriptor-reg))
991 (value :scs
(complex-double-reg)))
992 (:arg-types
* complex-double-float
)
993 (:info instance-length index
)
995 (let ((value-real (complex-double-reg-real-tn value
)))
996 (inst movsd
(make-ea-for-raw-slot object index instance-length -
8) value-real
))
997 (let ((value-imag (complex-double-reg-imag-tn value
)))
998 (inst movsd
(make-ea-for-raw-slot object index instance-length
) value-imag
))))