Upload Tizen:Base source
[external/gmp.git] / mpn / powerpc32 / bdiv_dbm1c.asm
1 dnl  PPC32 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 603e:            ?
24 C 604e:            ?
25 C 75x (G3):        ?
26 C 7400,7410 (G4):  9.43
27 C 744x,745x (G4+): 6.28
28 C power4/ppc970:   ?
29 C power5:          ?
30
31 C TODO
32 C  * Nothing to do...
33
34 C INPUT PARAMETERS
35 define(`rp', `r3')
36 define(`up', `r4')
37 define(`n',  `r5')
38 define(`bd', `r6')
39 define(`cy', `r7')
40
41 ASM_START()
42 PROLOGUE(mpn_bdiv_dbm1c)
43         lwz     r0, 0(r4)
44
45         rlwinm. r12, r5, 0,30,31
46         cmplwi  cr6, r12, 2
47         cmplwi  cr7, r5, 4
48         addi    r5, r5, 1
49         srwi    r5, r5, 2
50         mtctr   r5
51         beq     cr0, L(b00)
52         blt     cr6, L(b01)
53         beq     cr6, L(b10)
54
55 L(b11): mullw   r5, r0, r6
56         mulhwu  r12, r0, r6
57         lwz     r0, 4(r4)
58         addi    r4, r4, -12
59         addi    r3, r3, -12
60         b       L(3)
61
62 L(b00): mullw   r9, r0, r6
63         mulhwu  r8, r0, r6
64         lwz     r0, 4(r4)
65         addi    r4, r4, -8
66         addi    r3, r3, -8
67         b       L(0)
68
69 L(b01): mullw   r5, r0, r6
70         mulhwu  r12, r0, r6
71         addi    r3, r3, -4
72         ble     cr7, L(e1)
73         lwz     r0, 4(r4)
74         addi    r4, r4, -4
75         b       L(1)
76
77 L(b10): mullw   r9, r0, r6
78         mulhwu  r8, r0, r6
79         lwz     r0, 4(r4)
80         ble     cr7, L(e2)
81
82         ALIGN(16)
83 L(top): mullw   r5, r0, r6
84         mulhwu  r12, r0, r6
85         subfc   r11, r9, r7
86         lwz     r0, 8(r4)
87         subfe   r7, r8, r11
88         stw     r11, 0(r3)
89 L(1):   mullw   r9, r0, r6
90         mulhwu  r8, r0, r6
91         subfc   r11, r5, r7
92         lwz     r0, 12(r4)
93         subfe   r7, r12, r11
94         stw     r11, 4(r3)
95 L(0):   mullw   r5, r0, r6
96         mulhwu  r12, r0, r6
97         subfc   r11, r9, r7
98         lwz     r0, 16(r4)
99         subfe   r7, r8, r11
100         stw     r11, 8(r3)
101 L(3):   mullw   r9, r0, r6
102         mulhwu  r8, r0, r6
103         subfc   r11, r5, r7
104         lwz     r0, 20(r4)
105         subfe   r7, r12, r11
106         stw     r11, 12(r3)
107         addi    r4, r4, 16
108         addi    r3, r3, 16
109         bdnz    L(top)
110
111 L(e2):  mullw   r5, r0, r6
112         mulhwu  r12, r0, r6
113         subfc   r11, r9, r7
114         subfe   r7, r8, r11
115         stw     r11, 0(r3)
116 L(e1):  subfc   r11, r5, r7
117         stw     r11, 4(r3)
118         subfe   r3, r12, r11
119         blr
120 EPILOGUE()