xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/x86_64/copyd.asm (revision 4d5abbe83f525258eb479e5fca29f25cb943f379)
1dnl  AMD64 mpn_copyd -- copy limb vector, decrementing.
2
3dnl  Copyright 2003, 2005, 2007, 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
22C	     cycles/limb
23C AMD K8,K9	 1
24C AMD K10	 1
25C AMD bd1	 1.36
26C AMD bobcat	 1.71
27C Intel P4	 2-3
28C Intel core2	 1
29C Intel NHM	 1
30C Intel SBR	 1
31C Intel atom	 2
32C VIA nano	 2
33
34
35IFSTD(`define(`rp',`%rdi')')
36IFSTD(`define(`up',`%rsi')')
37IFSTD(`define(`n', `%rdx')')
38
39IFDOS(`define(`rp',`%rcx')')
40IFDOS(`define(`up',`%rdx')')
41IFDOS(`define(`n', `%r8')')
42
43ABI_SUPPORT(DOS64)
44ABI_SUPPORT(STD64)
45
46ASM_START()
47	TEXT
48	ALIGN(64)
49PROLOGUE(mpn_copyd)
50	lea	-8(up,n,8), up
51	lea	(rp,n,8), rp
52	sub	$4, n
53	jc	L(end)
54	nop
55
56L(top):	mov	(up), %rax
57	mov	-8(up), %r9
58	lea	-32(rp), rp
59	mov	-16(up), %r10
60	mov	-24(up), %r11
61	lea	-32(up), up
62	mov	%rax, 24(rp)
63	mov	%r9, 16(rp)
64	sub	$4, n
65	mov	%r10, 8(rp)
66	mov	%r11, (rp)
67	jnc	L(top)
68
69L(end):	shr	R32(n)
70	jnc	1f
71	mov	(up), %rax
72	mov	%rax, -8(rp)
73	lea	-8(rp), rp
74	lea	-8(up), up
751:	shr	R32(n)
76	jnc	1f
77	mov	(up), %rax
78	mov	-8(up), %r9
79	mov	%rax, -8(rp)
80	mov	%r9, -16(rp)
811:	ret
82EPILOGUE()
83