- (define-vop (,(symbolicate 'data-vector-ref/ type))
- (:note "inline array access")
- (:translate data-vector-ref)
- (:policy :fast-safe)
- (:args (object :scs (descriptor-reg))
- (index :scs (unsigned-reg)))
- (:arg-types ,type positive-fixnum)
- (:results (value :scs (any-reg)))
- (:result-types positive-fixnum)
- (:temporary (:scs (non-descriptor-reg) :to (:result 0)) temp result)
- (:generator 20
- (inst srl temp index ,bit-shift)
- (inst sll temp n-fixnum-tag-bits)
- (inst add temp (- (* vector-data-offset n-word-bytes)
- other-pointer-lowtag))
- (inst ld result object temp)
- (inst and temp index ,(1- elements-per-word))
- (inst xor temp ,(1- elements-per-word))
- ,@(unless (= bits 1)
- `((inst sll temp ,(1- (integer-length bits)))))
- (inst srl result temp)
- (inst and result ,(1- (ash 1 bits)))
- (inst sll value result 2)))
- (define-vop (,(symbolicate 'data-vector-ref-c/ type))
- (:translate data-vector-ref)
- (:policy :fast-safe)
- (:args (object :scs (descriptor-reg)))
- (:arg-types ,type (:constant index))
- (:info index)
- (:results (result :scs (unsigned-reg)))
- (:result-types positive-fixnum)
- (:temporary (:scs (non-descriptor-reg)) temp)
- (:generator 15
- (multiple-value-bind (word extra) (floor index ,elements-per-word)
- (setf extra (logxor extra (1- ,elements-per-word)))
- (let ((offset (- (* (+ word vector-data-offset) n-word-bytes)
- other-pointer-lowtag)))
- (cond ((typep offset '(signed-byte 13))
- (inst ld result object offset))
- (t
- (inst li temp offset)
- (inst ld result object temp))))
- (unless (zerop extra)
- (inst srl result
- (logxor (* extra ,bits) ,(1- elements-per-word))))
- (unless (= extra ,(1- elements-per-word))
- (inst and result ,(1- (ash 1 bits)))))))
- (define-vop (,(symbolicate 'data-vector-set/ type))
- (:note "inline array store")
- (:translate data-vector-set)
- (:policy :fast-safe)
- (:args (object :scs (descriptor-reg))
- (index :scs (unsigned-reg) :target shift)
- (value :scs (unsigned-reg zero immediate) :target result))
- (:arg-types ,type positive-fixnum positive-fixnum)
- (:results (result :scs (unsigned-reg)))
- (:result-types positive-fixnum)
- (:temporary (:scs (non-descriptor-reg)) temp old offset)
- (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) shift)
- (:generator 25
- (inst srl offset index ,bit-shift)
- (inst sll offset n-fixnum-tag-bits)
- (inst add offset (- (* vector-data-offset n-word-bytes)
- other-pointer-lowtag))
- (inst ld old object offset)
- (inst and shift index ,(1- elements-per-word))
- (inst xor shift ,(1- elements-per-word))
- ,@(unless (= bits 1)
- `((inst sll shift ,(1- (integer-length bits)))))
- (unless (and (sc-is value immediate)
- (= (tn-value value) ,(1- (ash 1 bits))))
- (inst li temp ,(1- (ash 1 bits)))
- (inst sll temp shift)
- (inst not temp)
- (inst and old temp))
- (unless (sc-is value zero)
- (sc-case value
- (immediate
- (inst li temp (logand (tn-value value) ,(1- (ash 1 bits)))))
- (unsigned-reg
- (inst and temp value ,(1- (ash 1 bits)))))
- (inst sll temp shift)
- (inst or old temp))
- (inst st old object offset)
- (sc-case value
- (immediate
- (inst li result (tn-value value)))
- (t
- (move result value)))))
- (define-vop (,(symbolicate 'data-vector-set-c/ type))
- (:translate data-vector-set)
- (:policy :fast-safe)
- (:args (object :scs (descriptor-reg))
- (value :scs (unsigned-reg zero immediate) :target result))
- (:arg-types ,type
- (:constant index)
- positive-fixnum)
- (:info index)
- (:results (result :scs (unsigned-reg)))
- (:result-types positive-fixnum)
- (:temporary (:scs (non-descriptor-reg)) offset-reg temp old)
- (:generator 20
- (multiple-value-bind (word extra) (floor index ,elements-per-word)
- (let ((offset (- (* (+ word vector-data-offset) n-word-bytes)
- other-pointer-lowtag)))
- (cond ((typep offset '(signed-byte 13))
- (inst ld old object offset))
- (t
- (inst li offset-reg offset)
- (inst ld old object offset-reg)))
- (unless (and (sc-is value immediate)
- (= (tn-value value) ,(1- (ash 1 bits))))
- (cond ((zerop extra)
- (inst sll old ,bits)
- (inst srl old ,bits))
- (t
- (inst li temp
- (lognot (ash ,(1- (ash 1 bits))
- (* (logxor extra
- ,(1- elements-per-word))
- ,bits))))
- (inst and old temp))))
- (sc-case value
- (zero)
- (immediate
- (let ((value (ash (logand (tn-value value)
- ,(1- (ash 1 bits)))
- (* (logxor extra
- ,(1- elements-per-word))
- ,bits))))
- (cond ((typep value '(signed-byte 13))
- (inst or old value))
- (t
- (inst li temp value)
- (inst or old temp)))))
- (unsigned-reg
- (inst sll temp value
- (* (logxor extra ,(1- elements-per-word)) ,bits))
- (inst or old temp)))
- (if (typep offset '(signed-byte 13))
- (inst st old object offset)
- (inst st old object offset-reg)))
- (sc-case value
- (immediate
- (inst li result (tn-value value)))
- (t
- (move result value))))))))))
+ (define-vop (,(symbolicate "DATA-VECTOR-REF/" type))
+ (:note "inline array access")
+ (:translate data-vector-ref)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (index :scs (unsigned-reg)))
+ (:arg-types ,type positive-fixnum)
+ (:results (value :scs (any-reg)))
+ (:result-types positive-fixnum)
+ (:temporary (:scs (non-descriptor-reg) :to (:result 0)) temp result)
+ (:generator 20
+ (inst srl temp index ,bit-shift)
+ (inst sll temp n-fixnum-tag-bits)
+ (inst add temp (- (* vector-data-offset n-word-bytes)
+ other-pointer-lowtag))
+ (inst ld result object temp)
+ (inst and temp index ,(1- elements-per-word))
+ (inst xor temp ,(1- elements-per-word))
+ ,@(unless (= bits 1)
+ `((inst sll temp ,(1- (integer-length bits)))))
+ (inst srl result temp)
+ (inst and result ,(1- (ash 1 bits)))
+ (inst sll value result 2)))
+ (define-vop (,(symbolicate "DATA-VECTOR-REF-C/" type))
+ (:translate data-vector-ref)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg)))
+ (:arg-types ,type (:constant index))
+ (:info index)
+ (:results (result :scs (unsigned-reg)))
+ (:result-types positive-fixnum)
+ (:temporary (:scs (non-descriptor-reg)) temp)
+ (:generator 15
+ (multiple-value-bind (word extra)
+ (floor index ,elements-per-word)
+ (setf extra (logxor extra (1- ,elements-per-word)))
+ (let ((offset (- (* (+ word vector-data-offset) n-word-bytes)
+ other-pointer-lowtag)))
+ (cond ((typep offset '(signed-byte 13))
+ (inst ld result object offset))
+ (t
+ (inst li temp offset)
+ (inst ld result object temp))))
+ (unless (zerop extra)
+ (inst srl result (* extra ,bits)))
+ (unless (= extra ,(1- elements-per-word))
+ (inst and result ,(1- (ash 1 bits)))))))
+ (define-vop (,(symbolicate "DATA-VECTOR-SET/" type))
+ (:note "inline array store")
+ (:translate data-vector-set)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (index :scs (unsigned-reg) :target shift)
+ (value :scs (unsigned-reg zero immediate) :target result))
+ (:arg-types ,type positive-fixnum positive-fixnum)
+ (:results (result :scs (unsigned-reg)))
+ (:result-types positive-fixnum)
+ (:temporary (:scs (non-descriptor-reg)) temp old offset)
+ (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) shift)
+ (:generator 25
+ (inst srl offset index ,bit-shift)
+ (inst sll offset n-fixnum-tag-bits)
+ (inst add offset (- (* vector-data-offset n-word-bytes)
+ other-pointer-lowtag))
+ (inst ld old object offset)
+ (inst and shift index ,(1- elements-per-word))
+ (inst xor shift ,(1- elements-per-word))
+ ,@(unless (= bits 1)
+ `((inst sll shift ,(1- (integer-length bits)))))
+ (unless (and (sc-is value immediate)
+ (= (tn-value value) ,(1- (ash 1 bits))))
+ (inst li temp ,(1- (ash 1 bits)))
+ (inst sll temp shift)
+ (inst not temp)
+ (inst and old temp))
+ (unless (sc-is value zero)
+ (sc-case value
+ (immediate
+ (inst li temp (logand (tn-value value) ,(1- (ash 1 bits)))))
+ (unsigned-reg
+ (inst and temp value ,(1- (ash 1 bits)))))
+ (inst sll temp shift)
+ (inst or old temp))
+ (inst st old object offset)
+ (sc-case value
+ (immediate
+ (inst li result (tn-value value)))
+ (t
+ (move result value)))))
+ (define-vop (,(symbolicate "DATA-VECTOR-SET-C/" type))
+ (:translate data-vector-set)
+ (:policy :fast-safe)
+ (:args (object :scs (descriptor-reg))
+ (value :scs (unsigned-reg zero immediate) :target result))
+ (:arg-types ,type
+ (:constant index)
+ positive-fixnum)
+ (:info index)
+ (:results (result :scs (unsigned-reg)))
+ (:result-types positive-fixnum)
+ (:temporary (:scs (non-descriptor-reg)) offset-reg temp old)
+ (:generator 20
+ (multiple-value-bind (word extra) (floor index ,elements-per-word)
+ (let ((offset (- (* (+ word vector-data-offset) n-word-bytes)
+ other-pointer-lowtag)))
+ (cond ((typep offset '(signed-byte 13))
+ (inst ld old object offset))
+ (t
+ (inst li offset-reg offset)
+ (inst ld old object offset-reg)))
+ (unless (and (sc-is value immediate)
+ (= (tn-value value) ,(1- (ash 1 bits))))
+ (cond ((zerop extra)
+ (inst sll old ,bits)
+ (inst srl old ,bits))
+ (t
+ (inst li temp
+ (lognot (ash ,(1- (ash 1 bits))
+ (* (logxor extra
+ ,(1- elements-per-word))
+ ,bits))))
+ (inst and old temp))))
+ (sc-case value
+ (zero)
+ (immediate
+ (let ((value (ash (logand (tn-value value)
+ ,(1- (ash 1 bits)))
+ (* (logxor extra
+ ,(1- elements-per-word))
+ ,bits))))
+ (cond ((typep value '(signed-byte 13))
+ (inst or old value))
+ (t
+ (inst li temp value)
+ (inst or old temp)))))
+ (unsigned-reg
+ (inst sll temp value
+ (* (logxor extra ,(1- elements-per-word)) ,bits))
+ (inst or old temp)))
+ (if (typep offset '(signed-byte 13))
+ (inst st old object offset)
+ (inst st old object offset-reg)))
+ (sc-case value
+ (immediate
+ (inst li result (tn-value value)))
+ (t
+ (move result value))))))))))