0.pre7.141:
[sbcl.git] / src / code / bit-bash.lisp
index fe2fa6e..47a86fc 100644 (file)
@@ -14,7 +14,7 @@
 ;;;; constants and types
 
 ;;; the number of bits to process at a time
-(defconstant unit-bits sb!vm:n-word-bits)
+(defconstant unit-bits n-word-bits)
 
 ;;; the maximum number of bits that can be dealt with in a single call
 (defconstant max-bits (ash most-positive-fixnum -2))
 ;;; A particular implementation must offer either VOPs to translate
 ;;; these, or DEFTRANSFORMs to convert them into something supported
 ;;; by the architecture.
-(macrolet ((def-frob (name &rest args)
+(macrolet ((def (name &rest args)
             `(defun ,name ,args
                (,name ,@args))))
-  (def-frob 32bit-logical-not x)
-  (def-frob 32bit-logical-and x y)
-  (def-frob 32bit-logical-or x y)
-  (def-frob 32bit-logical-xor x y)
-  (def-frob 32bit-logical-nor x y)
-  (def-frob 32bit-logical-eqv x y)
-  (def-frob 32bit-logical-nand x y)
-  (def-frob 32bit-logical-andc1 x y)
-  (def-frob 32bit-logical-andc2 x y)
-  (def-frob 32bit-logical-orc1 x y)
-  (def-frob 32bit-logical-orc2 x y))
+  (def 32bit-logical-not x)
+  (def 32bit-logical-and x y)
+  (def 32bit-logical-or x y)
+  (def 32bit-logical-xor x y)
+  (def 32bit-logical-nor x y)
+  (def 32bit-logical-eqv x y)
+  (def 32bit-logical-nand x y)
+  (def 32bit-logical-andc1 x y)
+  (def 32bit-logical-andc2 x y)
+  (def 32bit-logical-orc1 x y)
+  (def 32bit-logical-orc2 x y))
 
 ;;; Shift NUMBER by the low-order bits of COUNTOID, adding zero bits
 ;;; at the "end" and removing bits from the "start". On big-endian
   (let ((address (sap-int sap)))
     (values (int-sap #!-alpha (32bit-logical-andc2 address 3)
                     #!+alpha (ash (ash address -2) 2))
-           (+ (* (logand address 3) byte-bits) offset))))
+           (+ (* (logand address 3) n-byte-bits) offset))))
 
 #!-sb-fluid (declaim (inline word-sap-ref %set-word-sap-ref))
 (defun word-sap-ref (sap offset)
           (optimize (speed 3) (safety 0) (inhibit-warnings 3)))
   (setf (sap-ref-32 sap (the index (ash offset 2))) value))
 \f
-;;;; DO-CONSTANT-BIT-BASH
+;;;; CONSTANT-BIT-BASH
 
 ;;; Fill DST with VALUE starting at DST-OFFSET and continuing for
 ;;; LENGTH bits.
-#!-sb-fluid (declaim (inline do-constant-bit-bash))
-(defun do-constant-bit-bash (dst dst-offset length value dst-ref-fn dst-set-fn)
+#!-sb-fluid (declaim (inline constant-bit-bash))
+(defun constant-bit-bash (dst dst-offset length value dst-ref-fn dst-set-fn)
   (declare (type offset dst-offset) (type unit value)
           (type function dst-ref-fn dst-set-fn))
   (multiple-value-bind (dst-word-offset dst-bit-offset)
                           mask)))))))))
   (values))
 \f
-;;;; DO-UNARY-BIT-BASH
+;;;; UNARY-BIT-BASH
 
-#!-sb-fluid (declaim (inline do-unary-bit-bash))
-(defun do-unary-bit-bash (src src-offset dst dst-offset length
-                             dst-ref-fn dst-set-fn src-ref-fn)
+#!-sb-fluid (declaim (inline unary-bit-bash))
+(defun unary-bit-bash (src src-offset dst dst-offset length
+                          dst-ref-fn dst-set-fn src-ref-fn)
   ;; FIXME: Declaring these bit indices to be of type OFFSET, then
   ;; using the inline expansion in SPEED 3 SAFETY 0 functions, is not
   ;; a good thing. At the very least, we should make sure that the
   (declare (type unit value) (type offset dst-offset length))
   (locally
    (declare (optimize (speed 3) (safety 0)))
-   (do-constant-bit-bash dst dst-offset length value
-                        #'%raw-bits #'%set-raw-bits)))
+   (constant-bit-bash dst dst-offset length value
+                     #'%raw-bits #'%set-raw-bits)))
 
 (defun system-area-fill (value dst dst-offset length)
   (declare (type unit value) (type offset dst-offset length))
   (locally
    (declare (optimize (speed 3) (safety 0)))
    (multiple-value-bind (dst dst-offset) (fix-sap-and-offset dst dst-offset)
-     (do-constant-bit-bash dst dst-offset length value
-                          #'word-sap-ref #'%set-word-sap-ref))))
+     (constant-bit-bash dst dst-offset length value
+                       #'word-sap-ref #'%set-word-sap-ref))))
 
 (defun bit-bash-copy (src src-offset dst dst-offset length)
   (declare (type offset src-offset dst-offset length))
   (locally
    (declare (optimize (speed 3) (safety 0))
-           (inline do-unary-bit-bash))
-   (do-unary-bit-bash src src-offset dst dst-offset length
-                     #'%raw-bits #'%set-raw-bits #'%raw-bits)))
+           (inline unary-bit-bash))
+   (unary-bit-bash src src-offset dst dst-offset length
+                  #'%raw-bits #'%set-raw-bits #'%raw-bits)))
 
 (defun system-area-copy (src src-offset dst dst-offset length)
   (declare (type offset src-offset dst-offset length))
      (declare (type system-area-pointer src))
      (multiple-value-bind (dst dst-offset) (fix-sap-and-offset dst dst-offset)
        (declare (type system-area-pointer dst))
-       (do-unary-bit-bash src src-offset dst dst-offset length
-                         #'word-sap-ref #'%set-word-sap-ref
-                         #'word-sap-ref)))))
+       (unary-bit-bash src src-offset dst dst-offset length
+                      #'word-sap-ref #'%set-word-sap-ref
+                      #'word-sap-ref)))))
 
 (defun copy-to-system-area (src src-offset dst dst-offset length)
   (declare (type offset src-offset dst-offset length))
   (locally
    (declare (optimize (speed 3) (safety 0)))
    (multiple-value-bind (dst dst-offset) (fix-sap-and-offset dst dst-offset)
-     (do-unary-bit-bash src src-offset dst dst-offset length
-                       #'word-sap-ref #'%set-word-sap-ref #'%raw-bits))))
+     (unary-bit-bash src src-offset dst dst-offset length
+                    #'word-sap-ref #'%set-word-sap-ref #'%raw-bits))))
 
 (defun copy-from-system-area (src src-offset dst dst-offset length)
   (declare (type offset src-offset dst-offset length))
   (locally
    (declare (optimize (speed 3) (safety 0)))
    (multiple-value-bind (src src-offset) (fix-sap-and-offset src src-offset)
-     (do-unary-bit-bash src src-offset dst dst-offset length
-                       #'%raw-bits #'%set-raw-bits #'word-sap-ref))))
+     (unary-bit-bash src src-offset dst dst-offset length
+                    #'%raw-bits #'%set-raw-bits #'word-sap-ref))))
 
 ;;; a common idiom for calling COPY-TO-SYSTEM-AREA
 ;;;
 (defun copy-byte-vector-to-system-area (bv sap &optional (offset 0))
   ;; FIXME: There should be a type like SB!VM:BYTE so that we can write this
   ;; type as (SIMPLE-ARRAY SB!VM:BYTE 1). Except BYTE is an external symbol of
-  ;; package CL; so maybe SB!VM:VM-BYTE?
+  ;; package CL, and shadowing it would be too ugly; so maybe SB!VM:VMBYTE?
+  ;; (And then N-BYTE-BITS would be N-VMBYTE-BITS and so forth?)
   (declare (type (simple-array (unsigned-byte 8) 1) bv))
   (declare (type sap sap))
   (declare (type fixnum offset))
   ;; %BYTE-BLIT (and correspondingly rename the corresponding VOP) and
   ;; replace the DST-END argument with an N-BYTES argument?
   (copy-to-system-area bv
-                      (* sb!vm:vector-data-offset sb!vm:n-word-bits)
+                      (* vector-data-offset n-word-bits)
                       sap
                       offset
-                      (* (length bv) sb!vm:byte-bits)))
+                      (* (length bv) n-byte-bits)))