1 dnl x86 mpn_add_n
/mpn_sub_n
-- mpn addition
and subtraction.
3 dnl Copyright
1992, 1994-1996, 1999-2002 Free Software Foundation
, Inc.
5 dnl
This file is part of the GNU MP Library.
7 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
8 dnl it under the terms of
either:
10 dnl
* the GNU Lesser General
Public License as published by the Free
11 dnl Software Foundation
; either version 3 of the License, or (at your
12 dnl option
) any later version.
16 dnl
* the GNU General
Public License as published by the Free Software
17 dnl Foundation
; either version 2 of the License, or (at your option) any
20 dnl
or both
in parallel
, as here.
22 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
23 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
24 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
27 dnl You should have received copies of the GNU General
Public License
and the
28 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
29 dnl see
https://www.gnu.
org/licenses
/.
31 include(`..
/config.m4
')
42 ifdef(`OPERATION_add_n',`
44 define
(M4_function_n
, mpn_add_n
)
45 define
(M4_function_nc
, mpn_add_nc
)
47 ',`ifdef(`OPERATION_sub_n',`
49 define
(M4_function_n
, mpn_sub_n
)
50 define
(M4_function_nc
, mpn_sub_nc
)
52 ',`m4_error(`Need OPERATION_add_n or OPERATION_sub_n
55 MULFUNC_PROLOGUE
(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc
)
58 C mp_limb_t M4_function_n
(mp_ptr dst
, mp_srcptr src1
, mp_srcptr src2
,
60 C mp_limb_t M4_function_nc
(mp_ptr dst
, mp_srcptr src1
, mp_srcptr src2
,
61 C mp_size_t
size, mp_limb_t carry
);
63 defframe
(PARAM_CARRY
,20)
64 defframe
(PARAM_SIZE
, 16)
65 defframe
(PARAM_SRC2
, 12)
66 defframe
(PARAM_SRC1
, 8)
67 defframe
(PARAM_DST
, 4)
72 PROLOGUE
(M4_function_nc
)
75 pushl %edi FRAME_pushl()
76 pushl %esi FRAME_pushl()
84 shrl $3,%ecx C compute count for unrolled loop
86 andl $7,%eax C get index where to start loop
87 jz L(oopgo) C necessary special case for 0
88 incl %ecx C adjust loop count
89 shll $2,%eax C adjustment for pointers...
90 subl %eax,%edi C ... since they are offset ...
91 subl %eax,%esi C ... by a constant when we ...
92 subl %eax,%edx C ... enter the loop
93 shrl $2,%eax C restore previous value
96 C Calculate start address
in loop for PIC. Due to limitations
in
97 C old gas
, LF
(M4_function_n
,oop
)-L
(0a
)-3 cannot be put
into the leal
99 L
(0a
): leal
(%eax,%eax,8),%eax
101 addl $L
(oop
)-L
(0a
)-3,%eax
104 C Calculate start address in loop for non-PIC.
105 leal L(oop)-3(%eax,%eax,8),%eax
108 C These lines initialize carry from the
5th parameter. Should be
109 C possible to simplify.
110 pushl
%ebp FRAME_pushl
()
111 movl PARAM_CARRY
,%ebp
112 shrl
%ebp C shift bit
0 into carry
113 popl
%ebp FRAME_popl
()
115 jmp *%eax C jump
into loop
121 PROLOGUE
(M4_function_n
)
124 pushl %edi FRAME_pushl()
125 pushl %esi FRAME_pushl()
133 shrl $3,%ecx C compute count for unrolled loop
135 andl $7,%eax C get index where to start loop
136 jz L(oop) C necessary special case for 0
137 incl %ecx C adjust loop count
138 shll $2,%eax C adjustment for pointers...
139 subl %eax,%edi C ... since they are offset ...
140 subl %eax,%esi C ... by a constant when we ...
141 subl %eax,%edx C ... enter the loop
142 shrl $2,%eax C restore previous value
145 C Calculate start address
in loop for PIC. Due to limitations
in
146 C some assemblers
, L
(oop
)-L
(0b)-3 cannot be put
into the leal
148 L
(0b): leal
(%eax,%eax,8),%eax
150 addl $L
(oop
)-L
(0b)-3,%eax
153 C Calculate start address in loop for non-PIC.
154 leal L(oop)-3(%eax,%eax,8),%eax
156 jmp *%eax C jump
into loop
159 pushl
%ebp FRAME_pushl
()
160 movl PARAM_CARRY
,%ebp
161 shrl
%ebp C shift bit
0 into carry
162 popl
%ebp FRAME_popl
()
165 L
(oop
): movl
(%esi),%eax
175 M4_inst
12(%edx),%eax
178 M4_inst
16(%edx),%eax
181 M4_inst
20(%edx),%eax
184 M4_inst
24(%edx),%eax
187 M4_inst
28(%edx),%eax