Upload Tizen:Base source
[external/gmp.git] / mpn / sparc32 / v8 / mul_1.asm
1 dnl  SPARC v8 mpn_mul_1 -- Multiply a limb vector with a single limb and
2 dnl  store the product in a second limb vector.
3
4 dnl  Copyright 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
5
6 dnl  This file is part of the GNU MP Library.
7
8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
9 dnl  it under the terms of the GNU Lesser General Public License as published
10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
11 dnl  your option) any later version.
12
13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 dnl  License for more details.
17
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21
22 include(`../config.m4')
23
24 C INPUT PARAMETERS
25 C res_ptr       o0
26 C s1_ptr        o1
27 C size          o2
28 C s2_limb       o3
29
30 ASM_START()
31 PROLOGUE(mpn_mul_1)
32         sll     %o2,4,%g1
33         and     %g1,(4-1)<<4,%g1
34 ifdef(`PIC',
35 `       mov     %o7,%g4         C Save return address register
36 0:      call    1f
37         add     %o7,L(1)-0b,%g3
38 1:      mov     %g4,%o7         C Restore return address register
39 ',
40 `       sethi   %hi(L(1)),%g3
41         or      %g3,%lo(L(1)),%g3
42 ')
43         jmp     %g3+%g1
44         ld      [%o1+0],%o4     C 1
45 L(1):
46 L(L00): add     %o0,-4,%o0
47         add     %o1,-4,%o1
48         b       L(loop00)       C 4, 8, 12, ...
49         orcc    %g0,%g0,%g2
50 L(L01): b       L(loop01)       C 1, 5, 9, ...
51         orcc    %g0,%g0,%g2
52         nop
53         nop
54 L(L10): add     %o0,-12,%o0     C 2, 6, 10, ...
55         add     %o1,4,%o1
56         b       L(loop10)
57         orcc    %g0,%g0,%g2
58         nop
59 L(L11): add     %o0,-8,%o0      C 3, 7, 11, ...
60         add     %o1,-8,%o1
61         b       L(loop11)
62         orcc    %g0,%g0,%g2
63
64 L(loop):
65         addcc   %g3,%g2,%g3     C 1
66         ld      [%o1+4],%o4     C 2
67         st      %g3,[%o0+0]     C 1
68         rd      %y,%g2          C 1
69 L(loop00):
70         umul    %o4,%o3,%g3     C 2
71         addxcc  %g3,%g2,%g3     C 2
72         ld      [%o1+8],%o4     C 3
73         st      %g3,[%o0+4]     C 2
74         rd      %y,%g2          C 2
75 L(loop11):
76         umul    %o4,%o3,%g3     C 3
77         addxcc  %g3,%g2,%g3     C 3
78         ld      [%o1+12],%o4    C 4
79         add     %o1,16,%o1
80         st      %g3,[%o0+8]     C 3
81         rd      %y,%g2          C 3
82 L(loop10):
83         umul    %o4,%o3,%g3     C 4
84         addxcc  %g3,%g2,%g3     C 4
85         ld      [%o1+0],%o4     C 1
86         st      %g3,[%o0+12]    C 4
87         add     %o0,16,%o0
88         rd      %y,%g2          C 4
89         addx    %g0,%g2,%g2
90 L(loop01):
91         addcc   %o2,-4,%o2
92         bg      L(loop)
93         umul    %o4,%o3,%g3     C 1
94
95         addcc   %g3,%g2,%g3     C 4
96         st      %g3,[%o0+0]     C 4
97         rd      %y,%g2          C 4
98
99         retl
100         addx    %g0,%g2,%o0
101 EPILOGUE(mpn_mul_1)