0.9.17.8:
[sbcl.git] / src / compiler / ppc / cell.lisp
index d1dc086..553dfe8 100644 (file)
@@ -24,7 +24,7 @@
 
 (define-vop (set-slot)
   (:args (object :scs (descriptor-reg))
-        (value :scs (descriptor-reg any-reg)))
+         (value :scs (descriptor-reg any-reg)))
   (:info name offset lowtag)
   (:ignore name)
   (:results)
@@ -91,7 +91,7 @@
     ;; it is a fixnum.  The lowtag selection magic that is required to
     ;; ensure this is explained in the comment in objdef.lisp
     (loadw res symbol symbol-hash-slot other-pointer-lowtag)
-    (inst clrrwi res res (1- n-lowtag-bits))))
+    (inst clrrwi res res n-fixnum-tag-bits)))
 \f
 ;;;; Fdefinition (fdefn) objects.
 
   (:policy :fast-safe)
   (:translate (setf fdefn-fun))
   (:args (function :scs (descriptor-reg) :target result)
-        (fdefn :scs (descriptor-reg)))
+         (fdefn :scs (descriptor-reg)))
   (:temporary (:scs (interior-reg)) lip)
   (:temporary (:scs (non-descriptor-reg)) type)
   (:results (result :scs (descriptor-reg)))
       (inst cmpwi type simple-fun-header-widetag)
       ;;(inst mr lip function)
       (inst addi lip function
-           (- (ash simple-fun-code-offset word-shift) fun-pointer-lowtag))
+            (- (ash simple-fun-code-offset word-shift) fun-pointer-lowtag))
       (inst beq normal-fn)
       (inst lr lip  (make-fixup "closure_tramp" :foreign))
       (emit-label normal-fn)
 
 (define-vop (bind)
   (:args (val :scs (any-reg descriptor-reg))
-        (symbol :scs (descriptor-reg)))
+         (symbol :scs (descriptor-reg)))
   (:temporary (:scs (descriptor-reg)) temp)
   (:generator 5
     (loadw temp symbol symbol-value-slot other-pointer-lowtag)
     (loadw symbol bsp-tn (- binding-symbol-slot binding-size))
     (loadw value bsp-tn (- binding-value-slot binding-size))
     (storew value symbol symbol-value-slot other-pointer-lowtag)
+    (storew zero-tn bsp-tn (- binding-value-slot binding-size))
     (storew zero-tn bsp-tn (- binding-symbol-slot binding-size))
     (inst subi bsp-tn bsp-tn (* 2 n-word-bytes))))
 
   (:temporary (:scs (descriptor-reg)) symbol value)
   (:generator 0
     (let ((loop (gen-label))
-         (skip (gen-label))
-         (done (gen-label)))
+          (skip (gen-label))
+          (done (gen-label)))
       (move where arg)
       (inst cmpw where bsp-tn)
       (inst beq done)
       (inst beq skip)
       (loadw value bsp-tn (- binding-value-slot binding-size))
       (storew value symbol symbol-value-slot other-pointer-lowtag)
+      (storew zero-tn bsp-tn (- binding-value-slot binding-size))
       (storew zero-tn bsp-tn (- binding-symbol-slot binding-size))
 
       (emit-label skip)
   (:variant funcallable-instance-info-offset fun-pointer-lowtag)
   (:translate %set-funcallable-instance-info))
 
-(define-vop (funcallable-instance-lexenv cell-ref)
-  (:variant funcallable-instance-lexenv-slot fun-pointer-lowtag))
-
-
 (define-vop (closure-ref slot-ref)
   (:variant closure-info-offset fun-pointer-lowtag))
 
     (loadw temp struct 0 instance-pointer-lowtag)
     (inst srwi res temp n-widetag-bits)))
 
-(define-vop (instance-ref slot-ref)
-  (:variant instance-slots-offset instance-pointer-lowtag)
-  (:policy :fast-safe)
-  (:translate %instance-ref)
-  (:arg-types * (:constant index)))
-
-#+nil
-(define-vop (instance-set slot-set)
-  (:policy :fast-safe)
-  (:translate %instance-set)
-  (:variant instance-slots-offset instance-pointer-lowtag)
-  (:arg-types instance (:constant index) *))
-
 (define-vop (instance-index-ref word-index-ref)
-  (:policy :fast-safe) 
+  (:policy :fast-safe)
   (:translate %instance-ref)
   (:variant instance-slots-offset instance-pointer-lowtag)
   (:arg-types instance positive-fixnum))
 
 (define-vop (instance-index-set word-index-set)
-  (:policy :fast-safe) 
+  (:policy :fast-safe)
   (:translate %instance-set)
   (:variant instance-slots-offset instance-pointer-lowtag)
   (:arg-types instance positive-fixnum *))
   (:translate %raw-instance-ref/word)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg)))
