1/* MIPS2 __mpn_lshift --
2
3Copyright (C) 1995-2022 Free Software Foundation, Inc.
4
5This file is part of the GNU MP Library.
6
7The GNU MP Library is free software; you can redistribute it and/or modify
8it under the terms of the GNU Lesser General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or (at your
10option) any later version.
11
12The GNU MP Library is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15License for more details.
16
17You should have received a copy of the GNU Lesser General Public License
18along with the GNU MP Library. If not, see
19<https://www.gnu.org/licenses/>. */
20
21#include <sysdep.h>
22
23/* INPUT PARAMETERS
24 res_ptr $4
25 src_ptr $5
26 size $6
27 cnt $7
28*/
29#ifdef __PIC__
30 .option pic2
31#endif
32ENTRY (__mpn_lshift)
33 .set noreorder
34#ifdef __PIC__
35 .cpload t9
36#endif
37 .set nomacro
38
39 sll $2,$6,2
40 addu $5,$5,$2 /* make r5 point at end of src */
41 lw $10,-4($5) /* load first limb */
42 subu $13,$0,$7
43 addu $4,$4,$2 /* make r4 point at end of res */
44 addiu $6,$6,-1
45 and $9,$6,4-1 /* number of limbs in first loop */
46 beq $9,$0,L(L0) /* if multiple of 4 limbs, skip first loop */
47 srl $2,$10,$13 /* compute function result */
48
49 subu $6,$6,$9
50
51L(Loop0): lw $3,-8($5)
52 addiu $4,$4,-4
53 addiu $5,$5,-4
54 addiu $9,$9,-1
55 sll $11,$10,$7
56 srl $12,$3,$13
57 move $10,$3
58 or $8,$11,$12
59 bne $9,$0,L(Loop0)
60 sw $8,0($4)
61
62L(L0): beq $6,$0,L(Lend)
63 nop
64
65L(Loop): lw $3,-8($5)
66 addiu $4,$4,-16
67 addiu $6,$6,-4
68 sll $11,$10,$7
69 srl $12,$3,$13
70
71 lw $10,-12($5)
72 sll $14,$3,$7
73 or $8,$11,$12
74 sw $8,12($4)
75 srl $9,$10,$13
76
77 lw $3,-16($5)
78 sll $11,$10,$7
79 or $8,$14,$9
80 sw $8,8($4)
81 srl $12,$3,$13
82
83 lw $10,-20($5)
84 sll $14,$3,$7
85 or $8,$11,$12
86 sw $8,4($4)
87 srl $9,$10,$13
88
89 addiu $5,$5,-16
90 or $8,$14,$9
91 bgtz $6,L(Loop)
92 sw $8,0($4)
93
94L(Lend): sll $8,$10,$7
95 j $31
96 sw $8,-4($4)
97 END (__mpn_lshift)
98

source code of glibc/sysdeps/mips/lshift.S