Tizen 2.1 base
[external/gmp.git] / mpn / powerpc32 / mul_1.asm
1 dnl  PowerPC-32 mpn_mul_1 -- Multiply a limb vector with a limb and store the
2 dnl  result in a second limb vector.
3
4 dnl  Copyright 1995, 1997, 2000, 2002, 2003, 2005 Free Software Foundation,
5 dnl  Inc.
6
7 dnl  This file is part of the GNU MP Library.
8
9 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10 dnl  it under the terms of the GNU Lesser General Public License as published
11 dnl  by the Free Software Foundation; either version 3 of the License, or (at
12 dnl  your option) any later version.
13
14 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17 dnl  License for more details.
18
19 dnl  You should have received a copy of the GNU Lesser General Public License
20 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22 include(`../config.m4')
23
24 C                cycles/limb
25 C 603e:            ?
26 C 604e:            4.0
27 C 75x (G3):        4.5-11
28 C 7400,7410 (G4):  4.5-11
29 C 744x,745x (G4+): 6.0
30 C power4/ppc970:   6.0
31 C power5:          5.63
32
33 C INPUT PARAMETERS
34 C rp    r3
35 C up    r4
36 C n     r5
37 C vl    r6
38
39 ASM_START()
40 PROLOGUE(mpn_mul_1)
41         mtctr   r5
42         addi    r3,r3,-4        C adjust res_ptr, it's offset before it's used
43         li      r12,0           C clear upper product reg
44         addic   r0,r0,0         C clear cy
45 C Start software pipeline
46         lwz     r8,0(r4)
47         bdz     L(end3)
48         lwzu    r9,4(r4)
49         mullw   r11,r8,r6
50         mulhwu  r0,r8,r6
51         bdz     L(end1)
52 C Software pipelined main loop
53 L(loop):
54         lwz     r8,4(r4)
55         mullw   r10,r9,r6
56         adde    r5,r11,r12
57         mulhwu  r12,r9,r6
58         stw     r5,4(r3)
59         bdz     L(end2)
60         lwzu    r9,8(r4)
61         mullw   r11,r8,r6
62         adde    r7,r10,r0
63         mulhwu  r0,r8,r6
64         stwu    r7,8(r3)
65         bdnz    L(loop)
66 C Finish software pipeline
67 L(end1):
68         mullw   r10,r9,r6
69         adde    r5,r11,r12
70         mulhwu  r12,r9,r6
71         stw     r5,4(r3)
72         adde    r7,r10,r0
73         stwu    r7,8(r3)
74         addze   r3,r12
75         blr
76 L(end2):
77         mullw   r11,r8,r6
78         adde    r7,r10,r0
79         mulhwu  r0,r8,r6
80         stwu    r7,8(r3)
81         adde    r5,r11,r12
82         stw     r5,4(r3)
83         addze   r3,r0
84         blr
85 L(end3):
86         mullw   r11,r8,r6
87         stw     r11,4(r3)
88         mulhwu  r3,r8,r6
89         blr
90 EPILOGUE(mpn_mul_1)