Imported Upstream version 6.0.0
[platform/upstream/gmp.git] / mpn / x86_64 / com.asm
1 dnl  AMD64 mpn_com.
2
3 dnl  Copyright 2004-2006, 2011, 2012 Free Software Foundation, Inc.
4
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 modify
8 dnl  it under the terms of either:
9 dnl
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.
13 dnl
14 dnl  or
15 dnl
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
18 dnl      later version.
19 dnl
20 dnl  or both in parallel, as here.
21 dnl
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
25 dnl  for more details.
26 dnl
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/.
30
31 include(`../config.m4')
32
33
34 C           cycles/limb
35 C AMD K8,K9      1.25
36 C AMD K10        1.25
37 C Intel P4       2.78
38 C Intel core2    1.1
39 C Intel corei    1.5
40 C Intel atom     ?
41 C VIA nano       2
42
43 C INPUT PARAMETERS
44 define(`rp',`%rdi')
45 define(`up',`%rsi')
46 define(`n',`%rdx')
47
48 ABI_SUPPORT(DOS64)
49 ABI_SUPPORT(STD64)
50
51 ASM_START()
52         TEXT
53         ALIGN(32)
54 PROLOGUE(mpn_com)
55         FUNC_ENTRY(3)
56         movq    (up), %r8
57         movl    R32(%rdx), R32(%rax)
58         leaq    (up,n,8), up
59         leaq    (rp,n,8), rp
60         negq    n
61         andl    $3, R32(%rax)
62         je      L(b00)
63         cmpl    $2, R32(%rax)
64         jc      L(b01)
65         je      L(b10)
66
67 L(b11): notq    %r8
68         movq    %r8, (rp,n,8)
69         decq    n
70         jmp     L(e11)
71 L(b10): addq    $-2, n
72         jmp     L(e10)
73         .byte   0x90,0x90,0x90,0x90,0x90,0x90
74 L(b01): notq    %r8
75         movq    %r8, (rp,n,8)
76         incq    n
77         jz      L(ret)
78
79 L(oop): movq    (up,n,8), %r8
80 L(b00): movq    8(up,n,8), %r9
81         notq    %r8
82         notq    %r9
83         movq    %r8, (rp,n,8)
84         movq    %r9, 8(rp,n,8)
85 L(e11): movq    16(up,n,8), %r8
86 L(e10): movq    24(up,n,8), %r9
87         notq    %r8
88         notq    %r9
89         movq    %r8, 16(rp,n,8)
90         movq    %r9, 24(rp,n,8)
91         addq    $4, n
92         jnc     L(oop)
93 L(ret): FUNC_EXIT()
94         ret
95 EPILOGUE()