Update copyright notices in Windows assembler code

This commit is contained in:
gladman 2009-01-10 15:15:37 +00:00
parent 7a9a69af3c
commit b8969d6bbc
18 changed files with 354 additions and 232 deletions

View File

@ -1,27 +1,26 @@
; YASM translation of code provided by P. Gaudry for AMD64, converted
; by Brian Gladman.
;
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2005, 2006 Pierrick Gaudry
;
; The GNU MP Library is free software; you can redistribute it and/or
; Copyright 2008 Brian Gladman
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_add_n/mpn_sub_n -- mpn add or subtract.
;
@ -139,7 +138,7 @@
%define cry_hi rsi ; second carry for alternate block
%%3:
prologue %3%4, reg_save_list, 0
prologue %3%4, 0, reg_save_list
lea rep_cnt,[len-2]
dec len
shr rep_cnt,UNROLL_LOG2
@ -199,7 +198,7 @@ prologue %3%4, reg_save_list, 0
%2 [dst-off+8],rax
adc rdx,len
mov rax,rdx
epilogue reg_save_list, 0
epilogue reg_save_list
%endmacro

View File

@ -1,24 +1,26 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2005, 2006 Pierrick Gaudry
;
; The GNU MP Library is free software; you can redistribute it and/or
; Copyright 2008 Brian Gladman
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_mul_1 -- mpn by limb multiply.
;

View File

@ -1,27 +1,26 @@
; YASM translation of code provided by P. Gaudry for AMD64, converted
; by Brian Gladman.
;
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2005, 2006 Pierrick Gaudry
;
; The GNU MP Library is free software; you can redistribute it and/or
; Copyright 2008 Brian Gladman
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_mul_basecase -- multiply two mpn numbers.
;
@ -133,7 +132,7 @@ mul_2_by_2: ; r8 (x_len) and r10 (y_len) free
mul_m_by_n:
mov r10d, dword[rsp+0x28] ; load as a 32-bit integer
prologue fmul_m_by_n, reg_save_list, 3
prologue fmul_m_by_n, 3, reg_save_list
mov x_ptr,rdx
mov r12,x_len
mov rbp,rax ; y[0] -> rbp
@ -267,6 +266,6 @@ L_unroll:
mov [rdi+8],rdx
jnz .2
L_exit:
epilogue reg_save_list, 3
epilogue reg_save_list
end

View File

@ -1,27 +1,26 @@
; YASM translation of code provided by P. Gaudry for AMD64, converted
; by Brian Gladman.
;
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2005, 2006 Pierrick Gaudry
;
; The GNU MP Library is free software; you can redistribute it and/or
; Copyright 2008 Brian Gladman
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_sqr_basecase -- square an mpn number.
;
@ -109,7 +108,7 @@ sqr_2:
adc [r_ptr+24],rcx
ret
prologue sqr_3_plus, reg_save_list, 0
prologue sqr_3_plus, 0, reg_save_list
mov r_ptr,rcx
mov x_ptr,rdx
cmp x_len,4
@ -328,6 +327,6 @@ L_corner:
jnz .1
add [rdi-8],rdx
sqr_exit:
epilogue reg_save_list, 0
epilogue reg_save_list
end

View File

@ -1,27 +1,26 @@
; YASM translation of code provided by P. Gaudry for AMD64, converted
; by Brian Gladman.
;
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2005, 2006 Pierrick Gaudry
;
; The GNU MP Library is free software; you can redistribute it and/or
; Copyright 2008 Brian Gladman
;
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_add_n/mpn_sub_n -- mpn add or subtract.
;

View File

@ -1,24 +1,24 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Provided by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_copyd -- decrementing copy limb vector
;

View File

@ -1,25 +1,25 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
; Provided by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; AMD64 mpn_copyi -- incrementing copy limb vector
;
; Calling interface:

View File

@ -1,19 +1,22 @@
; Copyright 2001, 2002 Free Software Foundation, Inc.
; Copyright 2006 Jason Worth Martin <jason.worth.martin@gmail.com>
;
; This file is part of the GNU MP Library.
; Copyright 2008, 2009 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
@ -157,7 +160,7 @@ __gmpn_%1mul_1:
__gmpn_%1mul_1c:
mov a_z, [rsp+0x28]
prologue %%1, reg_save_list, 0
prologue %%1, 0, reg_save_list
mov rdi, rcx
mov rsi, rdx
xor rdx, rdx
@ -328,7 +331,7 @@ prologue %%1, reg_save_list, 0
mov [rp+index*8-8], a_z
adc rax, rdx
%%13:
epilogue reg_save_list, 0
epilogue reg_save_list
%endmacro
bits 64

