Convert an ASSERT into an AVER in INIT-LIVE-TNS
[sbcl.git] / src / compiler / hppa / cell.lisp
index 78df196..114ed55 100644 (file)
@@ -30,6 +30,8 @@
   (:results)
   (:generator 1
     (storew value object offset lowtag)))
+
+(define-vop (init-slot set-slot))
 \f
 ;;;; Symbol hacking VOPs:
 
   (:generator 2
     (loadw temp symbol symbol-hash-slot other-pointer-lowtag)
     (inst dep 0 31 n-fixnum-tag-bits temp)
-    ; we must go through an temporary to avoid gc
+    ;; we must go through an temporary to avoid gc
     (move temp res)))
 
+;;; On unithreaded builds these are just copies of the non-global versions.
+(define-vop (%set-symbol-global-value set))
+(define-vop (symbol-global-value symbol-value)
+  (:translate symbol-global-value))
+(define-vop (fast-symbol-global-value fast-symbol-value)
+  (:translate symbol-global-value))
 \f
 ;;;; Fdefinition (fdefn) objects.
 
 ;;; BIND -- Establish VAL as a binding for SYMBOL.  Save the old value and
 ;;; the symbol on the binding stack and stuff the new value into the
 ;;; symbol.
+;;;
+;;; See the "Chapter 9: Specials" of the SBCL Internals Manual.
 
 (define-vop (bind)
   (:args (val :scs (any-reg descriptor-reg))
 
 (define-vop (closure-init slot-set)
   (:variant closure-info-offset fun-pointer-lowtag))
+
+(define-vop (closure-init-from-fp)
+  (:args (object :scs (descriptor-reg)))
+  (:info offset)
+  (:generator 4
+    (storew cfp-tn object (+ closure-info-offset offset) fun-pointer-lowtag)))
 \f
 ;;;; Value Cell hackery.
 
 
 \f
 ;;;; raw instance slot accessors
-
-(macrolet ((fix-storage (inc-offset-by)
-             `(progn
-                (loadw offset object 0 instance-pointer-lowtag)
-                (inst srl offset n-widetag-bits offset)
-                (inst sll offset 2 offset)
-                (inst sub offset index offset)
-                (inst addi ,inc-offset-by offset offset)
-                (inst add offset object lip)))
+(macrolet ((lfloat (imm base dst &key side)
+             `(cond
+                ((< ,imm (ash 1 4))
+                  (inst flds ,imm ,base ,dst :side ,side))
+                ((and (< ,imm (ash 1 13))
+                      (> ,imm 0))
+                  (progn
+                    (inst li ,imm offset)
+                    (inst fldx offset ,base ,dst :side ,side)))
+                (t
+                  (error "inst fldx cant handle offset-register loaded with immediate ~s" ,imm))))
+           (sfloat (src imm base &key side)
+             `(cond
+                ((< ,imm (ash 1 4))
+                  (inst fsts ,src ,imm ,base :side ,side))
+                ((and (< ,imm (ash 1 13))
+                      (> ,imm 0))
+                  (progn
+                    (inst ldo ,imm zero-tn offset)
+                    (inst fstx ,src offset ,base :side ,side)))
+                (t
+                  (error "inst fstx cant handle offset-register loaded with immediate ~s" ,imm))))
            (raw-instance ((type inc-offset-by set &optional complex)
                           &body body)
              (let ((name (symbolicate "RAW-INSTANCE-"
     (move value result))
 
   (raw-instance (single -1 nil)
-    (inst li (- (* instance-slots-offset n-word-bytes)
-                instance-pointer-lowtag) offset)
-    (inst fldx offset lip value))
+    (let ((io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+      (lfloat io lip value)))
 
   (raw-instance (single -1 t)
-    (inst li (- (* instance-slots-offset n-word-bytes)
-                instance-pointer-lowtag) offset)
-    (inst fstx value offset lip)
+    (let ((io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+      (sfloat value io lip))
     (unless (location= result value)
       (inst funop :copy value result)))
 
   (raw-instance (double -2 nil)
-    (inst fldx object index value)
-    (inst fldx offset lip value))
+    (let ((io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+      (lfloat io lip value)))
 
   (raw-instance (double -2 t)
-    (inst fldx offset lip value)
-    (inst fldx index object value)
-    (inst funop :copy value result))
+    (let ((io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+      (sfloat value io lip :side 0))
+    (let ((io (- (* (1+ instance-slots-offset) n-word-bytes)
+                 instance-pointer-lowtag)))
+      (sfloat value io lip :side 1))
+    (unless (location= result value)
+      (inst funop :copy value result)))
 
   (raw-instance (single -2 nil complex-single)
-    (inst li (- (* instance-slots-offset n-word-bytes)
-                instance-pointer-lowtag) offset)
-    (inst fldx offset lip (complex-single-reg-real-tn value))
-    (inst li (- (* (1+ instance-slots-offset) n-word-bytes)
-                instance-pointer-lowtag) offset)
-    (inst fldx offset lip (complex-single-reg-imag-tn value)))
+    (let ((io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+      (lfloat io lip (complex-single-reg-real-tn value)))
+    (let ((io (- (* (1+ instance-slots-offset) n-word-bytes)
+                 instance-pointer-lowtag)))
+      (lfloat io lip (complex-single-reg-imag-tn value))))
 
   (raw-instance (single -2 t complex-single)
     (let ((value-real (complex-single-reg-real-tn value))
-          (result-real (complex-single-reg-real-tn result)))
-      (inst li (- (* instance-slots-offset n-word-bytes)
-                  instance-pointer-lowtag) offset)
-      (inst fstx value-real offset lip)
+          (result-real (complex-single-reg-real-tn result))
+          (io (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag)))
+
+      (sfloat value-real io lip)
       (unless (location= result-real value-real)
         (inst funop :copy value-real result-real)))
     (let ((value-imag (complex-single-reg-imag-tn value))
-          (result-imag (complex-single-reg-imag-tn result)))
-      (inst li (- (* (1+ instance-slots-offset) n-word-bytes)
-                  instance-pointer-lowtag) offset)
-      (inst fstx value-imag offset lip)
+          (result-imag (complex-single-reg-imag-tn result))
+          (io (- (* (1+ instance-slots-offset) n-word-bytes)
+                 instance-pointer-lowtag)))
+      (sfloat value-imag io lip)
       (unless (location= result-imag value-imag)
         (inst funop :copy value-imag result-imag))))
 
   (raw-instance (double -4 nil complex-double)
-    (let ((immediate-offset (- (* instance-slots-offset n-word-bytes)
-                               instance-pointer-lowtag)))
-      (inst li immediate-offset offset)
-      (inst fldx offset lip (complex-double-reg-real-tn value)))
-    (let ((immediate-offset (+ 4 (- (* (1+ instance-slots-offset)
-           n-word-bytes) instance-pointer-lowtag))))
-      (inst li immediate-offset offset)
-      (inst fldx offset lip (complex-double-reg-real-tn value)))
-    (let ((immediate-offset (- (* (+ instance-slots-offset 2) n-word-bytes)
-                               instance-pointer-lowtag)))
-      (inst li immediate-offset offset)
-      (inst fldx offset lip (complex-double-reg-imag-tn value)))
-    (let ((immediate-offset (+ 4 (- (* (+ instance-slots-offset 3)
-           n-word-bytes) instance-pointer-lowtag))))
-      (inst li immediate-offset offset)
-      (inst fldx offset lip (complex-double-reg-imag-tn value))))
+    (let ((r0 (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag))
+          (r1 (- (* (+ instance-slots-offset 1) n-word-bytes)
+                 instance-pointer-lowtag))
+          (i0 (- (* (+ instance-slots-offset 2) n-word-bytes)
+                 instance-pointer-lowtag))
+          (i1 (- (* (+ instance-slots-offset 3) n-word-bytes)
+                 instance-pointer-lowtag)))
+      (lfloat r0 lip (complex-double-reg-real-tn value) :side 0)
+      (lfloat r1 lip (complex-double-reg-real-tn value) :side 1)
+      (lfloat i0 lip (complex-double-reg-imag-tn value) :side 0)
+      (lfloat i1 lip (complex-double-reg-imag-tn value) :side 1)))
 
   (raw-instance (double -4 t complex-double)
-    (let ((value-real (complex-double-reg-real-tn value))
-          (result-real (complex-double-reg-real-tn result)))
-      (let ((immediate-offset (- (* instance-slots-offset n-word-bytes)
-                                 instance-pointer-lowtag)))
-        (inst li immediate-offset offset)
-        (inst fldx offset lip value-real))
-      (let ((immediate-offset (+ 4 (- (* (1+ instance-slots-offset)
-              n-word-bytes) instance-pointer-lowtag))))
-        (inst li immediate-offset offset)
-        (inst fldx offset lip value-real))
-
+    (let ((value-real  (complex-double-reg-real-tn value))
+          (result-real (complex-double-reg-real-tn result))
+          (value-imag (complex-double-reg-imag-tn value))
+          (result-imag (complex-double-reg-imag-tn result))
+          (r0 (- (* instance-slots-offset n-word-bytes)
+                 instance-pointer-lowtag))
+          (r1 (- (* (+ instance-slots-offset 1) n-word-bytes)
+                 instance-pointer-lowtag))
+          (i0 (- (* (+ instance-slots-offset 2) n-word-bytes)
+                 instance-pointer-lowtag))
+          (i1 (- (* (+ instance-slots-offset 3) n-word-bytes)
+                      instance-pointer-lowtag)))
+      (sfloat value-real r0 lip :side 0)
+      (sfloat value-real r1 lip :side 1)
+      (sfloat value-imag i0 lip :side 0)
+      (sfloat value-imag i1 lip :side 1)
       (unless (location= result-real value-real)
-        (inst funop :copy value-real result-real)))
-    (let ((value-imag (complex-double-reg-imag-tn value))
-          (result-imag (complex-double-reg-imag-tn result)))
-      (let ((immediate-offset (- (* (+ instance-slots-offset 2) n-word-bytes)
-                                 instance-pointer-lowtag)))
-        (inst li immediate-offset offset)
-        (inst fldx offset lip value-imag))
-
-      (let ((immediate-offset (+ 4 (- (* (+ instance-slots-offset 3)
-             n-word-bytes) instance-pointer-lowtag))))
-        (inst li immediate-offset offset)
-        (inst fldx offset lip value-imag))
+        (inst funop :copy value-real result-real))
       (unless (location= result-imag value-imag)
          (inst funop :copy value-imag result-imag)))))