Imported Upstream version 6.0.0
[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 dnl
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of either:
9 dnl
10 dnl    * the GNU Lesser General Public License as published by the Free
11 dnl      Software Foundation; either version 3 of the License, or (at your
12 dnl      option) any later version.
13 dnl
14 dnl  or
15 dnl
16 dnl    * the GNU General Public License as published by the Free Software
17 dnl      Foundation; either version 2 of the License, or (at your option) any
18 dnl      later version.
19 dnl
20 dnl  or both in parallel, as here.
21 dnl
22 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 dnl  for more details.
26 dnl
27 dnl  You should have received copies of the GNU General Public License and the
28 dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
29 dnl  see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C                  cycles/limb
34 C POWER3/PPC630          1
35 C POWER4/PPC970          1
36 C POWER5                 ?
37 C POWER6                 ?
38 C POWER7                 1.4
39
40 C INPUT PARAMETERS
41 C rp    r3
42 C up    r4
43 C n     r5
44
45 ASM_START()
46 PROLOGUE(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
50 ifdef(`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...
55 ifdef(`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)
71 L(oop): ld      r6, 24(r4)
72         std     r6, 24(r3)
73 L(L11): ld      r6, 16(r4)
74         std     r6, 16(r3)
75 L(L10): ld      r6, 8(r4)
76         std     r6, 8(r3)
77 L(L01): ld      r6, 0(r4)
78         std     r6, 0(r3)
79 L(L00): addi    r4, r4, -32
80         addi    r3, r3, -32
81         bdnz    L(oop)
82
83         blr
84 EPILOGUE()