View File

@ -1,19 +1,22 @@
; Copyright 2001, 2002 Free Software Foundation, Inc.
; Copyright 2006 Jason Worth Martin <jason.worth.martin@gmail.com>
;
; This file is part of the GNU MP Library.
; Copyright 2008, 2009 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
@ -156,11 +159,11 @@
__gmpn_mul_1:
xor r10, r10
jmp entry
__gmpn_mul_1c:
mov a_z, [rsp+0x28]
prologue entry, reg_save_list, 0
prologue entry, 0, reg_save_list
mov rdi, rcx
mov rsi, rdx
xor rdx, rdx
@ -314,6 +317,6 @@ prologue entry, reg_save_list, 0
mov [rp+index*8-8], rax
mov rax, rdx
.mul_1_exit:
epilogue reg_save_list,0
epilogue reg_save_list
end

View File

@ -1,19 +1,22 @@
; Copyright 2001, 2002 Free Software Foundation, Inc.
; Copyright 2006 Jason Worth Martin <jason.worth.martin@gmail.com>
;
; This file is part of the GNU MP Library.
; Copyright 2008, 2009 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
@ -122,7 +125,7 @@
export __gmpn_mul_basecase
%endif
prologue __gmpn_mul_basecase, reg_save_list, 0
prologue __gmpn_mul_basecase, 0, reg_save_list
mov rdi, rcx
mov rsi, rdx
mov rdx, r8
@ -440,6 +443,6 @@ mul_loop_end:
jnz mul_loop
exit:
epilogue reg_save_list, 0
epilogue reg_save_list
end

View File

@ -1,19 +1,22 @@
; Copyright 2001, 2002 Free Software Foundation, Inc.
; Copyright 2006 Jason Worth Martin <jason.worth.martin@gmail.com>
;
; This file is part of the GNU MP Library.
; Copyright 2008, 2009 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
@ -202,10 +205,10 @@ __gmpn_sqr_basecase:
mov [rcx+40], rax
ret
prologue sqr_basecase, reg_save_list, 0
prologue sqr_basecase, 0, reg_save_list
mov rdi, rcx
mov rsi, r8
movq xmm2, rdx
add s1p, 8
add rp, 8
@ -559,6 +562,6 @@ outer_end:
add a_x, 2
jnz .2
add [rp+08], rdx
epilogue reg_save_list, 0
epilogue reg_save_list
end

View File

@ -1,24 +1,24 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_divexact_1 -- mpn by limb exact division
;
@ -68,7 +68,7 @@ L_div_top:
jnz L_div_top
rep ret ; avoid single byte return
prologue L_mul_by_inverse, reg_save_list, 0
prologue L_mul_by_inverse, 0, reg_save_list
mov rsi,rdx ; src pointer
mov rdi,rcx ; dst pointer
mov rax,r9
@ -155,6 +155,6 @@ L_even_entry:
imul rax,r10
mov [rdi-8],rax
L_exit:
epilogue reg_save_list, 0
epilogue reg_save_list
end

View File

@ -1,24 +1,24 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_lshift -- mpn left shift
;

View File

