Changeset 12973
- Timestamp:
- Oct 9, 2009, 1:40:00 PM (15 years ago)
- Location:
- branches/working-0711/ccl/level-0
- Files:
-
- 2 edited
-
X86/X8664/x8664-bignum.lisp (modified) (1 diff)
-
l0-bignum64.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/level-0/X86/X8664/x8664-bignum.lisp
r11164 r12973 71 71 (single-value-return 4))) 72 72 73 (defx86lapfunction %multiply-and-add-loop64 74 ((xs 16) (ys 8) #|(ra 0)|# (r arg_x) (i arg_y) (ylen arg_z)) 75 (let ((y temp2) 76 (j temp0) 77 (c imm2)) 78 (movq (@ xs (% rsp)) (% temp0)) 79 (movq (@ x8664::misc-data-offset (% temp0) (% i)) (% mm0)) ;x[i] 80 (movq (@ ys (% rsp)) (% y)) 81 (xorl (%l j) (%l j)) 82 (xorl (%l c) (%l c)) 83 @loop 84 ;; It's a pity to have to reload this every time, but there's no 85 ;; imm3. (Give him 16 registers, and he still complains...) 86 (movd (% mm0) (% rax)) 87 (mulq (@ x8664::misc-data-offset (% y) (% j))) ;128-bit x * y[j] in rdx:rax 88 (addq (@ x8664::misc-data-offset (% r) (% i)) (% rax)) ;add in r[i] 89 (adcq ($ 0) (% rdx)) 90 ;; add in carry digit 91 (addq (% c) (% rax)) 92 (movl ($ 0) (%l c)) 93 (adcq (% rdx) (% c)) ;new carry digit 94 (movq (% rax) (@ x8664::misc-data-offset (% r) (% i))) ;update r[i] 95 (addq ($ '1) (% i)) 96 (addq ($ '1) (% j)) 97 (subq ($ '1) (% ylen)) 98 (ja @loop) 99 (movq (% c) (@ x8664::misc-data-offset (% r) (% i))) 100 (single-value-return 4))) 73 101 74 102 ;;; Multiply the (32-bit) digits X and Y, producing a 64-bit result. -
branches/working-0711/ccl/level-0/l0-bignum64.lisp
r12048 r12973 804 804 (len-b (%bignum-length b)) 805 805 (len-res (+ len-a len-b)) 806 (res (%allocate-bignum len-res)) )806 (res (%allocate-bignum len-res))) 807 807 (declare (bignum-index len-a len-b len-res)) 808 808 (dotimes (i len-a) 809 809 (declare (type bignum-index i)) 810 810 (%multiply-and-add-loop a b res i len-b)) 811 res)) 812 (multiply-unsigned-bignums64 (a b) 813 (let* ((len-a (ceiling (%bignum-length a) 2)) 814 (len-b (ceiling (%bignum-length b) 2)) 815 (len-res (+ len-a len-b)) 816 (res (%allocate-bignum (+ len-res len-res)))) 817 (declare (bignum-index len-a len-b len-res)) 818 (dotimes (i len-a) 819 (declare (type bignum-index i)) 820 (%multiply-and-add-loop64 a b res i len-b)) 811 821 res))) 812 (let* ((res (with-negated-bignum-buffers a b multiply-unsigned-bignums))) 822 (let* ((res (with-negated-bignum-buffers a b 823 multiply-unsigned-bignums64))) 813 824 (if signs-differ (negate-bignum-in-place res)) 814 825 (%normalize-bignum-macro res))))) 815 826 816 827 (defun multiply-bignum-and-fixnum (bignum fixnum) 828 (declare (type bignum-type bignum) (fixnum fixnum)) 829 (if (eql fixnum 1) 830 bignum 831 (with-small-bignum-buffers ((big-fix fixnum)) 832 (multiply-bignums bignum big-fix)))) 833 834 #+slower 817 835 (defun multiply-bignum-and-fixnum (bignum fixnum) 818 836 (declare (type bignum-type bignum) (fixnum fixnum))
Note:
See TracChangeset
for help on using the changeset viewer.
