xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/x86_64/copyi.asm (revision f14316bcbc544b96a93e884bc5c2b15fd60e22ae)
1dnl  AMD64 mpn_copyi -- copy limb vector, incrementing.
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)
49	.byte	0,0,0,0,0,0
50PROLOGUE(mpn_copyi)
51	lea	-8(rp), rp
52	sub	$4, n
53	jc	L(end)
54
55L(top):	mov	(up), %rax
56	mov	8(up), %r9
57	lea	32(rp), rp
58	mov	16(up), %r10
59	mov	24(up), %r11
60	lea	32(up), up
61	mov	%rax, -24(rp)
62	mov	%r9, -16(rp)
63	sub	$4, n
64	mov	%r10, -8(rp)
65	mov	%r11, (rp)
66	jnc	L(top)
67
68L(end):	shr	R32(n)
69	jnc	1f
70	mov	(up), %rax
71	mov	%rax, 8(rp)
72	lea	8(rp), rp
73	lea	8(up), up
741:	shr	R32(n)
75	jnc	1f
76	mov	(up), %rax
77	mov	8(up), %r9
78	mov	%rax, 8(rp)
79	mov	%r9, 16(rp)
801:	ret
81EPILOGUE()
82