Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc64 / mode64 / bdiv_dbm1c.asm
1 dnl  PPC64 mpn_bdiv_dbm1c.
2
3 dnl  Copyright 2008 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:    6-18
24 C POWER4/PPC970:    8.5
25 C POWER5:           ?
26
27 C TODO
28 C  * Nothing to do...
29
30 C INPUT PARAMETERS
31 define(`rp', `r3')
32 define(`up', `r4')
33 define(`n',  `r5')
34 define(`bd', `r6')
35 define(`cy', `r7')
36
37 ASM_START()
38 PROLOGUE(mpn_bdiv_dbm1c)
39         ld      r0, 0(r4)
40
41         rldicl. r12, r5, 0,62
42         cmpldi  cr6, r12, 2
43         cmpldi  cr7, r5, 4
44         addi    r5, r5, 1
45         srwi    r5, r5, 2
46         mtctr   r5
47         beq     cr0, L(b00)
48         blt     cr6, L(b01)
49         beq     cr6, L(b10)
50
51 L(b11): mulld   r5, r0, r6
52         mulhdu  r12, r0, r6
53         ld      r0, 8(r4)
54         addi    r4, r4, -24
55         addi    r3, r3, -24
56         b       L(3)
57
58 L(b00): mulld   r9, r0, r6
59         mulhdu  r8, r0, r6
60         ld      r0, 8(r4)
61         addi    r4, r4, -16
62         addi    r3, r3, -16
63         b       L(0)
64
65 L(b01): mulld   r5, r0, r6
66         mulhdu  r12, r0, r6
67         addi    r3, r3, -8
68         ble     cr7, L(e1)
69         ld      r0, 8(r4)
70         addi    r4, r4, -8
71         b       L(1)
72
73 L(b10): mulld   r9, r0, r6
74         mulhdu  r8, r0, r6
75         ld      r0, 8(r4)
76         ble     cr7, L(e2)
77
78         ALIGN(16)
79 L(top): mulld   r5, r0, r6
80         mulhdu  r12, r0, r6
81         subfc   r11, r9, r7
82         ld      r0, 16(r4)
83         subfe   r7, r8, r11
84         std     r11, 0(r3)
85 L(1):   mulld   r9, r0, r6
86         mulhdu  r8, r0, r6
87         subfc   r11, r5, r7
88         ld      r0, 24(r4)
89         subfe   r7, r12, r11
90         std     r11, 8(r3)
91 L(0):   mulld   r5, r0, r6
92         mulhdu  r12, r0, r6
93         subfc   r11, r9, r7
94         ld      r0, 32(r4)
95         subfe   r7, r8, r11
96         std     r11, 16(r3)
97 L(3):   mulld   r9, r0, r6
98         mulhdu  r8, r0, r6
99         subfc   r11, r5, r7
100         ld      r0, 40(r4)
101         subfe   r7, r12, r11
102         std     r11, 24(r3)
103         addi    r4, r4, 32
104         addi    r3, r3, 32
105         bdnz    L(top)
106
107 L(e2):  mulld   r5, r0, r6
108         mulhdu  r12, r0, r6
109         subfc   r11, r9, r7
110         subfe   r7, r8, r11
111         std     r11, 0(r3)
112 L(e1):  subfc   r11, r5, r7
113         std     r11, 8(r3)
114         subfe   r3, r12, r11
115         blr
116 EPILOGUE()