xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/copyi.asm (revision 6d322f2f4598f0d8a138f10ea648ec4fabe41f8b)
1dnl  PowerPC-64 mpn_copyi.
2
3dnl  Copyright 2004, 2005 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 POWER3/PPC630          1
24C POWER4/PPC970          1
25C POWER5                 ?
26C POWER6                 ?
27C POWER7                 1.4
28
29C INPUT PARAMETERS
30C rp	r3
31C up	r4
32C n	r5
33
34ASM_START()
35PROLOGUE(mpn_copyi)
36	rldic.	r0, r5, 3, 59	C r0 = (r5 & 3) << 3; cr0 = (n == 4t)?
37	cmpldi	cr6, r0, 16	C cr6 = (n cmp 4t + 2)?
38
39	addi	r5, r5, 4	C compute...
40ifdef(`HAVE_ABI_mode32',
41`	rldicl	r5, r5, 62,34',	C ...branch count
42`	rldicl	r5, r5, 62, 2')	C ...branch count
43	mtctr	r5
44
45	add	r4, r4, r0	C offset up
46	add	r3, r3, r0	C offset rp
47
48	beq	cr0, L(L00)
49	blt	cr6, L(L01)
50	beq	cr6, L(L10)
51	b	L(L11)
52
53	ALIGN(16)
54L(oop):	ld	r6, -32(r4)
55	std	r6, -32(r3)
56L(L11):	ld	r6, -24(r4)
57	std	r6, -24(r3)
58L(L10):	ld	r6, -16(r4)
59	std	r6, -16(r3)
60L(L01):	ld	r6, -8(r4)
61	std	r6, -8(r3)
62L(L00):	addi	r4, r4, 32
63	addi	r3, r3, 32
64	bdnz	L(oop)
65
66	blr
67EPILOGUE()
68