+         (index :scs (any-reg)))
   (:arg-types * positive-fixnum)
   (:results (value :scs (unsigned-reg)))
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:result-types unsigned-num)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-set/word)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg))
+         (index :scs (any-reg))
          (value :scs (unsigned-reg)))
   (:arg-types * positive-fixnum unsigned-num)
   (:results (result :scs (unsigned-reg)))
   (:result-types unsigned-num)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-ref/single)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg)))
+         (index :scs (any-reg)))
   (:arg-types * positive-fixnum)
   (:results (value :scs (single-reg)))
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:result-types single-float)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-set/single)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg))
-        (value :scs (single-reg) :target result))
+         (index :scs (any-reg))
+         (value :scs (single-reg) :target result))
   (:arg-types * positive-fixnum single-float)
   (:results (result :scs (single-reg)))
   (:result-types single-float)
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-ref/double)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg)))
+         (index :scs (any-reg)))
   (:arg-types * positive-fixnum)
   (:results (value :scs (double-reg)))
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:result-types double-float)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-set/double)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg))
-        (value :scs (double-reg) :target result))
+         (index :scs (any-reg))
+         (value :scs (double-reg) :target result))
   (:arg-types * positive-fixnum double-float)
   (:results (result :scs (double-reg)))
   (:result-types double-float)
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-ref/complex-single)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg)))
+         (index :scs (any-reg)))
   (:arg-types * positive-fixnum)
   (:results (value :scs (complex-single-reg)))
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:result-types complex-single-float)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-set/complex-single)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg))
-        (value :scs (complex-single-reg) :target result))
+         (index :scs (any-reg))
+         (value :scs (complex-single-reg) :target result))
   (:arg-types * positive-fixnum complex-single-float)
   (:results (result :scs (complex-single-reg)))
   (:result-types complex-single-float)
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
           (- (* (- instance-slots-offset 2) n-word-bytes)
              instance-pointer-lowtag))
     (let ((value-real (complex-single-reg-real-tn value))
-         (result-real (complex-single-reg-real-tn result)))
+          (result-real (complex-single-reg-real-tn result)))
       (inst stfsx value-real object offset)
       (unless (location= result-real value-real)
         (inst frsp result-real value-real)))
     (inst addi offset offset n-word-bytes)
     (let ((value-imag (complex-single-reg-imag-tn value))
-         (result-imag (complex-single-reg-imag-tn result)))
+          (result-imag (complex-single-reg-imag-tn result)))
       (inst stfsx value-imag object offset)
       (unless (location= result-imag value-imag)
         (inst frsp result-imag value-imag)))))
   (:translate %raw-instance-ref/complex-double)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg)))
+         (index :scs (any-reg)))
   (:arg-types * positive-fixnum)
   (:results (value :scs (complex-double-reg)))
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:result-types complex-double-float)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
   (:translate %raw-instance-set/complex-double)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg))
-        (index :scs (any-reg))
-        (value :scs (complex-double-reg) :target result))
+         (index :scs (any-reg))
+         (value :scs (complex-double-reg) :target result))
   (:arg-types * positive-fixnum complex-double-float)
   (:results (result :scs (complex-double-reg)))
   (:result-types complex-double-float)
   (:temporary (:scs (non-descriptor-reg)) offset)
   (:generator 5
     (loadw offset object 0 instance-pointer-lowtag)
-    (inst srwi offset offset n-widetag-bits)
-    (inst slwi offset offset 2)
+    ;; offset = (offset >> n-widetag-bits) << 2
+    (inst rlwinm offset offset (- 32 (- n-widetag-bits 2)) (- n-widetag-bits 2) 29)
     (inst subf offset index offset)
     (inst addi
           offset
           (- (* (- instance-slots-offset 4) n-word-bytes)
              instance-pointer-lowtag))
     (let ((value-real (complex-double-reg-real-tn value))
-         (result-real (complex-double-reg-real-tn result)))
+          (result-real (complex-double-reg-real-tn result)))
       (inst stfdx value-real object offset)
       (unless (location= result-real value-real)
         (inst fmr result-real value-real)))
     (inst addi offset offset (* 2 n-word-bytes))
     (let ((value-imag (complex-double-reg-imag-tn value))
-         (result-imag (complex-double-reg-imag-tn result)))
+          (result-imag (complex-double-reg-imag-tn result)))
       (inst stfdx value-imag object offset)
       (unless (location= result-imag value-imag)
         (inst fmr result-imag value-imag)))))