1dnl  PowerPC-32 mpn_mul_1 -- Multiply a limb vector with a limb and store the
2dnl  result in a second limb vector.
3
4dnl  Copyright 1995, 1997, 2000, 2002, 2003, 2005 Free Software Foundation,
5dnl  Inc.
6
7dnl  This file is part of the GNU MP Library.
8
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of the GNU Lesser General Public License as published
11dnl  by the Free Software Foundation; either version 3 of the License, or (at
12dnl  your option) any later version.
13
14dnl  The GNU MP Library is distributed in the hope that it will be useful, but
15dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
17dnl  License for more details.
18
19dnl  You should have received a copy of the GNU Lesser General Public License
20dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
21
22include(`../config.m4')
23
24C                cycles/limb
25C 603e:            ?
26C 604e:            4.0
27C 75x (G3):        4.5-11
28C 7400,7410 (G4):  4.5-11
29C 744x,745x (G4+): 6.0
30C power4/ppc970:   6.0
31C power5:          5.63
32
33C INPUT PARAMETERS
34C rp	r3
35C up	r4
36C n	r5
37C vl	r6
38
39ASM_START()
40PROLOGUE(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
45C 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)
52C Software pipelined main loop
53L(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)
66C Finish software pipeline
67L(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
76L(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
85L(end3):
86	mullw	r11,r8,r6
87	stw	r11,4(r3)
88	mulhwu	r3,r8,r6
89	blr
90EPILOGUE(mpn_mul_1)
91