Reorganisation of the source tree
[ghc-hetmet.git] / rts / gmp / mpn / sparc32 / v8 / addmul_1.asm
1 dnl  SPARC v8 mpn_addmul_1 -- Multiply a limb vector with a limb and
2 dnl  add the result to a second limb vector.
3
4 dnl  Copyright (C) 1992, 1993, 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_addmul_1)
34         orcc    %g0,%g0,%g2
35         ld      [%o1+0],%o4     C 1
36
37         sll     %o2,4,%g1
38         and     %g1,(4-1)<<4,%g1
39 ifdef(`PIC',
40 `       mov     %o7,%g4         C Save return address register
41 0:      call    1f
42         add     %o7,L(1)-0b,%g3
43 1:      mov     %g4,%o7         C Restore return address register
44 ',
45 `       sethi   %hi(L(1)),%g3
46         or      %g3,%lo(L(1)),%g3
47 ')
48         jmp     %g3+%g1
49         nop
50 L(1):
51 L(L00): add     %o0,-4,%o0
52         b       L(loop00)       C 4, 8, 12, ...
53         add     %o1,-4,%o1
54         nop
55 L(L01): b       L(loop01)       C 1, 5, 9, ...
56         nop
57         nop
58         nop
59 L(L10): add     %o0,-12,%o0     C 2, 6, 10, ...
60         b       L(loop10)
61         add     %o1,4,%o1
62         nop
63 L(L11): add     %o0,-8,%o0      C 3, 7, 11, ...
64         b       L(loop11)
65         add     %o1,-8,%o1
66         nop
67
68 L(loop):
69         addcc   %g3,%g2,%g3     C 1
70         ld      [%o1+4],%o4     C 2
71         rd      %y,%g2          C 1
72         addx    %g0,%g2,%g2
73         ld      [%o0+0],%g1     C 2
74         addcc   %g1,%g3,%g3
75         st      %g3,[%o0+0]     C 1
76 L(loop00):
77         umul    %o4,%o3,%g3     C 2
78         ld      [%o0+4],%g1     C 2
79         addxcc  %g3,%g2,%g3     C 2
80         ld      [%o1+8],%o4     C 3
81         rd      %y,%g2          C 2
82         addx    %g0,%g2,%g2
83         nop
84         addcc   %g1,%g3,%g3
85         st      %g3,[%o0+4]     C 2
86 L(loop11):
87         umul    %o4,%o3,%g3     C 3
88         addxcc  %g3,%g2,%g3     C 3
89         ld      [%o1+12],%o4    C 4
90         rd      %y,%g2          C 3
91         add     %o1,16,%o1
92         addx    %g0,%g2,%g2
93         ld      [%o0+8],%g1     C 2
94         addcc   %g1,%g3,%g3
95         st      %g3,[%o0+8]     C 3
96 L(loop10):
97         umul    %o4,%o3,%g3     C 4
98         addxcc  %g3,%g2,%g3     C 4
99         ld      [%o1+0],%o4     C 1
100         rd      %y,%g2          C 4
101         addx    %g0,%g2,%g2
102         ld      [%o0+12],%g1    C 2
103         addcc   %g1,%g3,%g3
104         st      %g3,[%o0+12]    C 4
105         add     %o0,16,%o0
106         addx    %g0,%g2,%g2
107 L(loop01):
108         addcc   %o2,-4,%o2
109         bg      L(loop)
110         umul    %o4,%o3,%g3     C 1
111
112         addcc   %g3,%g2,%g3     C 4
113         rd      %y,%g2          C 4
114         addx    %g0,%g2,%g2
115         ld      [%o0+0],%g1     C 2
116         addcc   %g1,%g3,%g3
117         st      %g3,[%o0+0]     C 4
118         addx    %g0,%g2,%o0
119
120         retl
121          nop
122 EPILOGUE(mpn_addmul_1)