Upload Tizen:Base source
[external/gmp.git] / mpn / x86 / k6 / mmx / com.asm
1 dnl  AMD K6-2 mpn_com -- mpn bitwise one's complement.
2
3 dnl  Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 dnl
5 dnl  This file is part of the GNU MP Library.
6 dnl
7 dnl  The GNU MP Library is free software; you can redistribute it and/or
8 dnl  modify it under the terms of the GNU Lesser General Public License as
9 dnl  published by the Free Software Foundation; either version 3 of the
10 dnl  License, or (at your option) any later version.
11 dnl
12 dnl  The GNU MP Library is distributed in the hope that it will be useful,
13 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 dnl  Lesser General Public License for more details.
16 dnl
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 NAILS_SUPPORT(0-31)
23
24
25 C    alignment dst/src, A=0mod8 N=4mod8
26 C       A/A   A/N   N/A   N/N
27 C K6-2  1.0   1.18  1.18  1.18  cycles/limb
28 C K6    1.5   1.85  1.75  1.85
29
30
31 C void mpn_com (mp_ptr dst, mp_srcptr src, mp_size_t size);
32 C
33 C Take the bitwise ones-complement of src,size and write it to dst,size.
34
35 defframe(PARAM_SIZE,12)
36 defframe(PARAM_SRC, 8)
37 defframe(PARAM_DST, 4)
38
39         TEXT
40         ALIGN(16)
41 PROLOGUE(mpn_com)
42 deflit(`FRAME',0)
43
44         movl    PARAM_SIZE, %ecx
45         movl    PARAM_SRC, %eax
46         movl    PARAM_DST, %edx
47         shrl    %ecx
48         jnz     L(two_or_more)
49
50         movl    (%eax), %eax
51         notl_or_xorl_GMP_NUMB_MASK(     %eax)
52         movl    %eax, (%edx)
53         ret
54
55
56 L(two_or_more):
57         pushl   %ebx    FRAME_pushl()
58         pcmpeqd %mm7, %mm7              C all ones
59
60         movl    %ecx, %ebx
61 ifelse(GMP_NAIL_BITS,0,,
62 `       psrld   $GMP_NAIL_BITS, %mm7')  C clear nails
63
64
65
66         ALIGN(8)
67 L(top):
68         C eax   src
69         C ebx   floor(size/2)
70         C ecx   counter
71         C edx   dst
72         C
73         C mm0   scratch
74         C mm7   mask
75
76         movq    -8(%eax,%ecx,8), %mm0
77         pxor    %mm7, %mm0
78         movq    %mm0, -8(%edx,%ecx,8)
79         loop    L(top)
80
81
82         jnc     L(no_extra)
83         movl    (%eax,%ebx,8), %eax
84         notl_or_xorl_GMP_NUMB_MASK(     %eax)
85         movl    %eax, (%edx,%ebx,8)
86 L(no_extra):
87
88         popl    %ebx
89         emms_or_femms
90         ret
91
92 EPILOGUE()