(defun symbol-hash (symbol)
(declare (type symbol symbol))
(sxhash symbol))
+
+;;; These functions are needed for constant-folding.
+(defun sb!kernel:simple-array-nil-p (object)
+ (typep object '(simple-array nil)))
+
+(defun sb!kernel:%negate (number)
+ (- number))
+
+(defun sb!kernel:%single-float (number)
+ (coerce number 'single-float))
+
+(defun sb!kernel:%double-float (number)
+ (coerce number 'double-float))
+
+(defun sb!kernel:%ldb (size posn integer)
+ (ldb (byte size posn) integer))
\f
;;; Modular functions
-;;; (ldb (byte s 0) (foo x y ...)) =
+;;; (ldb (byte s 0) (foo x y ...)) =
;;; (ldb (byte s 0) (foo (ldb (byte s 0) x) y ...))
;;;
-;;; and similar for other arguments. If
-;;;
-;;; (ldb (byte s 0) (foo x y ...)) =
-;;; (foo (ldb (byte s 0) x) (ldb (byte s 0) y) ...)
-;;;
-;;; the function FOO is :GOOD.
+;;; and similar for other arguments.
;;; Try to recursively cut all uses of the continuation CONT to WIDTH
;;; bits.
+;;;
+;;; For good functions, we just recursively cut arguments; their
+;;; "goodness" means that the result will not increase (in the
+;;; (unsigned-byte +infinity) sense). An ordinary modular function is
+;;; replaced with the version, cutting its result to WIDTH or more
+;;; bits. If we have changed anything, we need to flush old derived
+;;; types, because they have nothing in common with the new code.
(defun cut-to-width (cont width)
(declare (type continuation cont) (type (integer 0) width))
(labels ((reoptimize-node (node name)
(move ecx amount)
(inst shl r :cl)))
\f
+;;;; Modular functions
+
+(define-modular-fun +-mod32 (x y) + 32)
+(define-vop (fast-+-mod32/unsigned=>unsigned fast-+/unsigned=>unsigned)
+ (:translate +-mod32))
+(define-vop (fast-+-mod32-c/unsigned=>unsigned fast-+-c/unsigned=>unsigned)
+ (:translate +-mod32))
+
+;;; logical operations
+(define-modular-fun lognot-mod32 (x) lognot 32)
+(define-vop (lognot-mod32/unsigned=>unsigned)
+ (:translate lognot-mod32)
+ (:args (x :scs (unsigned-reg unsigned-stack) :target r
+ :load-if (not (and (sc-is x unsigned-stack)
+ (sc-is r unsigned-stack)
+ (location= x r)))))
+ (:arg-types unsigned-num)
+ (:results (r :scs (unsigned-reg)
+ :load-if (not (and (sc-is x unsigned-stack)
+ (sc-is r unsigned-stack)
+ (location= x r)))))
+ (:result-types unsigned-num)
+ (:policy :fast-safe)
+ (:generator 1
+ (move r x)
+ (inst not r)))
+
+(define-modular-fun logxor-mod32 (x y) logxor 32)
+(define-vop (fast-logxor-mod32/unsigned=>unsigned
+ fast-logxor/unsigned=>unsigned)
+ (:translate logxor-mod32))
+(define-vop (fast-logxor-mod32-c/unsigned=>unsigned
+ fast-logxor-c/unsigned=>unsigned)
+ (:translate logxor-mod32))
+\f
;;;; bignum stuff
(define-vop (bignum-length get-header-data)
(move hi edx)
(move lo eax)))
-(define-vop (bignum-lognot)
- (:translate sb!bignum::%lognot)
- (:policy :fast-safe)
- (:args (x :scs (unsigned-reg unsigned-stack) :target r))
- (:arg-types unsigned-num)
- (:results (r :scs (unsigned-reg)
- :load-if (not (location= x r))))
- (:result-types unsigned-num)
- (:generator 1
- (move r x)
- (inst not r)))
+(define-vop (bignum-lognot lognot-mod32/unsigned=>unsigned)
+ (:translate sb!bignum::%lognot))
(define-vop (fixnum-to-digit)
(:translate sb!bignum::%fixnum-to-digit)
(inst mov tmp y)
(inst shr tmp 18)
(inst xor y tmp)))
-\f
-;;;; Modular functions
-(define-modular-fun +-mod32 (x y) + 32)
-(define-vop (fast-+-mod32/unsigned=>unsigned fast-+/unsigned=>unsigned)
- (:translate +-mod32))
-(define-vop (fast-+-mod32-c/unsigned=>unsigned fast-+-c/unsigned=>unsigned)
- (:translate +-mod32))
-
-;;; logical operations
-(define-modular-fun lognot-mod32 (x) lognot 32)
-(define-vop (lognot-mod32/unsigned=>unsigned)
- (:translate lognot-mod32)
- (:args (x :scs (unsigned-reg) :target r
- :load-if (not (and (sc-is x unsigned-stack)
- (sc-is r unsigned-stack)
- (location= x r)))))
- (:arg-types unsigned-num)
- (:results (r :scs (unsigned-reg)
- :load-if (not (and (sc-is x unsigned-stack)
- (sc-is r unsigned-stack)
- (location= x r)))))
- (:result-types unsigned-num)
- (:policy :fast-safe)
- (:generator 1
- (move r x)
- (inst not r)))
-
-(define-modular-fun logxor-mod32 (x y) logxor 32)
-(define-vop (fast-logxor-mod32/unsigned=>unsigned
- fast-logxor/unsigned=>unsigned)
- (:translate logxor-mod32))
-(define-vop (fast-logxor-mod32-c/unsigned=>unsigned
- fast-logxor-c/unsigned=>unsigned)
- (:translate logxor-mod32))