X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fgmp%2Fmpn%2Fx86%2Fp6%2Fmmx%2Fmod_1.asm;fp=rts%2Fgmp%2Fmpn%2Fx86%2Fp6%2Fmmx%2Fmod_1.asm;h=0000000000000000000000000000000000000000;hb=fdf1cd0399158308769fcb2ab7e46e215a68d865;hp=e7d8d94d3337fa8862eee3ae454d34bc6755351e;hpb=e552cfc427d2734b9a9629f2ab1d22f493e775f6;p=ghc-hetmet.git diff --git a/rts/gmp/mpn/x86/p6/mmx/mod_1.asm b/rts/gmp/mpn/x86/p6/mmx/mod_1.asm deleted file mode 100644 index e7d8d94..0000000 --- a/rts/gmp/mpn/x86/p6/mmx/mod_1.asm +++ /dev/null @@ -1,444 +0,0 @@ -dnl Intel Pentium-II mpn_mod_1 -- mpn by limb remainder. -dnl -dnl P6MMX: 24.0 cycles/limb. - - -dnl Copyright (C) 1999, 2000 Free Software Foundation, Inc. -dnl -dnl This file is part of the GNU MP Library. -dnl -dnl The GNU MP Library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public License as -dnl published by the Free Software Foundation; either version 2.1 of the -dnl License, or (at your option) any later version. -dnl -dnl The GNU MP Library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with the GNU MP Library; see the file COPYING.LIB. If -dnl not, write to the Free Software Foundation, Inc., 59 Temple Place - -dnl Suite 330, Boston, MA 02111-1307, USA. - - -include(`../config.m4') - - -C mp_limb_t mpn_mod_1 (mp_srcptr src, mp_size_t size, mp_limb_t divisor); -C mp_limb_t mpn_mod_1c (mp_srcptr src, mp_size_t size, mp_limb_t divisor, -C mp_limb_t carry); -C -C The code here very similar to mpn_divrem_1, but with the quotient -C discarded. What's here probably isn't optimal. -C -C See mpn/x86/p6/mmx/divrem_1.c and mpn/x86/k7/mmx/mod_1.asm for some -C comments. - - -dnl MUL_THRESHOLD is the size at which the multiply by inverse method is -dnl used, rather than plain "divl"s. Minimum value 2. - -deflit(MUL_THRESHOLD, 4) - - -defframe(PARAM_CARRY, 16) -defframe(PARAM_DIVISOR,12) -defframe(PARAM_SIZE, 8) -defframe(PARAM_SRC, 4) - -defframe(SAVE_EBX, -4) -defframe(SAVE_ESI, -8) -defframe(SAVE_EDI, -12) -defframe(SAVE_EBP, -16) - -defframe(VAR_NORM, -20) -defframe(VAR_INVERSE, -24) -defframe(VAR_SRC_STOP,-28) - -deflit(STACK_SPACE, 28) - - .text - ALIGN(16) - -PROLOGUE(mpn_mod_1c) -deflit(`FRAME',0) - movl PARAM_CARRY, %edx - movl PARAM_SIZE, %ecx - subl $STACK_SPACE, %esp -deflit(`FRAME',STACK_SPACE) - - movl %ebp, SAVE_EBP - movl PARAM_DIVISOR, %ebp - - movl %esi, SAVE_ESI - movl PARAM_SRC, %esi - jmp LF(mpn_mod_1,start_1c) - -EPILOGUE() - - - ALIGN(16) -PROLOGUE(mpn_mod_1) -deflit(`FRAME',0) - - movl $0, %edx C initial carry (if can't skip a div) - movl PARAM_SIZE, %ecx - subl $STACK_SPACE, %esp -deflit(`FRAME',STACK_SPACE) - - movl %esi, SAVE_ESI - movl PARAM_SRC, %esi - - movl %ebp, SAVE_EBP - movl PARAM_DIVISOR, %ebp - - orl %ecx, %ecx - jz L(divide_done) - - movl -4(%esi,%ecx,4), %eax C src high limb - - cmpl %ebp, %eax C carry flag if high n2 - leal (%ebp,%esi), %edx - - cmovc( %edx, %edi) C n - q1*d if underflow from using q1+1 - movd %mm0, %esi - cmpl %ebx, %ecx - - jne L(inverse_top) - - -L(inverse_loop_done): - - -C ----------------------------------------------------------------------------- - -L(inverse_two_left): - C eax scratch - C ebx scratch (nadj, q1) - C ecx &src[-1] - C edx scratch - C esi n10 - C edi n2 - C ebp divisor - C - C mm0 scratch (src dword) - C mm7 rshift - - movl %esi, %eax - movl %ebp, %ebx - - sarl $31, %eax C -n1 - - andl %eax, %ebx C -n1 & d - negl %eax C n1 - - addl %esi, %ebx C nadj = n10 + (-n1 & d), ignoring overflow - addl %edi, %eax C n2+n1 - - mull VAR_INVERSE C m*(n2+n1) - - movd 4(%ecx), %mm0 C src low limb - - C - - C - - C - - addl %ebx, %eax C m*(n2+n1) + nadj, low giving carry flag - leal 1(%edi), %ebx C n2<<32 + m*(n2+n1)) - - adcl %edx, %ebx C 1 + high(n2<<32 + m*(n2+n1) + nadj) = q1+1 - - sbbl $0, %ebx - movl %ebp, %eax C d - - mull %ebx C (q1+1)*d - - psllq $32, %mm0 - - psrlq %mm7, %mm0 - - C - - C - - subl %eax, %esi - - sbbl %edx, %edi C n - (q1+1)*d - movl %esi, %edi C remainder -> n2 - leal (%ebp,%esi), %edx - - cmovc( %edx, %edi) C n - q1*d if underflow from using q1+1 - movd %mm0, %esi - - -C One limb left - - C eax scratch - C ebx scratch (nadj, q1) - C ecx - C edx scratch - C esi n10 - C edi n2 - C ebp divisor - C - C mm0 src limb, shifted - C mm7 rshift - - movl %esi, %eax - movl %ebp, %ebx - - sarl $31, %eax C -n1 - - andl %eax, %ebx C -n1 & d - negl %eax C n1 - - addl %esi, %ebx C nadj = n10 + (-n1 & d), ignoring overflow - addl %edi, %eax C n2+n1 - - mull VAR_INVERSE C m*(n2+n1) - - movl VAR_NORM, %ecx C for final denorm - - C - - C - - C - - addl %ebx, %eax C m*(n2+n1) + nadj, low giving carry flag - leal 1(%edi), %ebx C n2<<32 + m*(n2+n1)) - - adcl %edx, %ebx C 1 + high(n2<<32 + m*(n2+n1) + nadj) = q1+1 - - sbbl $0, %ebx - movl %ebp, %eax C d - - mull %ebx C (q1+1)*d - - movl SAVE_EBX, %ebx - - C - - C - - C - - subl %eax, %esi - - sbbl %edx, %edi C n - (q1+1)*d - leal (%ebp,%esi), %edx - movl SAVE_EBP, %ebp - - movl %esi, %eax C remainder - movl SAVE_ESI, %esi - - cmovc( %edx, %eax) C n - q1*d if underflow from using q1+1 - movl SAVE_EDI, %edi - - shrl %cl, %eax C denorm remainder - addl $STACK_SPACE, %esp - emms - - ret - - -C ----------------------------------------------------------------------------- -C -C Special case for q1=0xFFFFFFFF, giving q=0xFFFFFFFF meaning the low dword -C of q*d is simply -d and the remainder n-q*d = n10+d - -L(q1_ff): - C eax (divisor) - C ebx (q1+1 == 0) - C ecx src pointer - C edx - C esi n10 - C edi (n2) - C ebp divisor - - leal (%ebp,%esi), %edi C n-q*d remainder -> next n2 - movl VAR_SRC_STOP, %edx - psrlq %mm7, %mm0 - - movd %mm0, %esi C next n10 - cmpl %ecx, %edx - jne L(inverse_top) - - jmp L(inverse_loop_done) - -EPILOGUE()