Commit 351351df authored by Raymond Toy's avatar Raymond Toy
Browse files

Simplify bignum-shld and bignum-shrd vops.

One temp variable for bignum-shld can be removed and the only temp
variable for bignum-shld-c can be removed.  Base this on the
digit-ashr vops.  This makes the vops simpler and faster.
parent 909ad007
Loading
Loading
Loading
Loading
+25 −57
Original line number Diff line number Diff line
@@ -1583,80 +1583,48 @@
(define-vop (bignum-shld)
  (:policy :fast-safe)
  (:translate bignum::%shld)
  (:args (x :scs (unsigned-reg) :target r)
	 (shift-in :scs (unsigned-reg))
  (:args (x :scs (unsigned-reg unsigned-stack) :target r)
	 (shift-in :scs (unsigned-reg) :to :result)
	 (amount :scs (unsigned-reg) :target cl))
  (:arg-types unsigned-num unsigned-num unsigned-num)
  (:results (r :scs (unsigned-reg)))
  (:results (r :scs (unsigned-reg)
	       :load-if (not (and (sc-is r unsigned-stack)
				  (location= x r)))))
  (:result-types unsigned-num)
  (:temporary (:sc unsigned-reg :from (:argument 0) :to (:result 0)) temp)
  (:temporary (:sc unsigned-reg :offset ecx-offset
		   :from (:argument 2) :to (:result 0)) cl)
  (:generator 4
		   :from (:argument 2)) cl)
  (:generator 3
    (move cl amount)
    (cond ((location= x r)
	   (inst shld x shift-in :cl))
	  (t
	   (move temp x)
	   (inst shld temp shift-in :cl)
	   (move r temp)))))
    (move r x)
    (inst shld r shift-in :cl)))
  
(define-vop (bignum-shld-c)
  (:policy :fast-safe)
  (:translate bignum::%shld)
  (:args (x :scs (unsigned-reg) :target r)
	 (shift-in :scs (unsigned-reg)))
  (:args (x :scs (unsigned-reg unsigned-stack) :target r)
	 (shift-in :scs (unsigned-reg) :to :save))
  (:info shift)
  (:arg-types unsigned-num unsigned-num (:constant (unsigned-byte 5)))
  (:results (r :scs (unsigned-reg)))
  (:results (r :scs (unsigned-reg)
	       :load-if (not (and (sc-is r unsigned-stack)
				  (location= x r)))))
  (:result-types unsigned-num)
  (:temporary (:sc unsigned-reg :from (:argument 0) :to (:result 0)) temp)
  (:generator 3
    (cond ((location= x r)
	   (inst shld x shift-in shift))
	  (t
	   (move temp x)
	   (inst shld temp shift-in shift)
	   (move r temp)))))
  (:generator 2
    (move r x)
    (inst shld r shift-in shift)))

(define-vop (bignum-shrd)
  (:policy :fast-safe)
(define-vop (bignum-shrd bignum-shld)
  (:translate bignum::%shrd)
  (:args (x :scs (unsigned-reg) :target r)
	 (shift-in :scs (unsigned-reg))
	 (amount :scs (unsigned-reg) :target cl))
  (:arg-types unsigned-num unsigned-num unsigned-num)
  (:results (r :scs (unsigned-reg)))
  (:result-types unsigned-num)
  (:temporary (:sc unsigned-reg :from (:argument 0) :to (:result 0)) temp)
  (:temporary (:sc unsigned-reg :offset ecx-offset
		   :from (:argument 2) :to (:result 0)) cl)
  (:generator 4
  (:generator 3
    (move cl amount)
    (cond ((location= x r)
	   (inst shrd x shift-in :cl))
	  (t
	   (move temp x)
	   (inst shrd temp shift-in :cl)
	   (move r temp)))))
    (move r x)
    (inst shrd r shift-in :cl)))

(define-vop (bignum-shrd-c)
  (:policy :fast-safe)
(define-vop (bignum-shrd-c bignum-shld-c)
  (:translate bignum::%shrd)
  (:args (x :scs (unsigned-reg))
	 (shift-in :scs (unsigned-reg)))
  (:info shift)
  (:arg-types unsigned-num unsigned-num (:constant (unsigned-byte 5)))
  (:results (r :scs (unsigned-reg)))
  (:result-types unsigned-num)
  (:temporary (:sc unsigned-reg :from (:argument 0) :to (:result 0)) temp)
  (:generator 3
    (cond ((location= x r)
	   (inst shrd x shift-in shift))
	  (t
	   (move temp x)
	   (inst shrd temp shift-in shift)
	   (move r temp)))))
  (:generator 2
    (move r x)
    (inst shrd r shift-in shift)))