(:arg-types tagged-num tagged-num)
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:arg-types tagged-num tagged-num)
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:arg-types unsigned-num unsigned-num)
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num)
(:arg-types unsigned-num unsigned-num)
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num)
(:arg-types signed-num signed-num)
(:results (r :scs (signed-reg)))
(:result-types signed-num)
(:arg-types signed-num signed-num)
(:results (r :scs (signed-reg)))
(:result-types signed-num)
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:note "inline fixnum arithmetic"))
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:note "inline fixnum arithmetic"))
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic"))
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic"))
(:results (r :scs (signed-reg)))
(:result-types signed-num)
(:note "inline (signed-byte 32) arithmetic"))
(:results (r :scs (signed-reg)))
(:result-types signed-num)
(:note "inline (signed-byte 32) arithmetic"))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-binop (translate untagged-penalty op
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-binop (translate untagged-penalty op
- ,(if arg-swap
- `(inst ,op ,(if restore-fixnum-mask 'temp 'r) y x)
- `(inst ,op ,(if restore-fixnum-mask 'temp 'r) x y))
- ,@(when restore-fixnum-mask
- `((inst andn r temp fixnum-tag-mask)))))
+ ,(if arg-swap
+ `(inst ,op ,(if restore-fixnum-mask 'temp 'r) y x)
+ `(inst ,op ,(if restore-fixnum-mask 'temp 'r) x y))
+ ,@(when restore-fixnum-mask
+ `((inst andn r temp fixnum-tag-mask)))))
- `((define-vop (,(symbolicate 'fast- translate '-c/fixnum=>fixnum)
- fast-fixnum-binop-c)
- ,@(when restore-fixnum-mask
- `((:temporary (:sc non-descriptor-reg) temp)))
- (:translate ,translate)
- (:generator 1
- (inst ,op ,(if restore-fixnum-mask 'temp 'r) x (fixnumize y))
- ,@(when restore-fixnum-mask
- `((inst andn r temp fixnum-tag-mask)))))))
+ `((define-vop (,(symbolicate 'fast- translate '-c/fixnum=>fixnum)
+ fast-fixnum-binop-c)
+ ,@(when restore-fixnum-mask
+ `((:temporary (:sc non-descriptor-reg) temp)))
+ (:translate ,translate)
+ (:generator 1
+ (inst ,op ,(if restore-fixnum-mask 'temp 'r) x (fixnumize y))
+ ,@(when restore-fixnum-mask
+ `((inst andn r temp fixnum-tag-mask)))))))
- `((define-vop (,(symbolicate 'fast- translate '-c/signed=>signed)
- fast-signed-binop-c)
- (:translate ,translate)
- (:generator ,untagged-penalty
- (inst ,op r x y)))))
+ `((define-vop (,(symbolicate 'fast- translate '-c/signed=>signed)
+ fast-signed-binop-c)
+ (:translate ,translate)
+ (:generator ,untagged-penalty
+ (inst ,op r x y)))))
- `((define-vop (,(symbolicate 'fast- translate '-c/unsigned=>unsigned)
- fast-unsigned-binop-c)
- (:translate ,translate)
- (:generator ,untagged-penalty
- (inst ,op r x y)))))))
+ `((define-vop (,(symbolicate 'fast- translate '-c/unsigned=>unsigned)
+ fast-unsigned-binop-c)
+ (:translate ,translate)
+ (:generator ,untagged-penalty
+ (inst ,op r x y)))))))
(:result-types tagged-num tagged-num)
(:note "inline fixnum arithmetic")
(:temporary (:scs (any-reg) :target quo) q)
(:result-types tagged-num tagged-num)
(:note "inline fixnum arithmetic")
(:temporary (:scs (any-reg) :target quo) q)
(:result-types signed-num signed-num)
(:note "inline (signed-byte 32) arithmetic")
(:temporary (:scs (signed-reg) :target quo) q)
(:result-types signed-num signed-num)
(:note "inline (signed-byte 32) arithmetic")
(:temporary (:scs (signed-reg) :target quo) q)
(:generator 12
(let ((zero (generate-error-code vop division-by-zero-error x y)))
(inst cmp y zero-tn)
(if (member :sparc-v9 *backend-subfeatures*)
(:generator 12
(let ((zero (generate-error-code vop division-by-zero-error x y)))
(inst cmp y zero-tn)
(if (member :sparc-v9 *backend-subfeatures*)
(:result-types unsigned-num unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic")
(:temporary (:scs (unsigned-reg) :target quo) q)
(:result-types unsigned-num unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic")
(:temporary (:scs (unsigned-reg) :target quo) q)
(:generator 8
(let ((zero (generate-error-code vop division-by-zero-error x y)))
(inst cmp y zero-tn)
(if (member :sparc-v9 *backend-subfeatures*)
(:generator 8
(let ((zero (generate-error-code vop division-by-zero-error x y)))
(inst cmp y zero-tn)
(if (member :sparc-v9 *backend-subfeatures*)
(:result-types signed-num signed-num)
(:note "inline (signed-byte 32) arithmetic")
(:temporary (:scs (signed-reg) :target quo) q)
(:result-types signed-num signed-num)
(:note "inline (signed-byte 32) arithmetic")
(:temporary (:scs (signed-reg) :target quo) q)
(:result-types unsigned-num unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic")
(:temporary (:scs (unsigned-reg) :target quo) q)
(:result-types unsigned-num unsigned-num)
(:note "inline (unsigned-byte 32) arithmetic")
(:temporary (:scs (unsigned-reg) :target quo) q)
(:arg-types signed-num signed-num)
(:results (result :scs (signed-reg)))
(:result-types signed-num)
(:arg-types signed-num signed-num)
(:results (result :scs (signed-reg)))
(:result-types signed-num)
- (progn
- (inst cmove :ge ndesc 31)
- (inst sra result number ndesc))
- (progn
- (inst b :le done)
- (inst sra result number ndesc)
- (inst sra result number 31)))
+ (progn
+ (inst cmove :ge ndesc 31)
+ (inst sra result number ndesc))
+ (progn
+ (inst b :le done)
+ (inst sra result number ndesc)
+ (inst sra result number 31)))
(:arg-types unsigned-num signed-num)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num)
(:arg-types unsigned-num signed-num)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num)
- (progn
- (inst srl result number ndesc)
- (inst cmove :ge result zero-tn))
- (progn
- (inst b :lt done)
- (inst srl result number ndesc)
- (move result zero-tn)))
+ (progn
+ (inst srl result number ndesc)
+ (inst cmove :ge result zero-tn))
+ (progn
+ (inst b :lt done)
+ (inst srl result number ndesc)
+ (move result zero-tn)))
- (:note "inline ASH")
- (:translate ash)
- (:args (number :scs (,sc-type))
- (amount :scs (signed-reg unsigned-reg immediate)))
- (:arg-types ,type positive-fixnum)
- (:results (result :scs (,result-type)))
- (:result-types ,type)
- (:policy :fast-safe)
- (:generator ,cost
- ;; The result-type assures us that this shift will not
- ;; overflow. And for fixnums, the zero bits that get
- ;; shifted in are just fine for the fixnum tag.
- (sc-case amount
- ((signed-reg unsigned-reg)
- (inst sll result number amount))
- (immediate
- (let ((amount (tn-value amount)))
- (aver (>= amount 0))
- (inst sll result number amount))))))))
+ (:note "inline ASH")
+ (:translate ash)
+ (:args (number :scs (,sc-type))
+ (amount :scs (signed-reg unsigned-reg immediate)))
+ (:arg-types ,type positive-fixnum)
+ (:results (result :scs (,result-type)))
+ (:result-types ,type)
+ (:policy :fast-safe)
+ (:generator ,cost
+ ;; The result-type assures us that this shift will not
+ ;; overflow. And for fixnums, the zero bits that get
+ ;; shifted in are just fine for the fixnum tag.
+ (sc-case amount
+ ((signed-reg unsigned-reg)
+ (inst sll result number amount))
+ (immediate
+ (let ((amount (tn-value amount)))
+ (aver (>= amount 0))
+ (inst sll result number amount))))))))
(def fast-ash-left/signed=>signed signed-reg signed-num signed-reg 3)
(def fast-ash-left/fixnum=>fixnum any-reg tagged-num any-reg 2)
(def fast-ash-left/unsigned=>unsigned unsigned-reg unsigned-num unsigned-reg 3))
(def fast-ash-left/signed=>signed signed-reg signed-num signed-reg 3)
(def fast-ash-left/fixnum=>fixnum any-reg tagged-num any-reg 2)
(def fast-ash-left/unsigned=>unsigned unsigned-reg unsigned-num unsigned-reg 3))
- (8 #x00ff00ff) (16 #x0000ffff)))
- (destructuring-bind (shift bit-mask)
- stuff
- ;; Set mask
- (inst sethi mask (ldb (byte 22 10) bit-mask))
- (inst add mask (ldb (byte 10 0) bit-mask))
+ (8 #x00ff00ff) (16 #x0000ffff)))
+ (destructuring-bind (shift bit-mask)
+ stuff
+ ;; Set mask
+ (inst sethi mask (ldb (byte 22 10) bit-mask))
+ (inst add mask (ldb (byte 10 0) bit-mask))
(:generator 2
;; The cost here should be less than the cost for
;; */signed=>signed. Why? A fixnum product using signed=>signed
(:generator 2
;; The cost here should be less than the cost for
;; */signed=>signed. Why? A fixnum product using signed=>signed
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:note "inline fixnum arithmetic")
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:results (r :scs (any-reg)))
(:result-types tagged-num)
(:note "inline fixnum arithmetic")
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 1
(inst smul r x y)))
(define-vop (fast-v8-*/signed=>signed fast-signed-binop)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 1
(inst smul r x y)))
(define-vop (fast-v8-*/signed=>signed fast-signed-binop)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 3
(inst smul r x y)))
(define-vop (fast-v8-*-c/signed=>signed fast-signed-binop-c)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 3
(inst smul r x y)))
(define-vop (fast-v8-*-c/signed=>signed fast-signed-binop-c)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(define-vop (fast-v8-*/unsigned=>unsigned fast-unsigned-binop)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(define-vop (fast-v8-*/unsigned=>unsigned fast-unsigned-binop)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 3
(inst umul r x y)))
(define-vop (fast-v8-*-c/unsigned=>unsigned fast-unsigned-binop-c)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:generator 3
(inst umul r x y)))
(define-vop (fast-v8-*-c/unsigned=>unsigned fast-unsigned-binop-c)
(:translate *)
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(define-vop (lognot-mod32/unsigned=>unsigned)
(:translate lognot-mod32)
(:args (x :scs (unsigned-reg)))
(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
(vop (symbolicate 'fast- fun '/unsigned=>unsigned))
(cvop (symbolicate 'fast- fun '-c/unsigned=>unsigned)))
`(progn
- ,@(when constantp
- `((define-vop (,modcvop ,cvop)
- (:translate ,mfun-name))))))))
+ ,@(when constantp
+ `((define-vop (,modcvop ,cvop)
+ (:translate ,mfun-name))))))))
(define-modular-backend + t)
(define-modular-backend - t)
(define-modular-backend logxor t)
(define-modular-backend + t)
(define-modular-backend - t)
(define-modular-backend logxor t)
`(lognot (logior ,x ,y)))
(define-vop (fast-ash-left-mod32-c/unsigned=>unsigned
`(lognot (logior ,x ,y)))
(define-vop (fast-ash-left-mod32-c/unsigned=>unsigned
(:translate ash-left-mod32))
(define-vop (fast-ash-left-mod32/unsigned=>unsigned
fast-ash-left/unsigned=>unsigned))
(deftransform ash-left-mod32 ((integer count)
(:translate ash-left-mod32))
(define-vop (fast-ash-left-mod32/unsigned=>unsigned
fast-ash-left/unsigned=>unsigned))
(deftransform ash-left-mod32 ((integer count)
(when (sb!c::constant-lvar-p count)
(sb!c::give-up-ir1-transform))
'(%primitive fast-ash-left-mod32/unsigned=>unsigned integer count))
(when (sb!c::constant-lvar-p count)
(sb!c::give-up-ir1-transform))
'(%primitive fast-ash-left-mod32/unsigned=>unsigned integer count))
(defmacro define-conditional-vop (tran cond unsigned not-cond not-unsigned)
`(progn
,@(mapcar (lambda (suffix cost signed)
(defmacro define-conditional-vop (tran cond unsigned not-cond not-unsigned)
`(progn
,@(mapcar (lambda (suffix cost signed)
- (unless (and (member suffix '(/fixnum -c/fixnum))
- (eq tran 'eql))
- `(define-vop (,(intern (format nil "~:@(FAST-IF-~A~A~)"
- tran suffix))
- ,(intern
- (format nil "~:@(FAST-CONDITIONAL~A~)"
- suffix)))
- (:translate ,tran)
- (:generator ,cost
- (inst cmp x
- ,(if (eq suffix '-c/fixnum) '(fixnumize y) 'y))
- (inst b (if not-p
- ,(if signed not-cond not-unsigned)
- ,(if signed cond unsigned))
- target)
- (inst nop)))))
- '(/fixnum -c/fixnum /signed -c/signed /unsigned -c/unsigned)
- '(4 3 6 5 6 5)
- '(t t t t nil nil))))
+ (unless (and (member suffix '(/fixnum -c/fixnum))
+ (eq tran 'eql))
+ `(define-vop (,(intern (format nil "~:@(FAST-IF-~A~A~)"
+ tran suffix))
+ ,(intern
+ (format nil "~:@(FAST-CONDITIONAL~A~)"
+ suffix)))
+ (:translate ,tran)
+ (:generator ,cost
+ (inst cmp x
+ ,(if (eq suffix '-c/fixnum) '(fixnumize y) 'y))
+ (inst b (if not-p
+ ,(if signed not-cond not-unsigned)
+ ,(if signed cond unsigned))
+ target)
+ (inst nop)))))
+ '(/fixnum -c/fixnum /signed -c/signed /unsigned -c/unsigned)
+ '(4 3 6 5 6 5)
+ '(t t t t nil nil))))
(: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)
(: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)
(:arg-types unsigned-num tagged-num)
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num))
(:arg-types unsigned-num tagged-num)
(:results (r :scs (unsigned-reg)))
(:result-types unsigned-num))
(:variant bignum-digits-offset other-pointer-lowtag)
(:translate sb!bignum:%bignum-set)
(:args (object :scs (descriptor-reg))
(:variant bignum-digits-offset other-pointer-lowtag)
(:translate sb!bignum:%bignum-set)
(:args (object :scs (descriptor-reg))
(:arg-types t positive-fixnum unsigned-num)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num))
(:arg-types t positive-fixnum unsigned-num)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num))
(defun emit-multiply (multiplier multiplicand result-high result-low)
"Emit code to multiply MULTIPLIER with MULTIPLICAND, putting the result
in RESULT-HIGH and RESULT-LOW. KIND is either :signed or :unsigned.
Note: the lifetimes of MULTIPLICAND and RESULT-HIGH overlap."
(declare (type tn multiplier result-high result-low)
(defun emit-multiply (multiplier multiplicand result-high result-low)
"Emit code to multiply MULTIPLIER with MULTIPLICAND, putting the result
in RESULT-HIGH and RESULT-LOW. KIND is either :signed or :unsigned.
Note: the lifetimes of MULTIPLICAND and RESULT-HIGH overlap."
(declare (type tn multiplier result-high result-low)
;; It seems that emit-multiply is only used to do an unsigned
;; multiply, so the code only does an unsigned multiply.
(cond
;; It seems that emit-multiply is only used to do an unsigned
;; multiply, so the code only does an unsigned multiply.
(cond
;; Multiply the two numbers and put the result in
;; result-high. Copy the low 32-bits to result-low. Then
;; shift result-high so the high 32-bits end up in the low
;; Multiply the two numbers and put the result in
;; result-high. Copy the low 32-bits to result-low. Then
;; shift result-high so the high 32-bits end up in the low
(inst move result-low result-high)
(inst srax result-high 32))
((or (member :sparc-v8 *backend-subfeatures*)
(inst move result-low result-high)
(inst srax result-high 32))
((or (member :sparc-v8 *backend-subfeatures*)
;; V8 has a multiply instruction. This should also work for
;; the V9, but umul and the Y register is deprecated on the
;; V9.
;; V8 has a multiply instruction. This should also work for
;; the V9, but umul and the Y register is deprecated on the
;; V9.
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from (:eval 0))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from (:eval 0))
- (y :scs (unsigned-reg) :to (:eval 1))
- (prev :scs (unsigned-reg) :to (:eval 2))
- (carry-in :scs (unsigned-reg) :to (:eval 2)))
+ (y :scs (unsigned-reg) :to (:eval 1))
+ (prev :scs (unsigned-reg) :to (:eval 2))
+ (carry-in :scs (unsigned-reg) :to (:eval 2)))
(:arg-types unsigned-num unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from (:eval 0))
(:arg-types unsigned-num unsigned-num unsigned-num unsigned-num)
(:results (hi :scs (unsigned-reg) :from (:eval 0))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (quo :scs (unsigned-reg) :from (:argument 1))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (quo :scs (unsigned-reg) :from (:argument 1))
(inst not quo)))
(define-vop (bignum-floor-v8)
(:translate sb!bignum:%floor)
(:policy :fast-safe)
(:args (div-high :scs (unsigned-reg) :target rem)
(inst not quo)))
(define-vop (bignum-floor-v8)
(:translate sb!bignum:%floor)
(:policy :fast-safe)
(:args (div-high :scs (unsigned-reg) :target rem)
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (quo :scs (unsigned-reg) :from (:argument 1))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:results (quo :scs (unsigned-reg) :from (:argument 1))
(:result-types unsigned-num unsigned-num)
(:temporary (:scs (unsigned-reg) :target quo) q)
;; This vop is for a v8 or v9, provided we're also not using
;; sparc-64, for which there a special sparc-64 vop.
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:result-types unsigned-num unsigned-num)
(:temporary (:scs (unsigned-reg) :target quo) q)
;; This vop is for a v8 or v9, provided we're also not using
;; sparc-64, for which there a special sparc-64 vop.
(:guard (or (member :sparc-v8 *backend-subfeatures*)
(:arg-types unsigned-num unsigned-num unsigned-num)
(:temporary (:sc unsigned-reg :from (:argument 0)) dividend)
(:results (quo :scs (unsigned-reg))
(:arg-types unsigned-num unsigned-num unsigned-num)
(:temporary (:sc unsigned-reg :from (:argument 0)) dividend)
(:results (quo :scs (unsigned-reg))
(:arg-types unsigned-num positive-fixnum)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num)
(:arg-types unsigned-num positive-fixnum)
(:results (result :scs (unsigned-reg)))
(:result-types unsigned-num)
"recode as shifts and adds"
(let ((y (lvar-value y)))
(multiple-value-bind (result adds shifts)
"recode as shifts and adds"
(let ((y (lvar-value y)))
(multiple-value-bind (result adds shifts)
(cond
;; we assume, perhaps foolishly, that good SPARCs don't have an
;; issue with multiplications. (Remember that there's a
;; different transform for converting x*2^k to a shift).
((member :sparc-64 *backend-subfeatures*) (give-up-ir1-transform))
((or (member :sparc-v9 *backend-subfeatures*)
(cond
;; we assume, perhaps foolishly, that good SPARCs don't have an
;; issue with multiplications. (Remember that there's a
;; different transform for converting x*2^k to a shift).
((member :sparc-64 *backend-subfeatures*) (give-up-ir1-transform))
((or (member :sparc-v9 *backend-subfeatures*)
- (member :sparc-v8 *backend-subfeatures*))
- ;; breakeven point as measured by Raymond Toy
- (when (> (+ adds shifts) 9)
- (give-up-ir1-transform))))
+ (member :sparc-v8 *backend-subfeatures*))
+ ;; breakeven point as measured by Raymond Toy
+ (when (> (+ adds shifts) 9)
+ (give-up-ir1-transform))))