Updated from /src/gmp-1.937
[kopensolaris-gnu/glibc.git] / sysdeps / alpha / alphaev5 / lshift.s
1  # Alpha EV5 __mpn_lshift --
2
3  # Copyright (C) 1994, 1995 Free Software Foundation, Inc.
4
5  # This file is part of the GNU MP Library.
6
7  # The GNU MP Library is free software; you can redistribute it and/or modify
8  # it under the terms of the GNU Library General Public License as published by
9  # the Free Software Foundation; either version 2 of the License, or (at your
10  # option) any later version.
11
12  # The GNU MP Library is distributed in the hope that it will be useful, but
13  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
15  # License for more details.
16
17  # You should have received a copy of the GNU Library General Public License
18  # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
19  # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21
22  # INPUT PARAMETERS
23  # res_ptr      r16
24  # s1_ptr       r17
25  # size         r18
26  # cnt          r19
27
28  # This code runs at 3.25 cycles/limb on the EV5.
29
30         .set    noreorder
31         .set    noat
32 .text
33         .align  3
34         .globl  __mpn_lshift
35         .ent    __mpn_lshift
36 __mpn_lshift:
37         .frame  $30,0,$26,0
38
39         s8addq  $18,$17,$17     # make r17 point at end of s1
40         ldq     $4,-8($17)      # load first limb
41         subq    $31,$19,$20
42         s8addq  $18,$16,$16     # make r16 point at end of RES
43         subq    $18,1,$18
44         and     $18,4-1,$28     # number of limbs in first loop
45         srl     $4,$20,$0       # compute function result
46
47         beq     $28,.L0
48         subq    $18,$28,$18
49
50         .align  3
51 .Loop0: ldq     $3,-16($17)
52         subq    $16,8,$16
53         sll     $4,$19,$5
54         subq    $17,8,$17
55         subq    $28,1,$28
56         srl     $3,$20,$6
57         or      $3,$3,$4
58         or      $5,$6,$8
59         stq     $8,0($16)
60         bne     $28,.Loop0
61
62 .L0:    sll     $4,$19,$24
63         beq     $18,.Lend
64  # warm up phase 1
65         ldq     $1,-16($17)
66         subq    $18,4,$18
67         ldq     $2,-24($17)
68         ldq     $3,-32($17)
69         ldq     $4,-40($17)
70         beq     $18,.Lend1
71  # warm up phase 2
72         srl     $1,$20,$7
73         sll     $1,$19,$21
74         srl     $2,$20,$8
75         ldq     $1,-48($17)
76         sll     $2,$19,$22
77         ldq     $2,-56($17)
78         srl     $3,$20,$5
79         or      $7,$24,$7
80         sll     $3,$19,$23
81         or      $8,$21,$8
82         srl     $4,$20,$6
83         ldq     $3,-64($17)
84         sll     $4,$19,$24
85         ldq     $4,-72($17)
86         subq    $18,4,$18
87         beq     $18,.Lend2
88         .align  4
89  # main loop
90 .Loop:  stq     $7,-8($16)
91         or      $5,$22,$5
92         stq     $8,-16($16)
93         or      $6,$23,$6
94
95         srl     $1,$20,$7
96         subq    $18,4,$18
97         sll     $1,$19,$21
98         unop    # ldq   $31,-96($17)
99
100         srl     $2,$20,$8
101         ldq     $1,-80($17)
102         sll     $2,$19,$22
103         ldq     $2,-88($17)
104
105         stq     $5,-24($16)
106         or      $7,$24,$7
107         stq     $6,-32($16)
108         or      $8,$21,$8
109
110         srl     $3,$20,$5
111         unop    # ldq   $31,-96($17)
112         sll     $3,$19,$23
113         subq    $16,32,$16
114
115         srl     $4,$20,$6
116         ldq     $3,-96($17)
117         sll     $4,$19,$24
118         ldq     $4,-104($17)
119
120         subq    $17,32,$17
121         bne     $18,.Loop
122  # cool down phase 2/1
123 .Lend2: stq     $7,-8($16)
124         or      $5,$22,$5
125         stq     $8,-16($16)
126         or      $6,$23,$6
127         srl     $1,$20,$7
128         sll     $1,$19,$21
129         srl     $2,$20,$8
130         sll     $2,$19,$22
131         stq     $5,-24($16)
132         or      $7,$24,$7
133         stq     $6,-32($16)
134         or      $8,$21,$8
135         srl     $3,$20,$5
136         sll     $3,$19,$23
137         srl     $4,$20,$6
138         sll     $4,$19,$24
139  # cool down phase 2/2
140         stq     $7,-40($16)
141         or      $5,$22,$5
142         stq     $8,-48($16)
143         or      $6,$23,$6
144         stq     $5,-56($16)
145         stq     $6,-64($16)
146  # cool down phase 2/3
147         stq     $24,-72($16)
148         ret     $31,($26),1
149
150  # cool down phase 1/1
151 .Lend1: srl     $1,$20,$7
152         sll     $1,$19,$21
153         srl     $2,$20,$8
154         sll     $2,$19,$22
155         srl     $3,$20,$5
156         or      $7,$24,$7
157         sll     $3,$19,$23
158         or      $8,$21,$8
159         srl     $4,$20,$6
160         sll     $4,$19,$24
161  # cool down phase 1/2
162         stq     $7,-8($16)
163         or      $5,$22,$5
164         stq     $8,-16($16)
165         or      $6,$23,$6
166         stq     $5,-24($16)
167         stq     $6,-32($16)
168         stq     $24,-40($16)
169         ret     $31,($26),1
170
171 .Lend:  stq     $24,-8($16)
172         ret     $31,($26),1
173         .end    __mpn_lshift