X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fx86%2Farray.lisp;h=2cd1d081e807cb12adaa348726b1f39d050671a9;hb=c5159b9f0da46023e65b65a82c911d8d9816dc3e;hp=f8c3c7037cadc2b159634ad175f5939fba2ddc26;hpb=d8edba3a4e96a718d9eab64d2cbb0b70d0946546;p=sbcl.git diff --git a/src/compiler/x86/array.lisp b/src/compiler/x86/array.lisp index f8c3c70..2cd1d08 100644 --- a/src/compiler/x86/array.lisp +++ b/src/compiler/x86/array.lisp @@ -40,24 +40,16 @@ (storew header result 0 other-pointer-lowtag)))) ;;;; additional accessors and setters for the array header - -(defknown sb!impl::%array-dimension (t index) index - (flushable)) -(defknown sb!impl::%set-array-dimension (t index index) index - ()) - (define-full-reffer %array-dimension * array-dimensions-offset other-pointer-lowtag - (any-reg) positive-fixnum sb!impl::%array-dimension) + (any-reg) positive-fixnum sb!kernel:%array-dimension) (define-full-setter %set-array-dimension * array-dimensions-offset other-pointer-lowtag - (any-reg) positive-fixnum sb!impl::%set-array-dimension) - -(defknown sb!impl::%array-rank (t) index (flushable)) + (any-reg) positive-fixnum sb!kernel:%set-array-dimension) (define-vop (array-rank-vop) - (:translate sb!impl::%array-rank) + (:translate sb!kernel:%array-rank) (:policy :fast-safe) (:args (x :scs (descriptor-reg))) (:results (res :scs (unsigned-reg))) @@ -112,10 +104,10 @@ (:translate %check-bound) (:policy :fast-safe) (:args (array :scs (descriptor-reg)) - (bound :scs (any-reg descriptor-reg)) - (index :scs (any-reg descriptor-reg #+nil immediate) :target result)) + (bound :scs (any-reg)) + (index :scs (any-reg #+nil immediate) :target result)) (:arg-types * positive-fixnum tagged-num) - (:results (result :scs (any-reg descriptor-reg))) + (:results (result :scs (any-reg))) (:result-types positive-fixnum) (:vop-var vop) (:save-p :compute-only) @@ -160,7 +152,7 @@ ;;;; bit, 2-bit, and 4-bit vectors (macrolet ((def-small-data-vector-frobs (type bits) - (let* ((elements-per-word (floor sb!vm:n-word-bits bits)) + (let* ((elements-per-word (floor n-word-bits bits)) (bit-shift (1- (integer-length elements-per-word)))) `(progn (define-vop (,(symbolicate 'data-vector-ref/ type)) @@ -268,7 +260,7 @@ (mask ,(1- (ash 1 bits))) (shift (* extra ,bits))) (unless (= value mask) - (inst and old (lognot (ash mask shift)))) + (inst and old (ldb (byte 32 0) (lognot (ash mask shift))))) (unless (zerop value) (inst or old (ash value shift))))) (unsigned-reg @@ -307,9 +299,9 @@ (:generator 5 (with-empty-tn@fp-top(value) (inst fld (make-ea :dword :base object :index index :scale 1 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag)))))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag)))))) (define-vop (data-vector-ref-c/simple-array-single-float) (:note "inline array access") @@ -323,10 +315,10 @@ (:generator 4 (with-empty-tn@fp-top(value) (inst fld (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 4 index)) - sb!vm:other-pointer-lowtag)))))) + other-pointer-lowtag)))))) (define-vop (data-vector-set/simple-array-single-float) (:note "inline array store") @@ -342,9 +334,9 @@ (cond ((zerop (tn-offset value)) ;; Value is in ST0. (inst fst (make-ea :dword :base object :index index :scale 1 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (unless (zerop (tn-offset result)) ;; Value is in ST0 but not result. (inst fst result))) @@ -352,9 +344,9 @@ ;; Value is not in ST0. (inst fxch value) (inst fst (make-ea :dword :base object :index index :scale 1 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (cond ((zerop (tn-offset result)) ;; The result is in ST0. (inst fst value)) @@ -379,10 +371,10 @@ (cond ((zerop (tn-offset value)) ;; Value is in ST0. (inst fst (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 4 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (zerop (tn-offset result)) ;; Value is in ST0 but not result. (inst fst result))) @@ -390,10 +382,10 @@ ;; Value is not in ST0. (inst fxch value) (inst fst (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 4 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (cond ((zerop (tn-offset result)) ;; The result is in ST0. (inst fst value)) @@ -415,9 +407,9 @@ (:generator 7 (with-empty-tn@fp-top(value) (inst fldd (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag)))))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag)))))) (define-vop (data-vector-ref-c/simple-array-double-float) (:note "inline array access") @@ -431,10 +423,10 @@ (:generator 6 (with-empty-tn@fp-top(value) (inst fldd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag)))))) + other-pointer-lowtag)))))) (define-vop (data-vector-set/simple-array-double-float) (:note "inline array store") @@ -450,9 +442,9 @@ (cond ((zerop (tn-offset value)) ;; Value is in ST0. (inst fstd (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (unless (zerop (tn-offset result)) ;; Value is in ST0 but not result. (inst fstd result))) @@ -460,9 +452,9 @@ ;; Value is not in ST0. (inst fxch value) (inst fstd (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (cond ((zerop (tn-offset result)) ;; The result is in ST0. (inst fstd value)) @@ -487,10 +479,10 @@ (cond ((zerop (tn-offset value)) ;; Value is in ST0. (inst fstd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (zerop (tn-offset result)) ;; Value is in ST0 but not result. (inst fstd result))) @@ -498,10 +490,10 @@ ;; Value is not in ST0. (inst fxch value) (inst fstd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (cond ((zerop (tn-offset result)) ;; The result is in ST0. (inst fstd value)) @@ -511,122 +503,7 @@ (inst fstd result)) (inst fxch value))))))) -#!+long-float -(define-vop (data-vector-ref/simple-array-long-float) - (:note "inline array access") - (:translate data-vector-ref) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg) :to :result) - (index :scs (any-reg))) - (:arg-types simple-array-long-float positive-fixnum) - (:temporary (:sc any-reg :from :eval :to :result) temp) - (:results (value :scs (long-reg))) - (:result-types long-float) - (:generator 7 - ;; temp = 3 * index - (inst lea temp (make-ea :dword :base index :index index :scale 2)) - (with-empty-tn@fp-top(value) - (inst fldl (make-ea :dword :base object :index temp :scale 1 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag)))))) -#!+long-float -(define-vop (data-vector-ref-c/simple-array-long-float) - (:note "inline array access") - (:translate data-vector-ref) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg))) - (:info index) - (:arg-types simple-array-long-float (:constant (signed-byte 30))) - (:results (value :scs (long-reg))) - (:result-types long-float) - (:generator 6 - (with-empty-tn@fp-top(value) - (inst fldl (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 12 index)) - sb!vm:other-pointer-lowtag)))))) - -#!+long-float -(define-vop (data-vector-set/simple-array-long-float) - (:note "inline array store") - (:translate data-vector-set) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg) :to :result) - (index :scs (any-reg)) - (value :scs (long-reg) :target result)) - (:arg-types simple-array-long-float positive-fixnum long-float) - (:temporary (:sc any-reg :from (:argument 1) :to :result) temp) - (:results (result :scs (long-reg))) - (:result-types long-float) - (:generator 20 - ;; temp = 3 * index - (inst lea temp (make-ea :dword :base index :index index :scale 2)) - (cond ((zerop (tn-offset value)) - ;; Value is in ST0. - (store-long-float - (make-ea :dword :base object :index temp :scale 1 - :disp (- (* sb!vm:vector-data-offset sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) - (unless (zerop (tn-offset result)) - ;; Value is in ST0 but not result. - (inst fstd result))) - (t - ;; Value is not in ST0. - (inst fxch value) - (store-long-float - (make-ea :dword :base object :index temp :scale 1 - :disp (- (* sb!vm:vector-data-offset sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) - (cond ((zerop (tn-offset result)) - ;; The result is in ST0. - (inst fstd value)) - (t - ;; Neither value or result are in ST0 - (unless (location= value result) - (inst fstd result)) - (inst fxch value))))))) - -#!+long-float -(define-vop (data-vector-set-c/simple-array-long-float) - (:note "inline array store") - (:translate data-vector-set) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg)) - (value :scs (long-reg) :target result)) - (:info index) - (:arg-types simple-array-long-float (:constant (signed-byte 30)) long-float) - (:results (result :scs (long-reg))) - (:result-types long-float) - (:generator 19 - (cond ((zerop (tn-offset value)) - ;; Value is in ST0. - (store-long-float (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 12 index)) - sb!vm:other-pointer-lowtag))) - (unless (zerop (tn-offset result)) - ;; Value is in ST0 but not result. - (inst fstd result))) - (t - ;; Value is not in ST0. - (inst fxch value) - (store-long-float (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 12 index)) - sb!vm:other-pointer-lowtag))) - (cond ((zerop (tn-offset result)) - ;; The result is in ST0. - (inst fstd value)) - (t - ;; Neither value or result are in ST0 - (unless (location= value result) - (inst fstd result)) - (inst fxch value))))))) ;;; complex float variants @@ -643,15 +520,15 @@ (let ((real-tn (complex-single-reg-real-tn value))) (with-empty-tn@fp-top (real-tn) (inst fld (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))))) (let ((imag-tn (complex-single-reg-imag-tn value))) (with-empty-tn@fp-top (imag-tn) (inst fld (make-ea :dword :base object :index index :scale 2 - :disp (- (* (1+ sb!vm:vector-data-offset) - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))))))) + :disp (- (* (1+ vector-data-offset) + n-word-bytes) + other-pointer-lowtag))))))) (define-vop (data-vector-ref-c/simple-array-complex-single-float) (:note "inline array access") @@ -666,17 +543,17 @@ (let ((real-tn (complex-single-reg-real-tn value))) (with-empty-tn@fp-top (real-tn) (inst fld (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag))))) + other-pointer-lowtag))))) (let ((imag-tn (complex-single-reg-imag-tn value))) (with-empty-tn@fp-top (imag-tn) (inst fld (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index) 4) - sb!vm:other-pointer-lowtag))))))) + other-pointer-lowtag))))))) (define-vop (data-vector-set/simple-array-complex-single-float) (:note "inline array store") @@ -695,9 +572,9 @@ (cond ((zerop (tn-offset value-real)) ;; Value is in ST0. (inst fst (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (unless (zerop (tn-offset result-real)) ;; Value is in ST0 but not result. (inst fst result-real))) @@ -705,9 +582,9 @@ ;; Value is not in ST0. (inst fxch value-real) (inst fst (make-ea :dword :base object :index index :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (cond ((zerop (tn-offset result-real)) ;; The result is in ST0. (inst fst value-real)) @@ -720,10 +597,10 @@ (result-imag (complex-single-reg-imag-tn result))) (inst fxch value-imag) (inst fst (make-ea :dword :base object :index index :scale 2 - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) 4) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (location= value-imag result-imag) (inst fst result-imag)) (inst fxch value-imag)))) @@ -745,10 +622,10 @@ (cond ((zerop (tn-offset value-real)) ;; Value is in ST0. (inst fst (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (zerop (tn-offset result-real)) ;; Value is in ST0 but not result. (inst fst result-real))) @@ -756,10 +633,10 @@ ;; Value is not in ST0. (inst fxch value-real) (inst fst (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (cond ((zerop (tn-offset result-real)) ;; The result is in ST0. (inst fst value-real)) @@ -772,10 +649,10 @@ (result-imag (complex-single-reg-imag-tn result))) (inst fxch value-imag) (inst fst (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 8 index) 4) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (location= value-imag result-imag) (inst fst result-imag)) (inst fxch value-imag)))) @@ -794,16 +671,16 @@ (let ((real-tn (complex-double-reg-real-tn value))) (with-empty-tn@fp-top (real-tn) (inst fldd (make-ea :dword :base object :index index :scale 4 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))))) (let ((imag-tn (complex-double-reg-imag-tn value))) (with-empty-tn@fp-top (imag-tn) (inst fldd (make-ea :dword :base object :index index :scale 4 - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) 8) - sb!vm:other-pointer-lowtag))))))) + other-pointer-lowtag))))))) (define-vop (data-vector-ref-c/simple-array-complex-double-float) (:note "inline array access") @@ -818,17 +695,17 @@ (let ((real-tn (complex-double-reg-real-tn value))) (with-empty-tn@fp-top (real-tn) (inst fldd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 16 index)) - sb!vm:other-pointer-lowtag))))) + other-pointer-lowtag))))) (let ((imag-tn (complex-double-reg-imag-tn value))) (with-empty-tn@fp-top (imag-tn) (inst fldd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 16 index) 8) - sb!vm:other-pointer-lowtag))))))) + other-pointer-lowtag))))))) (define-vop (data-vector-set/simple-array-complex-double-float) (:note "inline array store") @@ -847,9 +724,9 @@ (cond ((zerop (tn-offset value-real)) ;; Value is in ST0. (inst fstd (make-ea :dword :base object :index index :scale 4 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (unless (zerop (tn-offset result-real)) ;; Value is in ST0 but not result. (inst fstd result-real))) @@ -857,9 +734,9 @@ ;; Value is not in ST0. (inst fxch value-real) (inst fstd (make-ea :dword :base object :index index :scale 4 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) + :disp (- (* vector-data-offset + n-word-bytes) + other-pointer-lowtag))) (cond ((zerop (tn-offset result-real)) ;; The result is in ST0. (inst fstd value-real)) @@ -872,10 +749,10 @@ (result-imag (complex-double-reg-imag-tn result))) (inst fxch value-imag) (inst fstd (make-ea :dword :base object :index index :scale 4 - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) 8) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (location= value-imag result-imag) (inst fstd result-imag)) (inst fxch value-imag)))) @@ -897,10 +774,10 @@ (cond ((zerop (tn-offset value-real)) ;; Value is in ST0. (inst fstd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 16 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (zerop (tn-offset result-real)) ;; Value is in ST0 but not result. (inst fstd result-real))) @@ -908,10 +785,10 @@ ;; Value is not in ST0. (inst fxch value-real) (inst fstd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 16 index)) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (cond ((zerop (tn-offset result-real)) ;; The result is in ST0. (inst fstd value-real)) @@ -924,182 +801,16 @@ (result-imag (complex-double-reg-imag-tn result))) (inst fxch value-imag) (inst fstd (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) + :disp (- (+ (* vector-data-offset + n-word-bytes) (* 16 index) 8) - sb!vm:other-pointer-lowtag))) + other-pointer-lowtag))) (unless (location= value-imag result-imag) (inst fstd result-imag)) (inst fxch value-imag)))) -#!+long-float -(define-vop (data-vector-ref/simple-array-complex-long-float) - (:note "inline array access") - (:translate data-vector-ref) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg) :to :result) - (index :scs (any-reg))) - (:arg-types simple-array-complex-long-float positive-fixnum) - (:temporary (:sc any-reg :from :eval :to :result) temp) - (:results (value :scs (complex-long-reg))) - (:result-types complex-long-float) - (:generator 7 - ;; temp = 3 * index - (inst lea temp (make-ea :dword :base index :index index :scale 2)) - (let ((real-tn (complex-long-reg-real-tn value))) - (with-empty-tn@fp-top (real-tn) - (inst fldl (make-ea :dword :base object :index temp :scale 2 - :disp (- (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))))) - (let ((imag-tn (complex-long-reg-imag-tn value))) - (with-empty-tn@fp-top (imag-tn) - (inst fldl (make-ea :dword :base object :index temp :scale 2 - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - 12) - sb!vm:other-pointer-lowtag))))))) - -#!+long-float -(define-vop (data-vector-ref-c/simple-array-complex-long-float) - (:note "inline array access") - (:translate data-vector-ref) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg))) - (:info index) - (:arg-types simple-array-complex-long-float (:constant (signed-byte 30))) - (:results (value :scs (complex-long-reg))) - (:result-types complex-long-float) - (:generator 6 - (let ((real-tn (complex-long-reg-real-tn value))) - (with-empty-tn@fp-top (real-tn) - (inst fldl (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 24 index)) - sb!vm:other-pointer-lowtag))))) - (let ((imag-tn (complex-long-reg-imag-tn value))) - (with-empty-tn@fp-top (imag-tn) - (inst fldl (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 24 index) 12) - sb!vm:other-pointer-lowtag))))))) -#!+long-float -(define-vop (data-vector-set/simple-array-complex-long-float) - (:note "inline array store") - (:translate data-vector-set) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg) :to :result) - (index :scs (any-reg)) - (value :scs (complex-long-reg) :target result)) - (:arg-types simple-array-complex-long-float positive-fixnum - complex-long-float) - (:temporary (:sc any-reg :from (:argument 1) :to :result) temp) - (:results (result :scs (complex-long-reg))) - (:result-types complex-long-float) - (:generator 20 - ;; temp = 3 * index - (inst lea temp (make-ea :dword :base index :index index :scale 2)) - (let ((value-real (complex-long-reg-real-tn value)) - (result-real (complex-long-reg-real-tn result))) - (cond ((zerop (tn-offset value-real)) - ;; Value is in ST0. - (store-long-float - (make-ea :dword :base object :index temp :scale 2 - :disp (- (* sb!vm:vector-data-offset sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) - (unless (zerop (tn-offset result-real)) - ;; Value is in ST0 but not result. - (inst fstd result-real))) - (t - ;; Value is not in ST0. - (inst fxch value-real) - (store-long-float - (make-ea :dword :base object :index temp :scale 2 - :disp (- (* sb!vm:vector-data-offset sb!vm:n-word-bytes) - sb!vm:other-pointer-lowtag))) - (cond ((zerop (tn-offset result-real)) - ;; The result is in ST0. - (inst fstd value-real)) - (t - ;; Neither value or result are in ST0 - (unless (location= value-real result-real) - (inst fstd result-real)) - (inst fxch value-real)))))) - (let ((value-imag (complex-long-reg-imag-tn value)) - (result-imag (complex-long-reg-imag-tn result))) - (inst fxch value-imag) - (store-long-float - (make-ea :dword :base object :index temp :scale 2 - :disp (- (+ (* sb!vm:vector-data-offset sb!vm:n-word-bytes) 12) - sb!vm:other-pointer-lowtag))) - (unless (location= value-imag result-imag) - (inst fstd result-imag)) - (inst fxch value-imag)))) - -#!+long-float -(define-vop (data-vector-set-c/simple-array-complex-long-float) - (:note "inline array store") - (:translate data-vector-set) - (:policy :fast-safe) - (:args (object :scs (descriptor-reg)) - (value :scs (complex-long-reg) :target result)) - (:info index) - (:arg-types simple-array-complex-long-float (:constant (signed-byte 30)) - complex-long-float) - (:results (result :scs (complex-long-reg))) - (:result-types complex-long-float) - (:generator 19 - (let ((value-real (complex-long-reg-real-tn value)) - (result-real (complex-long-reg-real-tn result))) - (cond ((zerop (tn-offset value-real)) - ;; Value is in ST0. - (store-long-float - (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 24 index)) - sb!vm:other-pointer-lowtag))) - (unless (zerop (tn-offset result-real)) - ;; Value is in ST0 but not result. - (inst fstd result-real))) - (t - ;; Value is not in ST0. - (inst fxch value-real) - (store-long-float - (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - (* 24 index)) - sb!vm:other-pointer-lowtag))) - (cond ((zerop (tn-offset result-real)) - ;; The result is in ST0. - (inst fstd value-real)) - (t - ;; Neither value or result are in ST0 - (unless (location= value-real result-real) - (inst fstd result-real)) - (inst fxch value-real)))))) - (let ((value-imag (complex-long-reg-imag-tn value)) - (result-imag (complex-long-reg-imag-tn result))) - (inst fxch value-imag) - (store-long-float - (make-ea :dword :base object - :disp (- (+ (* sb!vm:vector-data-offset - sb!vm:n-word-bytes) - ;; FIXME: There are so many of these bare constants - ;; (24, 12..) in the LONG-FLOAT code that it's - ;; ridiculous. I should probably just delete it all - ;; instead of appearing to flirt with supporting - ;; this maintenance nightmare. - (* 24 index) 12) - sb!vm:other-pointer-lowtag))) - (unless (location= value-imag result-imag) - (inst fstd result-imag)) - (inst fxch value-imag)))) ;;; unsigned-byte-8 (macrolet ((define-data-vector-frobs (ptype) @@ -1247,14 +958,87 @@ ;;; simple-string +#!+sb-unicode +(progn +(define-vop (data-vector-ref/simple-base-string) + (:translate data-vector-ref) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg)) + (index :scs (unsigned-reg))) + (:arg-types simple-base-string positive-fixnum) + (:results (value :scs (character-reg))) + (:result-types character) + (:generator 5 + (inst movzx value + (make-ea :byte :base object :index index :scale 1 + :disp (- (* vector-data-offset n-word-bytes) + other-pointer-lowtag))))) + +(define-vop (data-vector-ref-c/simple-base-string) + (:translate data-vector-ref) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg))) + (:info index) + (:arg-types simple-base-string (:constant (signed-byte 30))) + (:results (value :scs (character-reg))) + (:result-types character) + (:generator 4 + (inst movzx value + (make-ea :byte :base object + :disp (- (+ (* vector-data-offset n-word-bytes) index) + other-pointer-lowtag))))) + +(define-vop (data-vector-set/simple-base-string) + (:translate data-vector-set) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg) :to (:eval 0)) + (index :scs (unsigned-reg) :to (:eval 0)) + (value :scs (character-reg) :target eax)) + (:arg-types simple-base-string positive-fixnum character) + (:temporary (:sc character-reg :offset eax-offset :target result + :from (:argument 2) :to (:result 0)) + eax) + (:results (result :scs (character-reg))) + (:result-types character) + (:generator 5 + (move eax value) + (inst mov (make-ea :byte :base object :index index :scale 1 + :disp (- (* vector-data-offset n-word-bytes) + other-pointer-lowtag)) + al-tn) + (move result eax))) + +(define-vop (data-vector-set-c/simple-base-string) + (:translate data-vector-set) + (:policy :fast-safe) + (:args (object :scs (descriptor-reg) :to (:eval 0)) + (value :scs (character-reg))) + (:info index) + (:arg-types simple-base-string (:constant (signed-byte 30)) character) + (:temporary (:sc unsigned-reg :offset eax-offset :target result + :from (:argument 1) :to (:result 0)) + eax) + (:results (result :scs (character-reg))) + (:result-types character) + (:generator 4 + (move eax value) + (inst mov (make-ea :byte :base object + :disp (- (+ (* vector-data-offset n-word-bytes) index) + other-pointer-lowtag)) + al-tn) + (move result eax))) +) ; PROGN + +#!-sb-unicode +(progn (define-vop (data-vector-ref/simple-base-string) (:translate data-vector-ref) (:policy :fast-safe) (:args (object :scs (descriptor-reg)) (index :scs (unsigned-reg))) (:arg-types simple-base-string positive-fixnum) - (:results (value :scs (base-char-reg))) - (:result-types base-char) + (:results (value :scs (character-reg))) + (:result-types character) (:generator 5 (inst mov value (make-ea :byte :base object :index index :scale 1 @@ -1267,8 +1051,8 @@ (:args (object :scs (descriptor-reg))) (:info index) (:arg-types simple-base-string (:constant (signed-byte 30))) - (:results (value :scs (base-char-reg))) - (:result-types base-char) + (:results (value :scs (character-reg))) + (:result-types character) (:generator 4 (inst mov value (make-ea :byte :base object @@ -1280,10 +1064,10 @@ (:policy :fast-safe) (:args (object :scs (descriptor-reg) :to (:eval 0)) (index :scs (unsigned-reg) :to (:eval 0)) - (value :scs (base-char-reg) :target result)) - (:arg-types simple-base-string positive-fixnum base-char) - (:results (result :scs (base-char-reg))) - (:result-types base-char) + (value :scs (character-reg) :target result)) + (:arg-types simple-base-string positive-fixnum character) + (:results (result :scs (character-reg))) + (:result-types character) (:generator 5 (inst mov (make-ea :byte :base object :index index :scale 1 :disp (- (* vector-data-offset n-word-bytes) @@ -1291,21 +1075,31 @@ value) (move result value))) -(define-vop (data-vector-set/simple-base-string-c) +(define-vop (data-vector-set-c/simple-base-string) (:translate data-vector-set) (:policy :fast-safe) (:args (object :scs (descriptor-reg) :to (:eval 0)) - (value :scs (base-char-reg))) + (value :scs (character-reg))) (:info index) - (:arg-types simple-base-string (:constant (signed-byte 30)) base-char) - (:results (result :scs (base-char-reg))) - (:result-types base-char) + (:arg-types simple-base-string (:constant (signed-byte 30)) character) + (:results (result :scs (character-reg))) + (:result-types character) (:generator 4 (inst mov (make-ea :byte :base object :disp (- (+ (* vector-data-offset n-word-bytes) index) other-pointer-lowtag)) value) (move result value))) +) ; PROGN + +#!+sb-unicode +(define-full-reffer data-vector-ref/simple-character-string + simple-character-string vector-data-offset other-pointer-lowtag + (character-reg) character data-vector-ref) +#!+sb-unicode +(define-full-setter data-vector-set/simple-character-string + simple-character-string vector-data-offset other-pointer-lowtag + (character-reg) character data-vector-set) ;;; signed-byte-8 @@ -1455,107 +1249,67 @@ ;;; data is an unsigned-32 vector). (define-vop (raw-ref-single data-vector-ref/simple-array-single-float) (:translate %raw-ref-single) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) + (:arg-types sb!c::raw-vector positive-fixnum)) (define-vop (raw-ref-single-c data-vector-ref-c/simple-array-single-float) (:translate %raw-ref-single) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)))) (define-vop (raw-set-single data-vector-set/simple-array-single-float) (:translate %raw-set-single) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum single-float)) + (:arg-types sb!c::raw-vector positive-fixnum single-float)) (define-vop (raw-set-single-c data-vector-set-c/simple-array-single-float) (:translate %raw-set-single) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) - single-float)) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)) single-float)) (define-vop (raw-ref-double data-vector-ref/simple-array-double-float) (:translate %raw-ref-double) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) + (:arg-types sb!c::raw-vector positive-fixnum)) (define-vop (raw-ref-double-c data-vector-ref-c/simple-array-double-float) (:translate %raw-ref-double) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)))) (define-vop (raw-set-double data-vector-set/simple-array-double-float) (:translate %raw-set-double) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum double-float)) + (:arg-types sb!c::raw-vector positive-fixnum double-float)) (define-vop (raw-set-double-c data-vector-set-c/simple-array-double-float) (:translate %raw-set-double) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) - double-float)) -#!+long-float -(define-vop (raw-ref-long data-vector-ref/simple-array-long-float) - (:translate %raw-ref-long) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) -#!+long-float -(define-vop (raw-ref-long-c data-vector-ref-c/simple-array-long-float) - (:translate %raw-ref-long) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) -#!+long-float -(define-vop (raw-set-double data-vector-set/simple-array-long-float) - (:translate %raw-set-long) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum long-float)) -#!+long-float -(define-vop (raw-set-long-c data-vector-set-c/simple-array-long-float) - (:translate %raw-set-long) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) - long-float)) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)) double-float)) + ;;;; complex-float raw structure slot accessors (define-vop (raw-ref-complex-single data-vector-ref/simple-array-complex-single-float) (:translate %raw-ref-complex-single) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) + (:arg-types sb!c::raw-vector positive-fixnum)) (define-vop (raw-ref-complex-single-c data-vector-ref-c/simple-array-complex-single-float) (:translate %raw-ref-complex-single) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)))) (define-vop (raw-set-complex-single data-vector-set/simple-array-complex-single-float) (:translate %raw-set-complex-single) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum complex-single-float)) + (:arg-types sb!c::raw-vector positive-fixnum complex-single-float)) (define-vop (raw-set-complex-single-c data-vector-set-c/simple-array-complex-single-float) (:translate %raw-set-complex-single) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)) complex-single-float)) (define-vop (raw-ref-complex-double data-vector-ref/simple-array-complex-double-float) (:translate %raw-ref-complex-double) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) + (:arg-types sb!c::raw-vector positive-fixnum)) (define-vop (raw-ref-complex-double-c data-vector-ref-c/simple-array-complex-double-float) (:translate %raw-ref-complex-double) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)))) (define-vop (raw-set-complex-double data-vector-set/simple-array-complex-double-float) (:translate %raw-set-complex-double) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum - complex-double-float)) + (:arg-types sb!c::raw-vector positive-fixnum complex-double-float)) (define-vop (raw-set-complex-double-c data-vector-set-c/simple-array-complex-double-float) (:translate %raw-set-complex-double) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) + (:arg-types sb!c::raw-vector (:constant (signed-byte 30)) complex-double-float)) -#!+long-float -(define-vop (raw-ref-complex-long - data-vector-ref/simple-array-complex-long-float) - (:translate %raw-ref-complex-long) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum)) -#!+long-float -(define-vop (raw-ref-complex-long-c - data-vector-ref-c/simple-array-complex-long-float) - (:translate %raw-ref-complex-long) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)))) -#!+long-float -(define-vop (raw-set-complex-long - data-vector-set/simple-array-complex-long-float) - (:translate %raw-set-complex-long) - (:arg-types simple-array-unsigned-byte-32 positive-fixnum - complex-long-float)) -#!+long-float -(define-vop (raw-set-complex-long-c - data-vector-set-c/simple-array-complex-long-float) - (:translate %raw-set-complex-long) - (:arg-types simple-array-unsigned-byte-32 (:constant (signed-byte 30)) - complex-long-float)) + ;;; These vops are useful for accessing the bits of a vector ;;; irrespective of what type of vector it is.