1 ;;;; floating point support for the x86
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 (macrolet ((ea-for-xf-desc (tn slot)
17 :disp (- (* ,slot n-word-bytes)
18 other-pointer-lowtag))))
19 (defun ea-for-df-desc (tn)
20 (ea-for-xf-desc tn double-float-value-slot))
22 (defun ea-for-csf-real-desc (tn)
23 (ea-for-xf-desc tn complex-single-float-real-slot))
24 (defun ea-for-csf-imag-desc (tn)
25 (ea-for-xf-desc tn complex-single-float-imag-slot))
26 (defun ea-for-cdf-real-desc (tn)
27 (ea-for-xf-desc tn complex-double-float-real-slot))
28 (defun ea-for-cdf-imag-desc (tn)
29 (ea-for-xf-desc tn complex-double-float-imag-slot)))
31 (macrolet ((ea-for-xf-stack (tn kind)
32 (declare (ignore kind))
35 :disp (- (* (+ (tn-offset ,tn) 1)
37 (defun ea-for-sf-stack (tn)
38 (ea-for-xf-stack tn :single))
39 (defun ea-for-df-stack (tn)
40 (ea-for-xf-stack tn :double)))
42 ;;; complex float stack EAs
43 (macrolet ((ea-for-cxf-stack (tn kind slot &optional base)
44 (declare (ignore kind))
47 :disp (- (* (+ (tn-offset ,tn)
48 (* 1 (ecase ,slot (:real 1) (:imag 2))))
50 (defun ea-for-csf-real-stack (tn &optional (base rbp-tn))
51 (ea-for-cxf-stack tn :single :real base))
52 (defun ea-for-csf-imag-stack (tn &optional (base rbp-tn))
53 (ea-for-cxf-stack tn :single :imag base))
54 (defun ea-for-cdf-real-stack (tn &optional (base rbp-tn))
55 (ea-for-cxf-stack tn :double :real base))
56 (defun ea-for-cdf-imag-stack (tn &optional (base rbp-tn))
57 (ea-for-cxf-stack tn :double :imag base)))
62 ;;; X is source, Y is destination.
64 (define-move-fun (load-fp-zero 1) (vop x y)
65 ((fp-single-zero) (single-reg)
66 (fp-double-zero) (double-reg))
67 (identity x) ; KLUDGE: IDENTITY as IGNORABLE...
68 (inst movq y fp-double-zero-tn))
70 (define-move-fun (load-single 2) (vop x y)
71 ((single-stack) (single-reg))
72 (inst movss y (ea-for-sf-stack x)))
74 (define-move-fun (store-single 2) (vop x y)
75 ((single-reg) (single-stack))
76 (inst movss (ea-for-sf-stack y) x))
78 (define-move-fun (load-double 2) (vop x y)
79 ((double-stack) (double-reg))
80 (inst movsd y (ea-for-df-stack x)))
82 (define-move-fun (store-double 2) (vop x y)
83 ((double-reg) (double-stack))
84 (inst movsd (ea-for-df-stack y) x))
86 (eval-when (:compile-toplevel :execute)
87 (setf *read-default-float-format* 'single-float))
89 ;;;; complex float move functions
91 (defun complex-single-reg-real-tn (x)
92 (make-random-tn :kind :normal :sc (sc-or-lose 'single-reg)
93 :offset (tn-offset x)))
94 (defun complex-single-reg-imag-tn (x)
95 (make-random-tn :kind :normal :sc (sc-or-lose 'single-reg)
96 :offset (1+ (tn-offset x))))
98 (defun complex-double-reg-real-tn (x)
99 (make-random-tn :kind :normal :sc (sc-or-lose 'double-reg)
100 :offset (tn-offset x)))
101 (defun complex-double-reg-imag-tn (x)
102 (make-random-tn :kind :normal :sc (sc-or-lose 'double-reg)
103 :offset (1+ (tn-offset x))))
105 ;;; X is source, Y is destination.
106 (define-move-fun (load-complex-single 2) (vop x y)
107 ((complex-single-stack) (complex-single-reg))
108 (let ((real-tn (complex-single-reg-real-tn y)))
109 (inst movss real-tn (ea-for-csf-real-stack x)))
110 (let ((imag-tn (complex-single-reg-imag-tn y)))
111 (inst movss imag-tn (ea-for-csf-imag-stack x))))
113 (define-move-fun (store-complex-single 2) (vop x y)
114 ((complex-single-reg) (complex-single-stack))
115 (let ((real-tn (complex-single-reg-real-tn x))
116 (imag-tn (complex-single-reg-imag-tn x)))
117 (inst movss (ea-for-csf-real-stack y) real-tn)
118 (inst movss (ea-for-csf-imag-stack y) imag-tn)))
120 (define-move-fun (load-complex-double 2) (vop x y)
121 ((complex-double-stack) (complex-double-reg))
122 (let ((real-tn (complex-double-reg-real-tn y)))
123 (inst movsd real-tn (ea-for-cdf-real-stack x)))
124 (let ((imag-tn (complex-double-reg-imag-tn y)))
125 (inst movsd imag-tn (ea-for-cdf-imag-stack x))))
127 (define-move-fun (store-complex-double 2) (vop x y)
128 ((complex-double-reg) (complex-double-stack))
129 (let ((real-tn (complex-double-reg-real-tn x))
130 (imag-tn (complex-double-reg-imag-tn x)))
131 (inst movsd (ea-for-cdf-real-stack y) real-tn)
132 (inst movsd (ea-for-cdf-imag-stack y) imag-tn)))
137 ;;; float register to register moves
138 (macrolet ((frob (vop sc)
143 :load-if (not (location= x y))))
144 (:results (y :scs (,sc)
145 :load-if (not (location= x y))))
148 (unless (location= y x)
150 (define-move-vop ,vop :move (,sc) (,sc)))))
151 (frob single-move single-reg)
152 (frob double-move double-reg))
154 ;;; complex float register to register moves
155 (define-vop (complex-float-move)
156 (:args (x :target y :load-if (not (location= x y))))
157 (:results (y :load-if (not (location= x y))))
158 (:note "complex float move")
160 (unless (location= x y)
161 ;; Note the complex-float-regs are aligned to every second
162 ;; float register so there is not need to worry about overlap.
163 ;; (It would be better to put the imagpart in the top half of the
164 ;; register, or something, but let's worry about that later)
165 (let ((x-real (complex-single-reg-real-tn x))
166 (y-real (complex-single-reg-real-tn y)))
167 (inst movq y-real x-real))
168 (let ((x-imag (complex-single-reg-imag-tn x))
169 (y-imag (complex-single-reg-imag-tn y)))
170 (inst movq y-imag x-imag)))))
172 (define-vop (complex-single-move complex-float-move)
173 (:args (x :scs (complex-single-reg) :target y
174 :load-if (not (location= x y))))
175 (:results (y :scs (complex-single-reg) :load-if (not (location= x y)))))
176 (define-move-vop complex-single-move :move
177 (complex-single-reg) (complex-single-reg))
179 (define-vop (complex-double-move complex-float-move)
180 (:args (x :scs (complex-double-reg)
181 :target y :load-if (not (location= x y))))
182 (:results (y :scs (complex-double-reg) :load-if (not (location= x y)))))
183 (define-move-vop complex-double-move :move
184 (complex-double-reg) (complex-double-reg))
187 ;;; Move from float to a descriptor reg. allocating a new float
188 ;;; object in the process.
189 (define-vop (move-from-single)
190 (:args (x :scs (single-reg) :to :save))
191 (:results (y :scs (descriptor-reg)))
192 (:note "float to pointer coercion")
196 (inst or y single-float-widetag)))
198 (define-move-vop move-from-single :move
199 (single-reg) (descriptor-reg))
201 (define-vop (move-from-double)
202 (:args (x :scs (double-reg) :to :save))
203 (:results (y :scs (descriptor-reg)))
205 (:note "float to pointer coercion")
207 (with-fixed-allocation (y
211 (inst movsd (ea-for-df-desc y) x))))
212 (define-move-vop move-from-double :move
213 (double-reg) (descriptor-reg))
215 ;;; Move from a descriptor to a float register.
216 (define-vop (move-to-single)
217 (:args (x :scs (descriptor-reg) :target tmp))
218 (:temporary (:sc unsigned-reg) tmp)
219 (:results (y :scs (single-reg)))
220 (:note "pointer to float coercion")
226 (define-move-vop move-to-single :move (descriptor-reg) (single-reg))
228 (define-vop (move-to-double)
229 (:args (x :scs (descriptor-reg)))
230 (:results (y :scs (double-reg)))
231 (:note "pointer to float coercion")
233 (inst movsd y (ea-for-df-desc x))))
234 (define-move-vop move-to-double :move (descriptor-reg) (double-reg))
237 ;;; Move from complex float to a descriptor reg. allocating a new
238 ;;; complex float object in the process.
239 (define-vop (move-from-complex-single)
240 (:args (x :scs (complex-single-reg) :to :save))
241 (:results (y :scs (descriptor-reg)))
243 (:note "complex float to pointer coercion")
245 (with-fixed-allocation (y
246 complex-single-float-widetag
247 complex-single-float-size
249 (let ((real-tn (complex-single-reg-real-tn x)))
250 (inst movss (ea-for-csf-real-desc y) real-tn))
251 (let ((imag-tn (complex-single-reg-imag-tn x)))
252 (inst movss (ea-for-csf-imag-desc y) imag-tn)))))
253 (define-move-vop move-from-complex-single :move
254 (complex-single-reg) (descriptor-reg))
256 (define-vop (move-from-complex-double)
257 (:args (x :scs (complex-double-reg) :to :save))
258 (:results (y :scs (descriptor-reg)))
260 (:note "complex float to pointer coercion")
262 (with-fixed-allocation (y
263 complex-double-float-widetag
264 complex-double-float-size
266 (let ((real-tn (complex-double-reg-real-tn x)))
267 (inst movsd (ea-for-cdf-real-desc y) real-tn))
268 (let ((imag-tn (complex-double-reg-imag-tn x)))
269 (inst movsd (ea-for-cdf-imag-desc y) imag-tn)))))
270 (define-move-vop move-from-complex-double :move
271 (complex-double-reg) (descriptor-reg))
273 ;;; Move from a descriptor to a complex float register.
274 (macrolet ((frob (name sc format)
277 (:args (x :scs (descriptor-reg)))
278 (:results (y :scs (,sc)))
279 (:note "pointer to complex float coercion")
281 (let ((real-tn (complex-double-reg-real-tn y)))
285 '((inst movss real-tn (ea-for-csf-real-desc x))))
287 '((inst movsd real-tn (ea-for-cdf-real-desc x))))))
288 (let ((imag-tn (complex-double-reg-imag-tn y)))
292 '((inst movss imag-tn (ea-for-csf-imag-desc x))))
294 '((inst movsd imag-tn (ea-for-cdf-imag-desc x))))))))
295 (define-move-vop ,name :move (descriptor-reg) (,sc)))))
296 (frob move-to-complex-single complex-single-reg :single)
297 (frob move-to-complex-double complex-double-reg :double))
299 ;;;; the move argument vops
301 ;;;; Note these are also used to stuff fp numbers onto the c-call
302 ;;;; stack so the order is different than the lisp-stack.
304 ;;; the general MOVE-ARG VOP
305 (macrolet ((frob (name sc stack-sc format)
308 (:args (x :scs (,sc) :target y)
310 :load-if (not (sc-is y ,sc))))
312 (:note "float argument move")
313 (:generator ,(case format (:single 2) (:double 3) )
316 (unless (location= x y)
319 (if (= (tn-offset fp) esp-offset)
320 (let* ((offset (* (tn-offset y) n-word-bytes))
321 (ea (make-ea :dword :base fp :disp offset)))
323 (:single '((inst movss ea x)))
324 (:double '((inst movsd ea x)))))
327 :disp (- (* (+ (tn-offset y)
333 (:single '((inst movss ea x)))
334 (:double '((inst movsd ea x))))))))))
335 (define-move-vop ,name :move-arg
336 (,sc descriptor-reg) (,sc)))))
337 (frob move-single-float-arg single-reg single-stack :single)
338 (frob move-double-float-arg double-reg double-stack :double))
340 ;;;; complex float MOVE-ARG VOP
341 (macrolet ((frob (name sc stack-sc format)
344 (:args (x :scs (,sc) :target y)
346 :load-if (not (sc-is y ,sc))))
348 (:note "complex float argument move")
349 (:generator ,(ecase format (:single 2) (:double 3))
352 (unless (location= x y)
353 (let ((x-real (complex-double-reg-real-tn x))
354 (y-real (complex-double-reg-real-tn y)))
355 (inst movsd y-real x-real))
356 (let ((x-imag (complex-double-reg-imag-tn x))
357 (y-imag (complex-double-reg-imag-tn y)))
358 (inst movsd y-imag x-imag))))
360 (let ((real-tn (complex-double-reg-real-tn x)))
364 (ea-for-csf-real-stack y fp)
368 (ea-for-cdf-real-stack y fp)
370 (let ((imag-tn (complex-double-reg-imag-tn x)))
374 (ea-for-csf-imag-stack y fp) imag-tn)))
377 (ea-for-cdf-imag-stack y fp) imag-tn)))))))))
378 (define-move-vop ,name :move-arg
379 (,sc descriptor-reg) (,sc)))))
380 (frob move-complex-single-float-arg
381 complex-single-reg complex-single-stack :single)
382 (frob move-complex-double-float-arg
383 complex-double-reg complex-double-stack :double))
385 (define-move-vop move-arg :move-arg
386 (single-reg double-reg
387 complex-single-reg complex-double-reg)
393 (define-vop (float-op)
397 (:note "inline float arithmetic")
399 (:save-p :compute-only))
401 (macrolet ((frob (name sc ptype)
402 `(define-vop (,name float-op)
403 (:args (x :scs (,sc) :target r)
405 (:results (r :scs (,sc)))
406 (:arg-types ,ptype ,ptype)
407 (:result-types ,ptype))))
408 (frob single-float-op single-reg single-float)
409 (frob double-float-op double-reg double-float))
411 (macrolet ((generate (movinst opinst commutative)
416 ((and ,commutative (location= y r))
418 ((not (location= r y))
422 (inst ,movinst tmp x)
424 (inst ,movinst r tmp)))))
425 (frob (op sinst sname scost dinst dname dcost commutative)
427 (define-vop (,sname single-float-op)
429 (:temporary (:sc single-reg) tmp)
431 (generate movss ,sinst ,commutative)))
432 (define-vop (,dname double-float-op)
434 (:temporary (:sc single-reg) tmp)
436 (generate movsd ,dinst ,commutative))))))
437 (frob + addss +/single-float 2 addsd +/double-float 2 t)
438 (frob - subss -/single-float 2 subsd -/double-float 2 nil)
439 (frob * mulss */single-float 4 mulsd */double-float 5 t)
440 (frob / divss //single-float 12 divsd //double-float 19 nil))
444 (macrolet ((frob ((name translate sc type) &body body)
446 (:args (x :scs (,sc)))
447 (:results (y :scs (,sc)))
448 (:translate ,translate)
451 (:result-types ,type)
452 (:temporary (:sc any-reg) hex8)
455 (:note "inline float arithmetic")
457 (:save-p :compute-only)
459 (note-this-location vop :internal-error)
460 ;; we should be able to do this better. what we
461 ;; really would like to do is use the target as the
462 ;; temp whenever it's not also the source
463 (unless (location= x y)
466 (frob (%negate/double-float %negate double-reg double-float)
467 (inst lea hex8 (make-ea :qword :disp 1))
468 (inst ror hex8 1) ; #x8000000000000000
471 (frob (%negate/single-float %negate single-reg single-float)
472 (inst lea hex8 (make-ea :qword :disp 1))
476 (frob (abs/double-float abs double-reg double-float)
481 (frob (abs/single-float abs single-reg single-float)
489 (define-vop (float-compare)
494 (:save-p :compute-only)
495 (:note "inline float comparison"))
497 ;;; comiss and comisd can cope with one or other arg in memory: we
498 ;;; could (should, indeed) extend these to cope with descriptor args
501 (define-vop (single-float-compare float-compare)
502 (:args (x :scs (single-reg)) (y :scs (single-reg)))
504 (:arg-types single-float single-float))
505 (define-vop (double-float-compare float-compare)
506 (:args (x :scs (double-reg)) (y :scs (double-reg)))
508 (:arg-types double-float double-float))
510 (define-vop (=/single-float single-float-compare)
515 (note-this-location vop :internal-error)
517 ;; if PF&CF, there was a NaN involved => not equal
518 ;; otherwise, ZF => equal
521 (inst jmp :ne target))
523 (let ((not-lab (gen-label)))
524 (inst jmp :p not-lab)
526 (emit-label not-lab))))))
528 (define-vop (=/double-float double-float-compare)
533 (note-this-location vop :internal-error)
537 (inst jmp :ne target))
539 (let ((not-lab (gen-label)))
540 (inst jmp :p not-lab)
542 (emit-label not-lab))))))
544 ;; XXX all of these probably have bad NaN behaviour
545 (define-vop (<double-float double-float-compare)
550 (inst jmp (if not-p :nc :c) target)))
552 (define-vop (<single-float single-float-compare)
557 (inst jmp (if not-p :nc :c) target)))
559 (define-vop (>double-float double-float-compare)
564 (inst jmp (if not-p :na :a) target)))
566 (define-vop (>single-float single-float-compare)
571 (inst jmp (if not-p :na :a) target)))
577 (macrolet ((frob (name translate inst to-sc to-type)
579 (:args (x :scs (signed-stack signed-reg) :target temp))
580 (:temporary (:sc signed-stack) temp)
581 (:results (y :scs (,to-sc)))
582 (:arg-types signed-num)
583 (:result-types ,to-type)
585 (:note "inline float coercion")
586 (:translate ,translate)
588 (:save-p :compute-only)
593 (note-this-location vop :internal-error)
596 (note-this-location vop :internal-error)
597 (inst ,inst y x)))))))
598 (frob %single-float/signed %single-float cvtsi2ss single-reg single-float)
599 (frob %double-float/signed %double-float cvtsi2sd double-reg double-float))
601 (macrolet ((frob (name translate inst from-sc from-type to-sc to-type)
603 (:args (x :scs (,from-sc) :target y))
604 (:results (y :scs (,to-sc)))
605 (:arg-types ,from-type)
606 (:result-types ,to-type)
608 (:note "inline float coercion")
609 (:translate ,translate)
611 (:save-p :compute-only)
613 (note-this-location vop :internal-error)
615 (frob %single-float/double-float %single-float cvtsd2ss double-reg
616 double-float single-reg single-float)
618 (frob %double-float/single-float %double-float cvtss2sd
619 single-reg single-float double-reg double-float))
621 (macrolet ((frob (trans inst from-sc from-type round-p)
622 (declare (ignore round-p))
623 `(define-vop (,(symbolicate trans "/" from-type))
624 (:args (x :scs (,from-sc)))
625 (:temporary (:sc any-reg) temp-reg)
626 (:results (y :scs (signed-reg)))
627 (:arg-types ,from-type)
628 (:result-types signed-num)
631 (:note "inline float truncate")
633 (:save-p :compute-only)
637 (inst ,inst temp-reg x)
642 (frob %unary-truncate cvttss2si single-reg single-float nil)
643 (frob %unary-truncate cvttsd2si double-reg double-float nil)
645 (frob %unary-round cvtss2si single-reg single-float t)
646 (frob %unary-round cvtsd2si double-reg double-float t))
648 (define-vop (make-single-float)
649 (:args (bits :scs (signed-reg) :target res
650 :load-if (not (or (and (sc-is bits signed-stack)
651 (sc-is res single-reg))
652 (and (sc-is bits signed-stack)
653 (sc-is res single-stack)
654 (location= bits res))))))
655 (:results (res :scs (single-reg single-stack)))
656 (:arg-types signed-num)
657 (:result-types single-float)
658 (:translate make-single-float)
668 (aver (location= bits res)))))
672 (inst movd res bits))
674 (inst movd res bits)))))))
676 (define-vop (make-double-float)
677 (:args (hi-bits :scs (signed-reg))
678 (lo-bits :scs (unsigned-reg)))
679 (:results (res :scs (double-reg)))
680 (:temporary (:sc unsigned-reg) temp)
681 (:arg-types signed-num unsigned-num)
682 (:result-types double-float)
683 (:translate make-double-float)
689 (inst or temp lo-bits)
690 (inst movd res temp)))
692 (define-vop (single-float-bits)
693 (:args (float :scs (single-reg descriptor-reg)
694 :load-if (not (sc-is float single-stack))))
695 (:results (bits :scs (signed-reg)))
696 (:temporary (:sc signed-stack :from :argument :to :result) stack-temp)
697 (:arg-types single-float)
698 (:result-types signed-num)
699 (:translate single-float-bits)
707 (inst movss stack-temp float)
708 (move bits stack-temp))
713 (inst shr bits 32))))
717 (inst movss bits float)))))
722 (define-vop (double-float-high-bits)
723 (:args (float :scs (double-reg descriptor-reg)
724 :load-if (not (sc-is float double-stack))))
725 (:results (hi-bits :scs (signed-reg)))
726 (:temporary (:sc signed-stack :from :argument :to :result) temp)
727 (:arg-types double-float)
728 (:result-types signed-num)
729 (:translate double-float-high-bits)
735 (inst movsd temp float)
738 (loadw hi-bits ebp-tn (- (1+ (tn-offset float)))))
740 (loadw hi-bits float double-float-value-slot
741 other-pointer-lowtag)))
742 (inst sar hi-bits 32)))
744 (define-vop (double-float-low-bits)
745 (:args (float :scs (double-reg descriptor-reg)
746 :load-if (not (sc-is float double-stack))))
747 (:results (lo-bits :scs (unsigned-reg)))
748 (:temporary (:sc signed-stack :from :argument :to :result) temp)
749 (:arg-types double-float)
750 (:result-types unsigned-num)
751 (:translate double-float-low-bits)
757 (inst movsd temp float)
760 (loadw lo-bits ebp-tn (- (1+ (tn-offset float)))))
762 (loadw lo-bits float double-float-value-slot
763 other-pointer-lowtag)))
764 (inst shl lo-bits 32)
765 (inst shr lo-bits 32)))
769 ;;;; complex float VOPs
771 (define-vop (make-complex-single-float)
773 (:args (real :scs (single-reg) :to :result :target r
774 :load-if (not (location= real r)))
775 (imag :scs (single-reg) :to :save))
776 (:arg-types single-float single-float)
777 (:results (r :scs (complex-single-reg) :from (:argument 0)
778 :load-if (not (sc-is r complex-single-stack))))
779 (:result-types complex-single-float)
780 (:note "inline complex single-float creation")
785 (let ((r-real (complex-single-reg-real-tn r)))
786 (unless (location= real r-real)
787 (inst movss r-real real)))
788 (let ((r-imag (complex-single-reg-imag-tn r)))
789 (unless (location= imag r-imag)
790 (inst movss r-imag imag))))
791 (complex-single-stack
792 (inst movss (ea-for-csf-real-stack r) real)
793 (inst movss (ea-for-csf-imag-stack r) imag)))))
795 (define-vop (make-complex-double-float)
797 (:args (real :scs (double-reg) :target r
798 :load-if (not (location= real r)))
799 (imag :scs (double-reg) :to :save))
800 (:arg-types double-float double-float)
801 (:results (r :scs (complex-double-reg) :from (:argument 0)
802 :load-if (not (sc-is r complex-double-stack))))
803 (:result-types complex-double-float)
804 (:note "inline complex double-float creation")
809 (let ((r-real (complex-double-reg-real-tn r)))
810 (unless (location= real r-real)
811 (inst movsd r-real real)))
812 (let ((r-imag (complex-double-reg-imag-tn r)))
813 (unless (location= imag r-imag)
814 (inst movsd r-imag imag))))
815 (complex-double-stack
816 (inst movsd (ea-for-cdf-real-stack r) real)
817 (inst movsd (ea-for-cdf-imag-stack r) imag)))))
819 (define-vop (complex-float-value)
820 (:args (x :target r))
822 (:variant-vars offset)
825 (cond ((sc-is x complex-single-reg complex-double-reg)
827 (make-random-tn :kind :normal
828 :sc (sc-or-lose 'double-reg)
829 :offset (+ offset (tn-offset x)))))
830 (unless (location= value-tn r)
831 (if (sc-is x complex-single-reg)
832 (inst movss r value-tn)
833 (inst movsd r value-tn)))))
834 ((sc-is r single-reg)
836 (complex-single-stack
838 (0 (ea-for-csf-real-stack x))
839 (1 (ea-for-csf-imag-stack x))))
842 (0 (ea-for-csf-real-desc x))
843 (1 (ea-for-csf-imag-desc x)))))))
845 ((sc-is r double-reg)
847 (complex-double-stack
849 (0 (ea-for-cdf-real-stack x))
850 (1 (ea-for-cdf-imag-stack x))))
853 (0 (ea-for-cdf-real-desc x))
854 (1 (ea-for-cdf-imag-desc x)))))))
856 (t (error "COMPLEX-FLOAT-VALUE VOP failure")))))
858 (define-vop (realpart/complex-single-float complex-float-value)
859 (:translate realpart)
860 (:args (x :scs (complex-single-reg complex-single-stack descriptor-reg)
862 (:arg-types complex-single-float)
863 (:results (r :scs (single-reg)))
864 (:result-types single-float)
865 (:note "complex float realpart")
868 (define-vop (realpart/complex-double-float complex-float-value)
869 (:translate realpart)
870 (:args (x :scs (complex-double-reg complex-double-stack descriptor-reg)
872 (:arg-types complex-double-float)
873 (:results (r :scs (double-reg)))
874 (:result-types double-float)
875 (:note "complex float realpart")
878 (define-vop (imagpart/complex-single-float complex-float-value)
879 (:translate imagpart)
880 (:args (x :scs (complex-single-reg complex-single-stack descriptor-reg)
882 (:arg-types complex-single-float)
883 (:results (r :scs (single-reg)))
884 (:result-types single-float)
885 (:note "complex float imagpart")
888 (define-vop (imagpart/complex-double-float complex-float-value)
889 (:translate imagpart)
890 (:args (x :scs (complex-double-reg complex-double-stack descriptor-reg)
892 (:arg-types complex-double-float)
893 (:results (r :scs (double-reg)))
894 (:result-types double-float)
895 (:note "complex float imagpart")
899 ;;; hack dummy VOPs to bias the representation selection of their
900 ;;; arguments towards a FP register, which can help avoid consing at
901 ;;; inappropriate locations
902 (defknown double-float-reg-bias (double-float) (values))
903 (define-vop (double-float-reg-bias)
904 (:translate double-float-reg-bias)
905 (:args (x :scs (double-reg double-stack) :load-if nil))
906 (:arg-types double-float)
908 (:note "inline dummy FP register bias")
911 (defknown single-float-reg-bias (single-float) (values))
912 (define-vop (single-float-reg-bias)
913 (:translate single-float-reg-bias)
914 (:args (x :scs (single-reg single-stack) :load-if nil))
915 (:arg-types single-float)
917 (:note "inline dummy FP register bias")