Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libgmp / mpn / alpha / lshift.s
1 /* $Id$
2  # Alpha 21064 __mpn_lshift --
3
4  # Copyright (C) 1994, 1995 Free Software Foundation, Inc.
5
6  # This file is part of the GNU MP Library.
7
8  # The GNU MP Library is free software; you can redistribute it and/or modify
9  # it under the terms of the GNU Library General Public License as published by
10  # the Free Software Foundation; either version 2 of the License, or (at your
11  # option) any later version.
12
13  # The GNU MP Library is distributed in the hope that it will be useful, but
14  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
16  # License for more details.
17
18  # You should have received a copy of the GNU Library General Public License
19  # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20  # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21  # MA 02111-1307, USA.
22
23
24  # INPUT PARAMETERS
25  # res_ptr      r16
26  # s1_ptr       r17
27  # size         r18
28  # cnt          r19
29
30  # This code runs at 4.8 cycles/limb on the 21064.  With infinite unrolling,
31  # it would take 4 cycles/limb.  It should be possible to get down to 3
32  # cycles/limb since both ldq and stq can be paired with the other used
33  # instructions.  But there are many restrictions in the 21064 pipeline that
34  # makes it hard, if not impossible, to get down to 3 cycles/limb:
35
36  # 1. ldq has a 3 cycle delay, srl and sll have a 2 cycle delay.
37  # 2. Only aligned instruction pairs can be paired.
38  # 3. The store buffer or silo might not be able to deal with the bandwidth.
39 */
40
41         .set    noreorder
42         .set    noat
43 .text
44         .align  3
45         .globl  __mpn_lshift
46         .ent    __mpn_lshift
47 __mpn_lshift:
48         .frame  $30,0,$26,0
49
50         s8addq  $18,$17,$17     # make r17 point at end of s1
51         ldq     $4,-8($17)      # load first limb
52         subq    $17,8,$17
53         subq    $31,$19,$7
54         s8addq  $18,$16,$16     # make r16 point at end of RES
55         subq    $18,1,$18
56         and     $18,4-1,$20     # number of limbs in first loop
57         srl     $4,$7,$0        # compute function result
58
59         beq     $20,.L0
60         subq    $18,$20,$18
61
62         .align  3
63 .Loop0:
64         ldq     $3,-8($17)
65         subq    $16,8,$16
66         subq    $17,8,$17
67         subq    $20,1,$20
68         sll     $4,$19,$5
69         srl     $3,$7,$6
70         bis     $3,$3,$4
71         bis     $5,$6,$8
72         stq     $8,0($16)
73         bne     $20,.Loop0
74
75 .L0:    beq     $18,.Lend
76
77         .align  3
78 .Loop:  ldq     $3,-8($17)
79         subq    $16,32,$16
80         subq    $18,4,$18
81         sll     $4,$19,$5
82         srl     $3,$7,$6
83
84         ldq     $4,-16($17)
85         sll     $3,$19,$1
86         bis     $5,$6,$8
87         stq     $8,24($16)
88         srl     $4,$7,$2
89
90         ldq     $3,-24($17)
91         sll     $4,$19,$5
92         bis     $1,$2,$8
93         stq     $8,16($16)
94         srl     $3,$7,$6
95
96         ldq     $4,-32($17)
97         sll     $3,$19,$1
98         bis     $5,$6,$8
99         stq     $8,8($16)
100         srl     $4,$7,$2
101
102         subq    $17,32,$17
103         bis     $1,$2,$8
104         stq     $8,0($16)
105
106         bgt     $18,.Loop
107
108 .Lend:  sll     $4,$19,$8
109         stq     $8,-8($16)
110         ret     $31,($26),1
111         .end    __mpn_lshift