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