X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Ffloat.lisp;h=e879b5ee4994d09810f1c1f620b2700ecc1969de;hb=d40a76606c86722b0aef8179155f9f2840739b72;hp=d8ea76419d04f14d1926d3e26d1f97b93f964cd5;hpb=64bf93a97814ea1caf62bbdcc7ef43e2fbfc8f73;p=sbcl.git diff --git a/src/compiler/x86/float.lisp b/src/compiler/x86/float.lisp index d8ea764..e879b5e 100644 --- a/src/compiler/x86/float.lisp +++ b/src/compiler/x86/float.lisp @@ -14,36 +14,37 @@ (macrolet ((ea-for-xf-desc (tn slot) `(make-ea :dword :base ,tn - :disp (- (* ,slot sb!vm:word-bytes) sb!vm:other-pointer-type)))) + :disp (- (* ,slot n-word-bytes) + other-pointer-lowtag)))) (defun ea-for-sf-desc (tn) - (ea-for-xf-desc tn sb!vm:single-float-value-slot)) + (ea-for-xf-desc tn single-float-value-slot)) (defun ea-for-df-desc (tn) - (ea-for-xf-desc tn sb!vm:double-float-value-slot)) + (ea-for-xf-desc tn double-float-value-slot)) #!+long-float (defun ea-for-lf-desc (tn) - (ea-for-xf-desc tn sb!vm:long-float-value-slot)) + (ea-for-xf-desc tn long-float-value-slot)) ;; complex floats (defun ea-for-csf-real-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-single-float-real-slot)) + (ea-for-xf-desc tn complex-single-float-real-slot)) (defun ea-for-csf-imag-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-single-float-imag-slot)) + (ea-for-xf-desc tn complex-single-float-imag-slot)) (defun ea-for-cdf-real-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-double-float-real-slot)) + (ea-for-xf-desc tn complex-double-float-real-slot)) (defun ea-for-cdf-imag-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-double-float-imag-slot)) + (ea-for-xf-desc tn complex-double-float-imag-slot)) #!+long-float (defun ea-for-clf-real-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-long-float-real-slot)) + (ea-for-xf-desc tn complex-long-float-real-slot)) #!+long-float (defun ea-for-clf-imag-desc (tn) - (ea-for-xf-desc tn sb!vm:complex-long-float-imag-slot))) + (ea-for-xf-desc tn complex-long-float-imag-slot))) (macrolet ((ea-for-xf-stack (tn kind) `(make-ea :dword :base ebp-tn :disp (- (* (+ (tn-offset ,tn) (ecase ,kind (:single 1) (:double 2) (:long 3))) - sb!vm:word-bytes))))) + n-word-bytes))))) (defun ea-for-sf-stack (tn) (ea-for-xf-stack tn :single)) (defun ea-for-df-stack (tn) @@ -77,7 +78,7 @@ (:double 2) (:long 3)) (ecase ,slot (:real 1) (:imag 2)))) - sb!vm:word-bytes))))) + n-word-bytes))))) (defun ea-for-csf-real-stack (tn &optional (base ebp-tn)) (ea-for-cxf-stack tn :single :real base)) (defun ea-for-csf-imag-stack (tn &optional (base ebp-tn)) @@ -100,7 +101,7 @@ ;;; ;;; Using a Pop then load. (defun copy-fp-reg-to-fr0 (reg) - (assert (not (zerop (tn-offset reg)))) + (aver (not (zerop (tn-offset reg)))) (inst fstp fr0-tn) (inst fld (make-random-tn :kind :normal :sc (sc-or-lose 'double-reg) @@ -108,7 +109,7 @@ ;;; Using Fxch then Fst to restore the original reg contents. #+nil (defun copy-fp-reg-to-fr0 (reg) - (assert (not (zerop (tn-offset reg)))) + (aver (not (zerop (tn-offset reg)))) (inst fxch reg) (inst fst reg)) @@ -122,13 +123,13 @@ ;;;; move functions -;;; x is source, y is destination -(define-move-function (load-single 2) (vop x y) +;;; X is source, Y is destination. +(define-move-fun (load-single 2) (vop x y) ((single-stack) (single-reg)) (with-empty-tn@fp-top(y) (inst fld (ea-for-sf-stack x)))) -(define-move-function (store-single 2) (vop x y) +(define-move-fun (store-single 2) (vop x y) ((single-reg) (single-stack)) (cond ((zerop (tn-offset x)) (inst fst (ea-for-sf-stack y))) @@ -138,12 +139,12 @@ ;; This may not be necessary as ST0 is likely invalid now. (inst fxch x)))) -(define-move-function (load-double 2) (vop x y) +(define-move-fun (load-double 2) (vop x y) ((double-stack) (double-reg)) (with-empty-tn@fp-top(y) (inst fldd (ea-for-df-stack x)))) -(define-move-function (store-double 2) (vop x y) +(define-move-fun (store-double 2) (vop x y) ((double-reg) (double-stack)) (cond ((zerop (tn-offset x)) (inst fstd (ea-for-df-stack y))) @@ -154,13 +155,13 @@ (inst fxch x)))) #!+long-float -(define-move-function (load-long 2) (vop x y) +(define-move-fun (load-long 2) (vop x y) ((long-stack) (long-reg)) (with-empty-tn@fp-top(y) (inst fldl (ea-for-lf-stack x)))) #!+long-float -(define-move-function (store-long 2) (vop x y) +(define-move-fun (store-long 2) (vop x y) ((long-reg) (long-stack)) (cond ((zerop (tn-offset x)) (store-long-float (ea-for-lf-stack y))) @@ -176,7 +177,7 @@ ;;; stored in a more precise form on chip. Anyhow, might as well use ;;; the feature. It can be turned off by hacking the ;;; "immediate-constant-sc" in vm.lisp. -(define-move-function (load-fp-constant 2) (vop x y) +(define-move-fun (load-fp-constant 2) (vop x y) ((fp-constant) (single-reg double-reg #!+long-float long-reg)) (let ((value (sb!c::constant-value (sb!c::tn-leaf x)))) (with-empty-tn@fp-top(y) @@ -222,8 +223,8 @@ (make-random-tn :kind :normal :sc (sc-or-lose 'long-reg) :offset (1+ (tn-offset x)))) -;;; x is source, y is destination. -(define-move-function (load-complex-single 2) (vop x y) +;;; X is source, Y is destination. +(define-move-fun (load-complex-single 2) (vop x y) ((complex-single-stack) (complex-single-reg)) (let ((real-tn (complex-single-reg-real-tn y))) (with-empty-tn@fp-top (real-tn) @@ -232,7 +233,7 @@ (with-empty-tn@fp-top (imag-tn) (inst fld (ea-for-csf-imag-stack x))))) -(define-move-function (store-complex-single 2) (vop x y) +(define-move-fun (store-complex-single 2) (vop x y) ((complex-single-reg) (complex-single-stack)) (let ((real-tn (complex-single-reg-real-tn x))) (cond ((zerop (tn-offset real-tn)) @@ -246,7 +247,7 @@ (inst fst (ea-for-csf-imag-stack y)) (inst fxch imag-tn))) -(define-move-function (load-complex-double 2) (vop x y) +(define-move-fun (load-complex-double 2) (vop x y) ((complex-double-stack) (complex-double-reg)) (let ((real-tn (complex-double-reg-real-tn y))) (with-empty-tn@fp-top(real-tn) @@ -255,7 +256,7 @@ (with-empty-tn@fp-top(imag-tn) (inst fldd (ea-for-cdf-imag-stack x))))) -(define-move-function (store-complex-double 2) (vop x y) +(define-move-fun (store-complex-double 2) (vop x y) ((complex-double-reg) (complex-double-stack)) (let ((real-tn (complex-double-reg-real-tn x))) (cond ((zerop (tn-offset real-tn)) @@ -270,7 +271,7 @@ (inst fxch imag-tn))) #!+long-float -(define-move-function (load-complex-long 2) (vop x y) +(define-move-fun (load-complex-long 2) (vop x y) ((complex-long-stack) (complex-long-reg)) (let ((real-tn (complex-long-reg-real-tn y))) (with-empty-tn@fp-top(real-tn) @@ -280,7 +281,7 @@ (inst fldl (ea-for-clf-imag-stack x))))) #!+long-float -(define-move-function (store-complex-long 2) (vop x y) +(define-move-fun (store-complex-long 2) (vop x y) ((complex-long-reg) (complex-long-stack)) (let ((real-tn (complex-long-reg-real-tn x))) (cond ((zerop (tn-offset real-tn)) @@ -387,8 +388,8 @@ (:note "float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:single-float-type - sb!vm:single-float-size node) + single-float-widetag + single-float-size node) (with-tn@fp-top(x) (inst fst (ea-for-sf-desc y)))))) (define-move-vop move-from-single :move @@ -401,8 +402,8 @@ (:note "float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:double-float-type - sb!vm:double-float-size + double-float-widetag + double-float-size node) (with-tn@fp-top(x) (inst fstd (ea-for-df-desc y)))))) @@ -417,8 +418,8 @@ (:note "float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:long-float-type - sb!vm:long-float-size + long-float-widetag + long-float-size node) (with-tn@fp-top(x) (store-long-float (ea-for-lf-desc y)))))) @@ -493,8 +494,9 @@ (:note "complex float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:complex-single-float-type - sb!vm:complex-single-float-size node) + complex-single-float-widetag + complex-single-float-size + node) (let ((real-tn (complex-single-reg-real-tn x))) (with-tn@fp-top(real-tn) (inst fst (ea-for-csf-real-desc y)))) @@ -511,8 +513,8 @@ (:note "complex float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:complex-double-float-type - sb!vm:complex-double-float-size + complex-double-float-widetag + complex-double-float-size node) (let ((real-tn (complex-double-reg-real-tn x))) (with-tn@fp-top(real-tn) @@ -531,8 +533,8 @@ (:note "complex float to pointer coercion") (:generator 13 (with-fixed-allocation (y - sb!vm:complex-long-float-type - sb!vm:complex-long-float-size + complex-long-float-widetag + complex-long-float-size node) (let ((real-tn (complex-long-reg-real-tn x))) (with-tn@fp-top(real-tn) @@ -600,7 +602,7 @@ (inst fxch x))))) (,stack-sc (if (= (tn-offset fp) esp-offset) - (let* ((offset (* (tn-offset y) word-bytes)) + (let* ((offset (* (tn-offset y) n-word-bytes)) (ea (make-ea :dword :base fp :disp offset))) (with-tn@fp-top(x) ,@(ecase format @@ -615,7 +617,7 @@ (:single 1) (:double 2) (:long 3))) - sb!vm:word-bytes))))) + n-word-bytes))))) (with-tn@fp-top(x) ,@(ecase format (:single '((inst fst ea))) @@ -1821,7 +1823,7 @@ (signed-reg (inst mov res bits)) (signed-stack - (assert (location= bits res))))) + (aver (location= bits res))))) (single-reg (sc-case bits (signed-reg @@ -1849,7 +1851,7 @@ (storew lo-bits ebp-tn (- (1+ offset))) (with-empty-tn@fp-top(res) (inst fldd (make-ea :dword :base ebp-tn - :disp (- (* (1+ offset) word-bytes)))))))) + :disp (- (* (1+ offset) n-word-bytes)))))))) #!+long-float (define-vop (make-long-float) @@ -1870,7 +1872,7 @@ (storew lo-bits ebp-tn (- (+ offset 2))) (with-empty-tn@fp-top(res) (inst fldl (make-ea :dword :base ebp-tn - :disp (- (* (+ offset 2) word-bytes)))))))) + :disp (- (* (+ offset 2) n-word-bytes)))))))) (define-vop (single-float-bits) (:args (float :scs (single-reg descriptor-reg) @@ -1894,8 +1896,8 @@ (inst mov bits float)) (descriptor-reg (loadw - bits float sb!vm:single-float-value-slot - sb!vm:other-pointer-type)))) + bits float single-float-value-slot + other-pointer-lowtag)))) (signed-stack (sc-case float (single-reg @@ -1918,14 +1920,14 @@ (with-tn@fp-top(float) (let ((where (make-ea :dword :base ebp-tn :disp (- (* (+ 2 (tn-offset temp)) - word-bytes))))) + n-word-bytes))))) (inst fstd where))) (loadw hi-bits ebp-tn (- (1+ (tn-offset temp))))) (double-stack (loadw hi-bits ebp-tn (- (1+ (tn-offset float))))) (descriptor-reg - (loadw hi-bits float (1+ sb!vm:double-float-value-slot) - sb!vm:other-pointer-type))))) + (loadw hi-bits float (1+ double-float-value-slot) + other-pointer-lowtag))))) (define-vop (double-float-low-bits) (:args (float :scs (double-reg descriptor-reg) @@ -1943,14 +1945,14 @@ (with-tn@fp-top(float) (let ((where (make-ea :dword :base ebp-tn :disp (- (* (+ 2 (tn-offset temp)) - word-bytes))))) + n-word-bytes))))) (inst fstd where))) (loadw lo-bits ebp-tn (- (+ 2 (tn-offset temp))))) (double-stack (loadw lo-bits ebp-tn (- (+ 2 (tn-offset float))))) (descriptor-reg - (loadw lo-bits float sb!vm:double-float-value-slot - sb!vm:other-pointer-type))))) + (loadw lo-bits float double-float-value-slot + other-pointer-lowtag))))) #!+long-float (define-vop (long-float-exp-bits) @@ -1969,21 +1971,21 @@ (with-tn@fp-top(float) (let ((where (make-ea :dword :base ebp-tn :disp (- (* (+ 3 (tn-offset temp)) - word-bytes))))) + n-word-bytes))))) (store-long-float where))) (inst movsx exp-bits (make-ea :word :base ebp-tn - :disp (* (- (1+ (tn-offset temp))) word-bytes)))) + :disp (* (- (1+ (tn-offset temp))) n-word-bytes)))) (long-stack (inst movsx exp-bits (make-ea :word :base ebp-tn - :disp (* (- (1+ (tn-offset float))) word-bytes)))) + :disp (* (- (1+ (tn-offset float))) n-word-bytes)))) (descriptor-reg (inst movsx exp-bits (make-ea :word :base float - :disp (- (* (+ 2 sb!vm:long-float-value-slot) - word-bytes) - sb!vm:other-pointer-type))))))) + :disp (- (* (+ 2 long-float-value-slot) + n-word-bytes) + other-pointer-lowtag))))))) #!+long-float (define-vop (long-float-high-bits) @@ -2002,14 +2004,14 @@ (with-tn@fp-top(float) (let ((where (make-ea :dword :base ebp-tn :disp (- (* (+ 3 (tn-offset temp)) - word-bytes))))) + n-word-bytes))))) (store-long-float where))) (loadw hi-bits ebp-tn (- (+ (tn-offset temp) 2)))) (long-stack (loadw hi-bits ebp-tn (- (+ (tn-offset float) 2)))) (descriptor-reg - (loadw hi-bits float (1+ sb!vm:long-float-value-slot) - sb!vm:other-pointer-type))))) + (loadw hi-bits float (1+ long-float-value-slot) + other-pointer-lowtag))))) #!+long-float (define-vop (long-float-low-bits) @@ -2028,14 +2030,14 @@ (with-tn@fp-top(float) (let ((where (make-ea :dword :base ebp-tn :disp (- (* (+ 3 (tn-offset temp)) - word-bytes))))) + n-word-bytes))))) (store-long-float where))) (loadw lo-bits ebp-tn (- (+ (tn-offset temp) 3)))) (long-stack (loadw lo-bits ebp-tn (- (+ (tn-offset float) 3)))) (descriptor-reg - (loadw lo-bits float sb!vm:long-float-value-slot - sb!vm:other-pointer-type))))) + (loadw lo-bits float long-float-value-slot + other-pointer-lowtag))))) ;;;; float mode hackery @@ -2044,7 +2046,7 @@ (defknown ((setf floating-point-modes)) (float-modes) float-modes) -(defconstant npx-env-size (* 7 sb!vm:word-bytes)) +(defconstant npx-env-size (* 7 n-word-bytes)) (defconstant npx-cw-offset 0) (defconstant npx-sw-offset 4) @@ -2928,12 +2930,6 @@ (:arg-types double-float) (:result-types double-float) (:policy :fast-safe) - ;; FIXME: PENTIUM isn't used on the *FEATURES* list of the CMU CL I based - ;; SBCL on, even when it is running on a Pentium. Find out what's going - ;; on here and see what the proper value should be. (Perhaps just use the - ;; apparently-conservative value of T always?) For more confusion, see also - ;; apparently-reversed-sense test for the FLOG1P-PENTIUM vop below. - (:guard #!+pentium nil #!-pentium t) (:note "inline log1p function") (:ignore temp) (:generator 5 @@ -2987,12 +2983,11 @@ (:arg-types double-float) (:result-types double-float) (:policy :fast-safe) - ;; FIXME: See comments on DEFINE-VOP FLOG1P :GUARD above. - (:guard #!+pentium t #!-pentium nil) + (:guard (member :pentium-style-fyl2xp1 *backend-subfeatures*)) (:note "inline log1p with limited x range function") (:vop-var vop) (:save-p :compute-only) - (:generator 5 + (:generator 4 (note-this-location vop :internal-error) (sc-case x (double-reg