Changeset 15569


Ignore:
Timestamp:
Jan 8, 2013, 8:25:19 AM (6 years ago)
Author:
gb
Message:

Nuke %MULTIPLY-AND-ADD-LOOP, add %MULTIPLY-AND-ADD-FIXNUM-LOOP for
x8664.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/X86/X8664/x8664-bignum.lisp

    r13432 r15569  
    3636  (single-value-return))
    3737 
    38 ;; multiply x[i] by y and add to result starting at digit idx
    39 (defx86lapfunction %multiply-and-add-loop
    40     ((x 16) (y 8) #|(ra 0)|# (r arg_x) (idx arg_y) (ylen arg_z))
    41   (let ((cc mm2)
    42         (xx mm3)
    43         (yy mm4)
    44         (rr mm5)
    45         (i imm0)
    46         (j imm1))
    47     (unbox-fixnum idx i)
    48     (movq (@ x (% rsp)) (% temp0))
    49     (movd (@ x8664::misc-data-offset (% temp0) (% i) 4) (% xx)) ;x[i]
    50     (movq (@ y (% rsp)) (% temp0))
    51     (movq (% r) (% temp1))
    52     (pxor (% cc) (% cc))
    53     (xorq (% j) (% j))
    54     @loop
    55     (movd (@ x8664::misc-data-offset (% temp0) (% j) 4) (% yy)) ;y[j]
    56     (pmuludq (% xx) (% yy))
    57     ;; 64-bit product now in %yy
    58     (movd (@ x8664::misc-data-offset (% temp1) (% i) 4) (% rr))
    59     ;; add in digit from r[i]
    60     (paddq (% yy) (% rr))
    61     ;; add in carry
    62     (paddq (% cc) (% rr))
    63     (movd (% rr) (@ x8664::misc-data-offset (% temp1) (% i) 4)) ;update r[i]
    64     (movq (% rr) (% cc))
    65     (psrlq ($ 32) (% cc))               ;get carry digit into low word
    66     (addq ($ 1) (% i))
    67     (addq ($ 1) (% j))
    68     (subq ($ '1) (% ylen))
    69     (jg @loop)
    70     (movd (% cc) (@ x8664::misc-data-offset (% temp1) (% i) 4))
    71     (single-value-return 4)))
     38
    7239
    7340(defx86lapfunction %multiply-and-add-loop64
     
    157124    (set-nargs 2)
    158125    (jmp-subprim .SPvalues)))
     126
     127
     128(defx86lapfunction %multiply-and-add-fixnum-loop ((len64 8) #||(ra 0)||# (x arg_x) (y arg_y) (result arg_z))
     129  (let ((carry imm2)
     130        (i temp0)
     131        (rlen temp1))
     132    (movq (@ len64 (% rsp)) (% rlen))
     133    (xorl (%l carry) (%l carry))
     134    (xorl (%l i) (%l i))
     135    (jmp @test)
     136    @loop
     137    (unbox-fixnum y rax)
     138    (mulq (@ x8664::misc-data-offset (% x) (% i)))
     139    (addq (% carry) (% rax))
     140    (adcq ($ 0) (% rdx))
     141    (movq (% rdx) (% carry))
     142    (movq (% rax) (@ x8664::misc-data-offset (% result) (% i)))
     143    (addq ($ 8) (% i))
     144    @test
     145    (cmpq (% rlen) (% i))
     146    (jl @loop)
     147    (movq (% carry) (@ x8664::misc-data-offset (% result) (% i)))
     148    (single-value-return 3)))
     149   
     150   
     151
     152   
     153
     154
     155;;; Set the ith 64-bit digit of BIGNUM to R
     156(defx86lapfunction %set-digit ((bignum arg_x) (i arg_y) (r arg_z))
     157
     158  (movq (@ x8664::misc-data-offset (% r)) (% imm0))
     159  (movq (% imm0) (@ x8664::misc-data-offset (% bignum) (% i)))
     160  (single-value-return))
    159161
    160162;;; Return the (possibly truncated) 32-bit quotient and remainder
Note: See TracChangeset for help on using the changeset viewer.