Debian Codegraph @

carlfw/src/udivsi3_i4i-Os.S

raw
1 /* Copyright (C) 2006 Free Software Foundation, Inc.
2
3 This file is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 In addition to the permissions in the GNU General Public License, the
9 Free Software Foundation gives you unlimited permission to link the
10 compiled version of this file into combinations with other programs,
11 and to distribute those combinations without any restriction coming
12 from the use of this file. (The General Public License restrictions
13 do apply in other respects; for example, they cover modification of
14 the file, and distribution when not linked into a combine
15 executable.)
16
17 This file is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; see the file COPYING. If not, write to
24 with this program; If not, see <http://www.gnu.org/licenses/>. */
25
26 /* Moderately Space-optimized libgcc routines for the Renesas SH /
27 STMicroelectronics ST40 CPUs.
28 Contributed by J"orn Rennecke [email protected]. */
29
30 /* Size: 186 bytes jointly for udivsi3_i4i and sdivsi3_i4i
31 sh4-200 run times:
32 udiv small divisor: 55 cycles
33 udiv large divisor: 52 cycles
34 sdiv small divisor, positive result: 59 cycles
35 sdiv large divisor, positive result: 56 cycles
36 sdiv small divisor, negative result: 65 cycles (*)
37 sdiv large divisor, negative result: 62 cycles (*)
38 (*): r2 is restored in the rts delay slot and has a lingering latency
39 of two more cycles. */
40 .balign 4
41 .global ___udivsi3_i4i
42 .global ___udivsi3_i4
43 .set ___udivsi3_i4, ___udivsi3_i4i
44 ___udivsi3_i4i:
45 sts pr,r1
46 mov.l r4,@-r15
47 extu.w r5,r0
48 cmp/eq r5,r0
49 swap.w r4,r0
50 shlr16 r4
51 bf/s large_divisor
52 div0u
53 mov.l r5,@-r15
54 shll16 r5
55 sdiv_small_divisor:
56 div1 r5,r4
57 bsr div6
58 div1 r5,r4
59 div1 r5,r4
60 bsr div6
61 div1 r5,r4
62 xtrct r4,r0
63 xtrct r0,r4
64 bsr div7
65 swap.w r4,r4
66 div1 r5,r4
67 bsr div7
68 div1 r5,r4
69 xtrct r4,r0
70 mov.l @r15+,r5
71 swap.w r0,r0
72 mov.l @r15+,r4
73 jmp @r1
74 rotcl r0
75 div7:
76 div1 r5,r4
77 div6:
78 div1 r5,r4; div1 r5,r4; div1 r5,r4
79 div1 r5,r4; div1 r5,r4; rts; div1 r5,r4
80
81 divx3:
82 rotcl r0
83 div1 r5,r4
84 rotcl r0
85 div1 r5,r4
86 rotcl r0
87 rts
88 div1 r5,r4
89
90 large_divisor:
91 mov.l r5,@-r15
92 sdiv_large_divisor:
93 xor r4,r0
94 .rept 4
95 rotcl r0
96 bsr divx3
97 div1 r5,r4
98 .endr
99 mov.l @r15+,r5
100 mov.l @r15+,r4
101 jmp @r1
102 rotcl r0
103
104 .global __sdivsi3_i4i
105 .global __sdivsi3_i4
106 .global __sdivsi3
107 .set __sdivsi3_i4, __sdivsi3_i4i
108 .set __sdivsi3, __sdivsi3_i4i
109 __sdivsi3_i4i:
110 mov.l r4,@-r15
111 cmp/pz r5
112 mov.l r5,@-r15
113 bt/s pos_divisor
114 cmp/pz r4
115 neg r5,r5
116 extu.w r5,r0
117 bt/s neg_result
118 cmp/eq r5,r0
119 neg r4,r4
120 pos_result:
121 swap.w r4,r0
122 bra sdiv_check_divisor
123 sts pr,r1
124 pos_divisor:
125 extu.w r5,r0
126 bt/s pos_result
127 cmp/eq r5,r0
128 neg r4,r4
129 neg_result:
130 mova negate_result,r0
131 ;
132 mov r0,r1
133 swap.w r4,r0
134 lds r2,macl
135 sts pr,r2
136 sdiv_check_divisor:
137 shlr16 r4
138 bf/s sdiv_large_divisor
139 div0u
140 bra sdiv_small_divisor
141 shll16 r5
142 .balign 4
143 negate_result:
144 neg r0,r0
145 jmp @r2
146 sts macl,r2