xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/x86_64/com.asm (revision 32d1c65c71fbdb65a012e8392a62a757dd6853e9)
1dnl  AMD64 mpn_com.
2
3dnl  Copyright 2004-2006, 2011, 2012 Free Software Foundation, Inc.
4
5dnl  This file is part of the GNU MP Library.
6dnl
7dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8dnl  it under the terms of either:
9dnl
10dnl    * the GNU Lesser General Public License as published by the Free
11dnl      Software Foundation; either version 3 of the License, or (at your
12dnl      option) any later version.
13dnl
14dnl  or
15dnl
16dnl    * the GNU General Public License as published by the Free Software
17dnl      Foundation; either version 2 of the License, or (at your option) any
18dnl      later version.
19dnl
20dnl  or both in parallel, as here.
21dnl
22dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25dnl  for more details.
26dnl
27dnl  You should have received copies of the GNU General Public License and the
28dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29dnl  see https://www.gnu.org/licenses/.
30
31include(`../config.m4')
32
33
34C	    cycles/limb
35C AMD K8,K9	 1.25
36C AMD K10	 1.25
37C Intel P4	 2.78
38C Intel core2	 1.1
39C Intel corei	 1.5
40C Intel atom	 ?
41C VIA nano	 2
42
43C INPUT PARAMETERS
44define(`rp',`%rdi')
45define(`up',`%rsi')
46define(`n',`%rdx')
47
48ABI_SUPPORT(DOS64)
49ABI_SUPPORT(STD64)
50
51ASM_START()
52	TEXT
53	ALIGN(32)
54PROLOGUE(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
67L(b11):	notq	%r8
68	movq	%r8, (rp,n,8)
69	decq	n
70	jmp	L(e11)
71L(b10):	addq	$-2, n
72	jmp	L(e10)
73	.byte	0x90,0x90,0x90,0x90,0x90,0x90
74L(b01):	notq	%r8
75	movq	%r8, (rp,n,8)
76	incq	n
77	jz	L(ret)
78
79L(oop):	movq	(up,n,8), %r8
80L(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)
85L(e11):	movq	16(up,n,8), %r8
86L(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)
93L(ret):	FUNC_EXIT()
94	ret
95EPILOGUE()
96