@ -1,68 +1,30 @@
; Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
; Foundation, Inc.
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
;
; cycles/limb
; Hammer: 10
; Prescott/Nocona: 33
; mp_limb_t mpn_modexact_1_odd (mp_srcptr src, mp_size_t size,
; mp_limb_t divisor);
; mp_limb_t mpn_modexact_1c_odd (mp_srcptr src, mp_size_t size,
; mp_limb_t divisor, mp_limb_t carry);
;
; The dependent chain in the main loop is
;
; cycles
; subq %r8, %rax 1
; imulq %r9, %rax 4
; mulq %rsi 5
; ----
; total 10
;
; The movq load from src seems to need to be scheduled back before the jz to
; achieve this speed, out-of-order execution apparently can't completely
; hide the latency otherwise.
;
; The l=src[i]-cbit step is rotated back too, since that allows us to avoid
; it for the first iteration (where there's no cbit).
;
; The code alignment used (32-byte) for the loop also seems necessary.
; Without that the non-PIC case has adcq crossing the 0x60 offset,
; apparently making it run at 11 cycles instead of 10.
;
; Not done:
;
; divq for size==1 was measured at about 79 cycles, compared to the inverse
; at about 25 cycles (both including function call overheads), so that's not
; used.
;
; Enhancements:
;
; For PIC, we shouldn't really need the GOT fetch for modlimb_invert_table,
; it'll be in rodata or text in libgmp.so and can be accessed directly %rip
; relative. This would be for small model only (something we don't
; presently detect, but which is all that gcc 3.3.3 supports), since 8-byte
; PC-relative relocations are apparently not available. Some rough
; experiments with binutils 2.13 looked worrylingly like it might come out
; with an unwanted text segment relocation though, even with ".protected".
; AMD64 mpn_modexact_1_odd -- exact division style remainder.
;
; mp_limb_t mpn_modexact_1_odd (
@ -99,7 +61,7 @@
__gmpn_modexact_1_odd:
mov r9, 0 ; carry
prologue __gmpn_modexact_1c_odd, reg_save_list, 0
prologue __gmpn_modexact_1c_odd, 0, reg_save_list
; first use Newton's iteration to invert the divisor limb (d) using
; f(x) = 1/x - d and x[i+1] = x[i] - f(x[i]) / f'(x[i]) to give
@ -156,6 +118,6 @@ prologue __gmpn_modexact_1c_odd, reg_save_list, 0
imul rax, r10
mul r8
lea rax, [rcx+rdx]
epilogue reg_save_list, 0
epilogue reg_save_list
end

View File

@ -1,24 +1,24 @@
; Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;
; This file is part of the GNU MP Library.
; Copyright 2008 Brian Gladman
;
; The GNU MP Library is free software; you can redistribute it and/or
; This file is part of the MPIR Library.
;
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 59 Temple Place -
; Suite 330, Boston, MA 02111-1307, USA.
;
; Adapted by Brian Gladman AMD64 using the Microsoft VC++ v8 64-bit
; compiler and the YASM assembler.
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
; AMD64 mpn_rshift -- mpn right shift
;

View File

@ -1,19 +1,20 @@
; Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
; Copyright 2008 Brian Gladman
;
; This file is part of the GNU MP Library.
; This file is part of the MPIR Library.
;
; The GNU MP Library is free software; you can redistribute it and/or
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.
@ -42,4 +43,3 @@ __gmpn_udiv_qrnnd:
ret
end

View File

@ -1,19 +1,20 @@
; Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
; Copyright 2008 Brian Gladman
;
; This file is part of the GNU MP Library.
; This file is part of the MPIR Library.
;
; The GNU MP Library is free software; you can redistribute it and/or
; The MPIR Library is free software; you can redistribute it and/or
; modify it under the terms of the GNU Lesser General Public License as
; published by the Free Software Foundation; either version 2.1 of the
; License, or (at your option) any later version.
;
; The GNU MP Library is distributed in the hope that it will be useful,
; The MPIR Library is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; Lesser General Public License for more details.
;
; You should have received a copy of the GNU Lesser General Public
; License along with the GNU MP Library; see the file COPYING.LIB. If
; License along with the MPIR Library; see the file COPYING.LIB. If
; not, write to the Free Software Foundation, Inc., 51 Franklin Street,
; Fifth Floor, Boston, MA 02110-1301, USA.

View File

@ -1,50 +1,106 @@
;
; YASM macros for handling Windows Prologues and Epilogues
;
; Copyright 2008, 2009 Brian Gladman
; Windows x64 prologue macro
;
; prologue name, register list, stack space
; prologue name, stack_slots, register_save_list
;
; name: routine name
; register list: comma separated list of registers to save
; stack space: stack space needed in 8 byte units
; name: routine name
; register_save_list: comma separated list of registers to save
; stack_slots: stack space needed in 8 byte units
; Windows x64 epilogue macro
;
; epilogue register list, stack space
; epilogue register_save_list
;
; register list: comma separated list of registers to save
; in same order used in prologue
; stack space: stack space used in 8 byte units
; register_save_list: comma separated list of registers to save
; in same order used in prologue
%ifdef _WIN64_ABI
%macro prologue 1-*
PROC_FRAME %1
%rotate 1
%rep %0 - 2
push_reg %1
%rotate 1
%endrep
%if ((%0 + %1) & 1) == 0
alloc_stack 8 * (%1 + 1)
%elif %1 > 0
alloc_stack 8 * %1
%endif
END_PROLOGUE
%define r0 rax
%define r1 rdx
%define r2 rcx
%define r3 rbx
%define r4 rsi
%define r5 rdi
%define r6 rbp
%define r7 rsp
%define r0d eax
%define r1d edx
%define r2d ecx
%define r3d ebx
%define r4d esi
%define r5d edi
%define r6d ebp
%define r7d esp
%define r0w ax
%define r1w dx
%define r2w cx
%define r3w bx
%define r4w si
%define r5w di
%define r6w bp
%define r7w sp
%define r0b al
%define r1b dl
%define r2b cl
%define r3b bl
%define r4b sil
%define r5b dil
%define r6b bpl
%define r7b spl
%macro prologue 2-*
PROC_FRAME %1
%rotate 1
%if %1 < 0
%error Negative stack allocation not allowed
%else
%if (%0 & 1) == (%1 & 1)
%assign stack_use 8 * (%1 + 1)
%else
%assign stack_use 8 * %1
%endif
%endif
%rotate 1
%if %0 > 2
%rep %0 - 2
push_reg %1
%rotate 1
%endrep
%endif
%if stack_use > 0
alloc_stack stack_use
%endif
%assign stack_use stack_use + 8 * (%0 - 2)
END_PROLOGUE
%endmacro
%macro epilogue 1-*
%rotate -1
%if (%0 + %1) & 1
add rsp, 8 * (%1 + 1)
%else
add rsp, 8 * %1 ; is this needed if %1 == 0 ?
%endif
%rep %0 - 1
%rotate -1
pop %1
%endrep
%macro epilogue 0-*
add rsp, stack_use - 8 * %0
%if %0 > 0
%rep %0
%rotate -1
pop %1
%endrep
%endif
ret
ENDPROC_FRAME
ENDPROC_FRAME
%endmacro
%else
@ -74,3 +130,96 @@ ENDPROC_FRAME
%endmacro
%endif
; Macros for using assembler code using the GCC Calling
; Conventions in Windows.
; Note that these macros loads integer parameters that
; are 32-bits as 64-bit integers with no zero or sign
; extension. For such parameters either 'mov rxd, rxd'
; (for unsigned) or 'movsxd rx, rxd' (for signed) will
; be needed after their use if such parameters are to
; be used as 64-bit integers. These macros move the
; first six integer input parameters in Microsoft ABI
; calling calling conventions to those used by GCC:
;
; function( MSVC --> GCC
; p1, rcx rdi
; p2, rdx rsi
; p3, r8 rdx
; p4, r9 rcx
; p5, [rsp+40] r8
; p6, [rsp+48] r9
;
; As alreaddy discussed, care must be taken with 32-bit
; values in 64-bit registers or on the stack because
; the upper 32-bits of such parameters are undefined.
;
; win64_gcc_start name, (frame | leaf), parms
;
; win64_gcc_end frame | leaf
;
; name subroutine name
; type subroutine type (frame or leaf)
; parms number of parameters
;
%define leaf_proc 0
%define frame_proc 1
%macro win64_gcc_start 1-3 frame_proc, 6
global %1
%ifdef DLL
export %1
%endif
%if %2 == frame_proc
%ifndef reg_save_list
%define reg_save_list rsi, rdi
%endif
%ifndef stack_slots
%define stack_slots 0
%endif
prologue %1, stack_slots, reg_save_list
%if %3 > 0
mov rdi, rcx
%endif
%if %3 > 1
mov rsi, rdx
%endif
%if %3 > 2
mov rdx, r8
%endif
%if %3 > 3
mov rcx, r9
%endif
%if %3 > 4
mov r8, [rsp + stack_use + 40]
%endif
%if %3 > 5
mov r9, [rsp + stack_use + 48]
%endif
%elif %2 == leaf_proc
%1:
%else
%error no (or wrong) function type defined
%endif
%endmacro
%macro win64_gcc_end 0-1 frame_proc
%if %1 == frame_proc
epilogue reg_save_list
%elif %1 == leaf_proc
ret
%else
%error no (or wrong) function type defined
%endif
%endmacro