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