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