1 /* Pentium optimized __mpn_lshift --
2 Copyright (C) 1992-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #include "asm-syntax.h"
22 #define PARMS 4+16 /* space for 4 saved regs */
32 cfi_adjust_cfa_offset (4)
34 cfi_adjust_cfa_offset (4)
36 cfi_adjust_cfa_offset (4)
37 cfi_rel_offset (ebp, 0)
39 cfi_adjust_cfa_offset (4)
42 cfi_rel_offset (edi, 12)
44 cfi_rel_offset (esi, 8)
46 cfi_rel_offset (ebx, 0)
49 /* We can use faster code for shift-by-1 under certain conditions. */
54 jnc L(special) /* jump if s_ptr + 1 >= res_ptr */
55 leal (%esi,%ebx,4),%eax
57 jnc L(special) /* jump if res_ptr >= s_ptr + size */
60 leal -4(%edi,%ebx,4),%edi
61 leal -4(%esi,%ebx,4),%esi
66 shldl %cl,%edx,%eax /* compute carry limb */
67 pushl %eax /* push carry limb onto stack */
68 cfi_adjust_cfa_offset (4)
72 cfi_adjust_cfa_offset (4)
76 movl (%edi),%eax /* fetch destination cache line */
79 L(oop): movl -28(%edi),%eax /* fetch destination cache line */
116 cfi_adjust_cfa_offset (-4)
130 shll %cl,%edx /* compute least significant limb */
131 movl %edx,(%edi) /* store it */
133 popl %eax /* pop carry limb */
134 cfi_adjust_cfa_offset (-4)
137 cfi_adjust_cfa_offset (-4)
140 cfi_adjust_cfa_offset (-4)
143 cfi_adjust_cfa_offset (-4)
146 cfi_adjust_cfa_offset (-4)
151 /* We loop from least significant end of the arrays, which is only
152 permissible if the source and destination don't overlap, since the
153 function is documented to work for overlapping source and destination.
156 cfi_adjust_cfa_offset (16)
157 cfi_rel_offset (edi, 12)
158 cfi_rel_offset (esi, 8)
159 cfi_rel_offset (ebp, 4)
160 cfi_rel_offset (ebx, 0)
167 cfi_adjust_cfa_offset (4)
175 movl (%edi),%eax /* fetch destination cache line */
179 movl 28(%edi),%eax /* fetch destination cache line */
210 leal 32(%esi),%esi /* use leal not to clobber carry */
217 cfi_adjust_cfa_offset (-4)
218 sbbl %eax,%eax /* save carry in %eax */
221 addl %eax,%eax /* restore carry from eax */
228 leal 4(%esi),%esi /* use leal not to clobber carry */
235 addl %eax,%eax /* restore carry from eax */
236 L(L1): movl %edx,(%edi) /* store last limb */
242 cfi_adjust_cfa_offset (-4)
245 cfi_adjust_cfa_offset (-4)
248 cfi_adjust_cfa_offset (-4)
251 cfi_adjust_cfa_offset (-4)