Updated from ../=mpn/gmp-1.906.7
[kopensolaris-gnu/glibc.git] / sysdeps / alpha / alphaev5 / rshift.s
1  # Alpha EV5 __mpn_rshift --
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_rshift
35         .ent    __mpn_rshift
36 __mpn_rshift:
37         .frame  $30,0,$26,0
38
39         ldq     $4,0($17)       # load first limb
40         subq    $31,$19,$20
41         subq    $18,1,$18
42         and     $18,4-1,$28     # number of limbs in first loop
43         sll     $4,$20,$0       # compute function result
44
45         beq     $28,L0
46         subq    $18,$28,$18
47
48         .align  3
49 Loop0:  ldq     $3,8($17)
50         addq    $16,8,$16
51         srl     $4,$19,$5
52         addq    $17,8,$17
53         subq    $28,1,$28
54         sll     $3,$20,$6
55         or      $3,$3,$4
56         or      $5,$6,$8
57         stq     $8,-8($16)
58         bne     $28,Loop0
59
60 L0:     srl     $4,$19,$24
61         beq     $18,Lend
62  # warm up phase 1
63         ldq     $1,8($17)
64         subq    $18,4,$18
65         ldq     $2,16($17)
66         ldq     $3,24($17)
67         ldq     $4,32($17)
68         beq     $18,Lcool1
69  # warm up phase 2
70         sll     $1,$20,$7
71         srl     $1,$19,$21
72         sll     $2,$20,$8
73         ldq     $1,40($17)
74         srl     $2,$19,$22
75         ldq     $2,48($17)
76         sll     $3,$20,$5
77         or      $7,$24,$7
78         srl     $3,$19,$23
79         or      $8,$21,$8
80         sll     $4,$20,$6
81         ldq     $3,56($17)
82         srl     $4,$19,$24
83         ldq     $4,64($17)
84         subq    $18,4,$18
85         beq     $18,Lcool2
86         .align  4
87  # main loop
88 Loop:   stq     $7,0($16)
89         or      $5,$22,$5
90         stq     $8,8($16)
91         or      $6,$23,$6
92
93         sll     $1,$20,$7
94         subq    $18,4,$18
95         srl     $1,$19,$21
96         unop    # ldq   $31,-96($17)
97
98         sll     $2,$20,$8
99         ldq     $1,72($17)
100         srl     $2,$19,$22
101         ldq     $2,80($17)
102
103         stq     $5,16($16)
104         or      $7,$24,$7
105         stq     $6,24($16)
106         or      $8,$21,$8
107
108         sll     $3,$20,$5
109         unop    # ldq   $31,-96($17)
110         srl     $3,$19,$23
111         addq    $16,32,$16
112
113         sll     $4,$20,$6
114         ldq     $3,88($17)
115         srl     $4,$19,$24
116         ldq     $4,96($17)
117
118         addq    $17,32,$17
119         bne     $18,Loop
120         unop
121         unop
122  # cool down phase 2/1
123 Lcool2: stq     $7,0($16)
124         or      $5,$22,$5
125         stq     $8,8($16)
126         or      $6,$23,$6
127         sll     $1,$20,$7
128         srl     $1,$19,$21
129         sll     $2,$20,$8
130         srl     $2,$19,$22
131         stq     $5,16($16)
132         or      $7,$24,$7
133         stq     $6,24($16)
134         or      $8,$21,$8
135         sll     $3,$20,$5
136         srl     $3,$19,$23
137         sll     $4,$20,$6
138         srl     $4,$19,$24
139  # cool down phase 2/2
140         stq     $7,32($16)
141         or      $5,$22,$5
142         stq     $8,40($16)
143         or      $6,$23,$6
144         stq     $5,48($16)
145         stq     $6,56($16)
146  # cool down phase 2/3
147         stq     $24,64($16)
148         ret     $31,($26),1
149
150  # cool down phase 1/1
151 Lcool1: sll     $1,$20,$7
152         srl     $1,$19,$21
153         sll     $2,$20,$8
154         srl     $2,$19,$22
155         sll     $3,$20,$5
156         or      $7,$24,$7
157         srl     $3,$19,$23
158         or      $8,$21,$8
159         sll     $4,$20,$6
160         srl     $4,$19,$24
161  # cool down phase 1/2
162         stq     $7,0($16)
163         or      $5,$22,$5
164         stq     $8,8($16)
165         or      $6,$23,$6
166         stq     $5,16($16)
167         stq     $6,24($16)
168         stq     $24,32($16)
169         ret     $31,($26),1
170
171 Lend:   stq     $24,0($16)
172         ret     $31,($26),1
173         .end    __mpn_rshift