xref: /netbsd-src/external/lgpl3/gmp/dist/mpn/powerpc64/copyd.asm (revision 33881f779a77dce6440bdc44610d94de75bebefe)
1dnl  PowerPC-64 mpn_copyd
2
3dnl  Copyright 2004, 2005 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          1
35C POWER4/PPC970          1
36C POWER5                 ?
37C POWER6                 ?
38C POWER7                 1.4
39
40C INPUT PARAMETERS
41C rp	r3
42C up	r4
43C n	r5
44
45ASM_START()
46PROLOGUE(mpn_copyd)
47	rldic.	r0, r5, 3, 59	C r0 = (r5 & 3) << 3; cr0 = (n == 4t)?
48	cmpldi	cr6, r0, 16	C cr6 = (n cmp 4t + 2)?
49
50ifdef(`HAVE_ABI_mode32',
51`	rldic	r6, r5, 3, 32',	C byte count corresponding to n
52`	rldicr	r6, r5, 3, 60')	C byte count corresponding to n
53
54	addi	r5, r5, 4	C compute...
55ifdef(`HAVE_ABI_mode32',
56`	rldicl	r5, r5, 62,34',	C ...branch count
57`	rldicl	r5, r5, 62, 2')	C ...branch count
58	mtctr	r5
59
60	add	r4, r4, r6
61	add	r3, r3, r6
62	sub	r4, r4, r0	C offset up
63	sub	r3, r3, r0	C offset rp
64
65	beq	cr0, L(L00)
66	blt	cr6, L(L01)
67	beq	cr6, L(L10)
68	b	L(L11)
69
70	ALIGN(16)
71L(oop):	ld	r6, 24(r4)
72	std	r6, 24(r3)
73L(L11):	ld	r6, 16(r4)
74	std	r6, 16(r3)
75L(L10):	ld	r6, 8(r4)
76	std	r6, 8(r3)
77L(L01):	ld	r6, 0(r4)
78	std	r6, 0(r3)
79L(L00):	addi	r4, r4, -32
80	addi	r3, r3, -32
81	bdnz	L(oop)
82
83	blr
84EPILOGUE()
85