xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/p7/copyd.asm (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1dnl  PowerPC-64 mpn_copyd.
2
3dnl  Copyright 2004, 2005, 2013 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 POWER3/PPC630          ?
35C POWER4/PPC970          ?
36C POWER5                 ?
37C POWER6                 1.25
38C POWER7                 1.09
39
40C INPUT PARAMETERS
41define(`rp',	`r3')
42define(`up',	`r4')
43define(`n',	`r5')
44
45ASM_START()
46PROLOGUE(mpn_copyd)
47
48ifdef(`HAVE_ABI_mode32',
49`	rldicl	n, n, 0,32')
50
51	sldi	r0, n, 3
52	add	up, up, r0		C point at u[] end
53	add	rp, rp, r0		C point at r[] end
54
55	cmpdi	cr0, n, 4
56	blt	L(sml)
57
58	addi	r10, n, 4
59	srdi	r10, r10, 3
60	mtctr	r10
61
62	andi.	r0, n, 1
63	rlwinm	r11, n, 0,30,30
64	rlwinm	r12, n, 0,29,29
65	cmpdi	cr6, r11, 0
66	cmpdi	cr7, r12, 0
67
68	beq	cr0, L(xx0)
69L(xx1):	ld	r6, -8(up)
70	addi	up, up, -8
71	std	r6, -8(rp)
72	addi	rp, rp, -8
73
74L(xx0):	bne	cr6, L(x10)
75L(x00):	ld	r6, -8(up)
76	ld	r7, -16(up)
77	bne	cr7, L(100)
78L(000):	addi	rp, rp, 32
79	b	L(lo0)
80L(100):	addi	up, up, 32
81	b	L(lo4)
82L(x10):	ld	r8, -8(up)
83	ld	r9, -16(up)
84	bne	cr7, L(110)
85L(010):	addi	up, up, -16
86	addi	rp, rp, 16
87	b	L(lo2)
88L(110):	addi	up, up, 16
89	addi	rp, rp, 48
90	b	L(lo6)
91
92L(sml):	cmpdi	cr0, n, 0
93	beqlr-	cr0
94	mtctr	n
95L(t):	ld	r6, -8(up)
96	addi	up, up, -8
97	std	r6, -8(rp)
98	addi	rp, rp, -8
99	bdnz	L(t)
100	blr
101
102	ALIGN(32)
103L(top):	std	r6, -8(rp)
104	std	r7, -16(rp)
105L(lo2):	ld	r6, -8(up)
106	ld	r7, -16(up)
107	std	r8, -24(rp)
108	std	r9, -32(rp)
109L(lo0):	ld	r8, -24(up)
110	ld	r9, -32(up)
111	std	r6, -40(rp)
112	std	r7, -48(rp)
113L(lo6):	ld	r6, -40(up)
114	ld	r7, -48(up)
115	std	r8, -56(rp)
116	std	r9, -64(rp)
117	addi	rp, rp, -64
118L(lo4):	ld	r8, -56(up)
119	ld	r9, -64(up)
120	addi	up, up, -64
121	bdnz	L(top)
122
123L(end):	std	r6, -8(rp)
124	std	r7, -16(rp)
125	std	r8, -24(rp)
126	std	r9, -32(rp)
127	blr
128EPILOGUE()
129