(define-vop (fast-lognot/fixnum fixnum-unop)
(:translate lognot)
- (:generator 2
- (inst xori res x (fixnumize -1))))
+ (:generator 1
+ (inst subfic res x (fixnumize -1))))
(define-vop (fast-lognot/signed signed-unop)
(:translate lognot)
- (:generator 1
+ (:generator 2
(inst not res x)))
\f
;;;; Binary fixnum operations.
(:temporary (:scs (non-descriptor-reg)) temp)
(:translate *)
(:generator 2
- (inst srawi temp y 2)
+ (inst srawi temp y n-fixnum-tag-bits)
(inst mullw r x temp)))
(define-vop (fast-*-c/fixnum=>fixnum fast-fixnum-binop-c)
;;;; %LDB
(defknown %%ldb (integer unsigned-byte unsigned-byte) unsigned-byte
- (movable foldable flushable))
+ (movable foldable flushable always-translatable))
+
+;;; only for constant folding within the compiler
+(defun %%ldb (integer size posn)
+ (sb!kernel::%ldb size posn integer))
(define-vop (ldb-c/fixnum)
(:translate %%ldb)
\f
;;;; Modular functions:
-(define-modular-fun lognot-mod32 (x) lognot :unsigned 32)
+(define-modular-fun lognot-mod32 (x) lognot :untagged nil 32)
(define-vop (lognot-mod32/unsigned=>unsigned)
(:translate lognot-mod32)
(:args (x :scs (unsigned-reg)))
(vop (symbolicate 'fast- fun '/unsigned=>unsigned))
(cvop (symbolicate 'fast- fun '-c/unsigned=>unsigned)))
`(progn
- (define-modular-fun ,mfun-name (x y) ,fun :unsigned 32)
+ (define-modular-fun ,mfun-name (x y) ,fun :untagged nil 32)
(define-vop (,modvop ,vop)
(:translate ,mfun-name))
,@(when constantp
(define-modular-backend + t)
(define-modular-backend - t)
(define-modular-backend * t)
- (define-modular-backend logxor t)
(define-modular-backend logeqv)
(define-modular-backend lognand)
(define-modular-backend lognor)
(define-logtest-vops))
(defknown %logbitp (integer unsigned-byte) boolean
- (movable foldable flushable))
+ (movable foldable flushable always-translatable))
+
+;;; only for constant folding within the compiler
+(defun %logbitp (integer index)
+ (logbitp index integer))
;;; We only handle the constant cases because those are the only ones
;;; guaranteed to make it past COMBINATION-IMPLEMENTATION-STYLE.
;;; --njf, 06-02-2006
(define-vop (fast-logbitp-c/fixnum fast-conditional-c/fixnum)
(:translate %logbitp)
+ (:arg-types tagged-num (:constant (integer 0 29)))
(:temporary (:scs (any-reg) :to (:result 0)) test)
(:generator 4
(if (< y 14)
(define-vop (fast-logbitp-c/signed fast-conditional-c/signed)
(:translate %logbitp)
+ (:arg-types signed-num (:constant (integer 0 31)))
(:temporary (:scs (signed-reg) :to (:result 0)) test)
(:generator 4
(if (< y 16)
(define-vop (fast-logbitp-c/unsigned fast-conditional-c/unsigned)
(:translate %logbitp)
+ (:arg-types unsigned-num (:constant (integer 0 31)))
(:temporary (:scs (unsigned-reg) :to (:result 0)) test)
(:generator 4
(if (< y 16)
\f
;;;; 32-bit logical operations
-(define-vop (merge-bits)
- (:translate merge-bits)
- (:args (shift :scs (signed-reg unsigned-reg))
- (prev :scs (unsigned-reg))
- (next :scs (unsigned-reg)))
- (:arg-types tagged-num unsigned-num unsigned-num)
- (:temporary (:scs (unsigned-reg) :to (:result 0)) temp)
- (:temporary (:scs (unsigned-reg) :to (:result 0) :target result) res)
- (:results (result :scs (unsigned-reg)))
- (:result-types unsigned-num)
- (:policy :fast-safe)
- (:generator 4
- (let ((done (gen-label)))
- (inst cmpwi shift 0)
- (inst beq done)
- (inst srw res next shift)
- (inst sub temp zero-tn shift)
- (inst slw temp prev temp)
- (inst or res res temp)
- (emit-label done)
- (move result res))))
-
(define-vop (shift-towards-someplace)
(:policy :fast-safe)
(:args (num :scs (unsigned-reg))
(inst mullw lo x y)
(inst mulhwu hi x y)))
+#!+multiply-high-vops
+(define-vop (mulhi)
+ (:translate sb!kernel:%multiply-high)
+ (:policy :fast-safe)
+ (:args (x :scs (unsigned-reg))
+ (y :scs (unsigned-reg)))
+ (:arg-types unsigned-num unsigned-num)
+ (:results (hi :scs (unsigned-reg)))
+ (:result-types unsigned-num)
+ (:generator 20
+ (inst mulhwu hi x y)))
+
+#!+multiply-high-vops
+(define-vop (mulhi/fx)
+ (:translate sb!kernel:%multiply-high)
+ (:policy :fast-safe)
+ (:args (x :scs (any-reg))
+ (y :scs (unsigned-reg)))
+ (:arg-types positive-fixnum unsigned-num)
+ (:temporary (:sc non-descriptor-reg :from :eval :to :result) temp)
+ (:temporary (:sc non-descriptor-reg :from :eval :to :result) mask)
+ (:results (hi :scs (any-reg)))
+ (:result-types positive-fixnum)
+ (:generator 15
+ (inst mulhwu temp x y)
+ (inst lr mask fixnum-tag-mask)
+ (inst andc hi temp mask)))
+
(define-vop (bignum-lognot lognot-mod32/unsigned=>unsigned)
(:translate sb!bignum:%lognot))
(:results (digit :scs (unsigned-reg)))
(:result-types unsigned-num)
(:generator 1
- (inst srawi digit fixnum 2)))
+ (inst srawi digit fixnum n-fixnum-tag-bits)))
(define-vop (bignum-floor)
- (:translate sb!bignum:%floor)
+ (:translate sb!bignum:%bigfloor)
(:policy :fast-safe)
(:args (num-high :scs (unsigned-reg) :target rem)
(num-low :scs (unsigned-reg) :target rem-low)
#|
(define-vop (bignum-floor)
- (:translate sb!bignum:%floor)
+ (:translate sb!bignum:%bigfloor)
(:policy :fast-safe)
(:args (div-high :scs (unsigned-reg) :target rem)
(div-low :scs (unsigned-reg) :target quo)
(:generator 1
(sc-case res
(any-reg
- (inst slwi res digit 2))
+ (inst slwi res digit n-fixnum-tag-bits))
(signed-reg
(move res digit)))))