Reorganisation of the source tree
[ghc-hetmet.git] / rts / gmp / 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 (C) 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 2.1 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; see the file COPYING.LIB.  If not, write to
20 dnl  the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 dnl  MA 02111-1307, USA.
22
23
24 include(`../config.m4')
25
26 C INPUT PARAMETERS
27 C res_ptr       o0
28 C s1_ptr        o1
29 C size          o2
30 C s2_limb       o3
31
32 ASM_START()
33 PROLOGUE(mpn_mul_1)
34         sll     %o2,4,%g1
35         and     %g1,(4-1)<<4,%g1
36 ifdef(`PIC',
37 `       mov     %o7,%g4         C Save return address register
38 0:      call    1f
39         add     %o7,L(1)-0b,%g3
40 1:      mov     %g4,%o7         C Restore return address register
41 ',
42 `       sethi   %hi(L(1)),%g3
43         or      %g3,%lo(L(1)),%g3
44 ')
45         jmp     %g3+%g1
46         ld      [%o1+0],%o4     C 1
47 L(1):
48 L(L00): add     %o0,-4,%o0
49         add     %o1,-4,%o1
50         b       L(loop00)       C 4, 8, 12, ...
51         orcc    %g0,%g0,%g2
52 L(L01): b       L(loop01)       C 1, 5, 9, ...
53         orcc    %g0,%g0,%g2
54         nop
55         nop
56 L(L10): add     %o0,-12,%o0     C 2, 6, 10, ...
57         add     %o1,4,%o1
58         b       L(loop10)
59         orcc    %g0,%g0,%g2
60         nop
61 L(L11): add     %o0,-8,%o0      C 3, 7, 11, ...
62         add     %o1,-8,%o1
63         b       L(loop11)
64         orcc    %g0,%g0,%g2
65
66 L(loop):
67         addcc   %g3,%g2,%g3     C 1
68         ld      [%o1+4],%o4     C 2
69         st      %g3,[%o0+0]     C 1
70         rd      %y,%g2          C 1
71 L(loop00):
72         umul    %o4,%o3,%g3     C 2
73         addxcc  %g3,%g2,%g3     C 2
74         ld      [%o1+8],%o4     C 3
75         st      %g3,[%o0+4]     C 2
76         rd      %y,%g2          C 2
77 L(loop11):
78         umul    %o4,%o3,%g3     C 3
79         addxcc  %g3,%g2,%g3     C 3
80         ld      [%o1+12],%o4    C 4
81         add     %o1,16,%o1
82         st      %g3,[%o0+8]     C 3
83         rd      %y,%g2          C 3
84 L(loop10):
85         umul    %o4,%o3,%g3     C 4
86         addxcc  %g3,%g2,%g3     C 4
87         ld      [%o1+0],%o4     C 1
88         st      %g3,[%o0+12]    C 4
89         add     %o0,16,%o0
90         rd      %y,%g2          C 4
91         addx    %g0,%g2,%g2
92 L(loop01):
93         addcc   %o2,-4,%o2
94         bg      L(loop)
95         umul    %o4,%o3,%g3     C 1
96
97         addcc   %g3,%g2,%g3     C 4
98         st      %g3,[%o0+0]     C 4
99         rd      %y,%g2          C 4
100
101         retl
102         addx    %g0,%g2,%o0
103 EPILOGUE(mpn_mul_1)