fdb089550f077acf7f049ef2bb8969c8eed01de9
[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 4.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,Lcool1
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,Lcool1
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         unop
123         unop
124  # cool down phase 2/1
125 Lcool1: stq     $7,-8($16)
126         or      $5,$22,$5
127         stq     $8,-16($16)
128         or      $6,$23,$6
129         srl     $1,$20,$7
130         sll     $1,$19,$21
131         srl     $2,$20,$8
132         sll     $2,$19,$22
133         stq     $5,-24($16)
134         or      $7,$24,$7
135         stq     $6,-32($16)
136         or      $8,$21,$8
137         srl     $3,$20,$5
138         sll     $3,$19,$23
139         srl     $4,$20,$6
140         sll     $4,$19,$24
141  # cool down phase 2/2
142         stq     $7,-40($16)
143         or      $5,$22,$5
144         stq     $8,-48($16)
145         or      $6,$23,$6
146         stq     $5,-56($16)
147         stq     $6,-64($16)
148  # cool down phase 2/3
149         stq     $24,-72($16)
150         ret     $31,($26),1
151
152  # cool down phase 1/1
153 Lcool1: srl     $1,$20,$7
154         sll     $1,$19,$21
155         srl     $2,$20,$8
156         sll     $2,$19,$22
157         srl     $3,$20,$5
158         or      $7,$24,$7
159         sll     $3,$19,$23
160         or      $8,$21,$8
161         srl     $4,$20,$6
162         sll     $4,$19,$24
163  # cool down phase 1/2
164         stq     $7,-8($16)
165         or      $5,$22,$5
166         stq     $8,-16($16)
167         or      $6,$23,$6
168         stq     $5,-24($16)
169         stq     $6,-32($16)
170         stq     $24,-40($16)
171         ret     $31,($26),1
172
173 Lend    stq     $24,-8($16)
174         ret     $31,($26),1
175         .end    __mpn_lshift