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