Import upstream 5.1.3.
[platform/upstream/gmp.git] / mpn / powerpc64 / copyd.asm
1 dnl  PowerPC-64 mpn_copyd
2
3 dnl  Copyright 2004, 2005 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C                  cycles/limb
23 C POWER3/PPC630          1
24 C POWER4/PPC970          1
25 C POWER5                 ?
26 C POWER6                 ?
27 C POWER7                 1.4
28
29 C INPUT PARAMETERS
30 C rp    r3
31 C up    r4
32 C n     r5
33
34 ASM_START()
35 PROLOGUE(mpn_copyd)
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 ifdef(`HAVE_ABI_mode32',
40 `       rldic   r6, r5, 3, 32', C byte count corresponding to n
41 `       rldicr  r6, r5, 3, 60') C byte count corresponding to n
42
43         addi    r5, r5, 4       C compute...
44 ifdef(`HAVE_ABI_mode32',
45 `       rldicl  r5, r5, 62,34', C ...branch count
46 `       rldicl  r5, r5, 62, 2') C ...branch count
47         mtctr   r5
48
49         add     r4, r4, r6
50         add     r3, r3, r6
51         sub     r4, r4, r0      C offset up
52         sub     r3, r3, r0      C offset rp
53
54         beq     cr0, L(L00)
55         blt     cr6, L(L01)
56         beq     cr6, L(L10)
57         b       L(L11)
58
59         ALIGN(16)
60 L(oop): ld      r6, 24(r4)
61         std     r6, 24(r3)
62 L(L11): ld      r6, 16(r4)
63         std     r6, 16(r3)
64 L(L10): ld      r6, 8(r4)
65         std     r6, 8(r3)
66 L(L01): ld      r6, 0(r4)
67         std     r6, 0(r3)
68 L(L00): addi    r4, r4, -32
69         addi    r3, r3, -32
70         bdnz    L(oop)
71
72         blr
73 EPILOGUE()