1 /* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001
2 Free Software Foundation, Inc.
4 This file is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
9 In addition to the permissions in the GNU General Public License, the
10 Free Software Foundation gives you unlimited permission to link the
11 compiled version of this file into combinations with other programs,
12 and to distribute those combinations without any restriction coming
13 from the use of this file. (The General Public License restrictions
14 do apply in other respects; for example, they cover modification of
15 the file, and distribution when not linked into a combine
18 This file is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; see the file COPYING. If not, write to
25 the Free Software Foundation, 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. */
28 !! libgcc routines for the Hitachi SH cpu.
29 !! Contributed by Steve Chamberlain.
32 !! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
33 !! recoded in assembly by Toshiyasu Morita
36 /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
37 ELF local label prefixes by J"orn Rennecke
41 #define LOCAL(X) .L_##X
43 #define LOCAL(X) L_##X
47 #define GLOBAL(X) __##X
51 #define GLOBAL(X) ___##X
55 .global GLOBAL(ashiftrt_r4_0)
56 .global GLOBAL(ashiftrt_r4_1)
57 .global GLOBAL(ashiftrt_r4_2)
58 .global GLOBAL(ashiftrt_r4_3)
59 .global GLOBAL(ashiftrt_r4_4)
60 .global GLOBAL(ashiftrt_r4_5)
61 .global GLOBAL(ashiftrt_r4_6)
62 .global GLOBAL(ashiftrt_r4_7)
63 .global GLOBAL(ashiftrt_r4_8)
64 .global GLOBAL(ashiftrt_r4_9)
65 .global GLOBAL(ashiftrt_r4_10)
66 .global GLOBAL(ashiftrt_r4_11)
67 .global GLOBAL(ashiftrt_r4_12)
68 .global GLOBAL(ashiftrt_r4_13)
69 .global GLOBAL(ashiftrt_r4_14)
70 .global GLOBAL(ashiftrt_r4_15)
71 .global GLOBAL(ashiftrt_r4_16)
72 .global GLOBAL(ashiftrt_r4_17)
73 .global GLOBAL(ashiftrt_r4_18)
74 .global GLOBAL(ashiftrt_r4_19)
75 .global GLOBAL(ashiftrt_r4_20)
76 .global GLOBAL(ashiftrt_r4_21)
77 .global GLOBAL(ashiftrt_r4_22)
78 .global GLOBAL(ashiftrt_r4_23)
79 .global GLOBAL(ashiftrt_r4_24)
80 .global GLOBAL(ashiftrt_r4_25)
81 .global GLOBAL(ashiftrt_r4_26)
82 .global GLOBAL(ashiftrt_r4_27)
83 .global GLOBAL(ashiftrt_r4_28)
84 .global GLOBAL(ashiftrt_r4_29)
85 .global GLOBAL(ashiftrt_r4_30)
86 .global GLOBAL(ashiftrt_r4_31)
87 .global GLOBAL(ashiftrt_r4_32)
90 GLOBAL(ashiftrt_r4_32):
91 GLOBAL(ashiftrt_r4_31):
96 GLOBAL(ashiftrt_r4_30):
98 GLOBAL(ashiftrt_r4_29):
100 GLOBAL(ashiftrt_r4_28):
102 GLOBAL(ashiftrt_r4_27):
104 GLOBAL(ashiftrt_r4_26):
106 GLOBAL(ashiftrt_r4_25):
108 GLOBAL(ashiftrt_r4_24):
114 GLOBAL(ashiftrt_r4_23):
116 GLOBAL(ashiftrt_r4_22):
118 GLOBAL(ashiftrt_r4_21):
120 GLOBAL(ashiftrt_r4_20):
122 GLOBAL(ashiftrt_r4_19):
124 GLOBAL(ashiftrt_r4_18):
126 GLOBAL(ashiftrt_r4_17):
128 GLOBAL(ashiftrt_r4_16):
133 GLOBAL(ashiftrt_r4_15):
135 GLOBAL(ashiftrt_r4_14):
137 GLOBAL(ashiftrt_r4_13):
139 GLOBAL(ashiftrt_r4_12):
141 GLOBAL(ashiftrt_r4_11):
143 GLOBAL(ashiftrt_r4_10):
145 GLOBAL(ashiftrt_r4_9):
147 GLOBAL(ashiftrt_r4_8):
149 GLOBAL(ashiftrt_r4_7):
151 GLOBAL(ashiftrt_r4_6):
153 GLOBAL(ashiftrt_r4_5):
155 GLOBAL(ashiftrt_r4_4):
157 GLOBAL(ashiftrt_r4_3):
159 GLOBAL(ashiftrt_r4_2):
161 GLOBAL(ashiftrt_r4_1):
165 GLOBAL(ashiftrt_r4_0):
189 .global GLOBAL(ashrsi3)
194 mova LOCAL(ashrsi3_table),r0
205 LOCAL(ashrsi3_table):
206 .byte LOCAL(ashrsi3_0)-LOCAL(ashrsi3_table)
207 .byte LOCAL(ashrsi3_1)-LOCAL(ashrsi3_table)
208 .byte LOCAL(ashrsi3_2)-LOCAL(ashrsi3_table)
209 .byte LOCAL(ashrsi3_3)-LOCAL(ashrsi3_table)
210 .byte LOCAL(ashrsi3_4)-LOCAL(ashrsi3_table)
211 .byte LOCAL(ashrsi3_5)-LOCAL(ashrsi3_table)
212 .byte LOCAL(ashrsi3_6)-LOCAL(ashrsi3_table)
213 .byte LOCAL(ashrsi3_7)-LOCAL(ashrsi3_table)
214 .byte LOCAL(ashrsi3_8)-LOCAL(ashrsi3_table)
215 .byte LOCAL(ashrsi3_9)-LOCAL(ashrsi3_table)
216 .byte LOCAL(ashrsi3_10)-LOCAL(ashrsi3_table)
217 .byte LOCAL(ashrsi3_11)-LOCAL(ashrsi3_table)
218 .byte LOCAL(ashrsi3_12)-LOCAL(ashrsi3_table)
219 .byte LOCAL(ashrsi3_13)-LOCAL(ashrsi3_table)
220 .byte LOCAL(ashrsi3_14)-LOCAL(ashrsi3_table)
221 .byte LOCAL(ashrsi3_15)-LOCAL(ashrsi3_table)
222 .byte LOCAL(ashrsi3_16)-LOCAL(ashrsi3_table)
223 .byte LOCAL(ashrsi3_17)-LOCAL(ashrsi3_table)
224 .byte LOCAL(ashrsi3_18)-LOCAL(ashrsi3_table)
225 .byte LOCAL(ashrsi3_19)-LOCAL(ashrsi3_table)
226 .byte LOCAL(ashrsi3_20)-LOCAL(ashrsi3_table)
227 .byte LOCAL(ashrsi3_21)-LOCAL(ashrsi3_table)
228 .byte LOCAL(ashrsi3_22)-LOCAL(ashrsi3_table)
229 .byte LOCAL(ashrsi3_23)-LOCAL(ashrsi3_table)
230 .byte LOCAL(ashrsi3_24)-LOCAL(ashrsi3_table)
231 .byte LOCAL(ashrsi3_25)-LOCAL(ashrsi3_table)
232 .byte LOCAL(ashrsi3_26)-LOCAL(ashrsi3_table)
233 .byte LOCAL(ashrsi3_27)-LOCAL(ashrsi3_table)
234 .byte LOCAL(ashrsi3_28)-LOCAL(ashrsi3_table)
235 .byte LOCAL(ashrsi3_29)-LOCAL(ashrsi3_table)
236 .byte LOCAL(ashrsi3_30)-LOCAL(ashrsi3_table)
237 .byte LOCAL(ashrsi3_31)-LOCAL(ashrsi3_table)
337 .global GLOBAL(ashlsi3)
342 mova LOCAL(ashlsi3_table),r0
353 LOCAL(ashlsi3_table):
354 .byte LOCAL(ashlsi3_0)-LOCAL(ashlsi3_table)
355 .byte LOCAL(ashlsi3_1)-LOCAL(ashlsi3_table)
356 .byte LOCAL(ashlsi3_2)-LOCAL(ashlsi3_table)
357 .byte LOCAL(ashlsi3_3)-LOCAL(ashlsi3_table)
358 .byte LOCAL(ashlsi3_4)-LOCAL(ashlsi3_table)
359 .byte LOCAL(ashlsi3_5)-LOCAL(ashlsi3_table)
360 .byte LOCAL(ashlsi3_6)-LOCAL(ashlsi3_table)
361 .byte LOCAL(ashlsi3_7)-LOCAL(ashlsi3_table)
362 .byte LOCAL(ashlsi3_8)-LOCAL(ashlsi3_table)
363 .byte LOCAL(ashlsi3_9)-LOCAL(ashlsi3_table)
364 .byte LOCAL(ashlsi3_10)-LOCAL(ashlsi3_table)
365 .byte LOCAL(ashlsi3_11)-LOCAL(ashlsi3_table)
366 .byte LOCAL(ashlsi3_12)-LOCAL(ashlsi3_table)
367 .byte LOCAL(ashlsi3_13)-LOCAL(ashlsi3_table)
368 .byte LOCAL(ashlsi3_14)-LOCAL(ashlsi3_table)
369 .byte LOCAL(ashlsi3_15)-LOCAL(ashlsi3_table)
370 .byte LOCAL(ashlsi3_16)-LOCAL(ashlsi3_table)
371 .byte LOCAL(ashlsi3_17)-LOCAL(ashlsi3_table)
372 .byte LOCAL(ashlsi3_18)-LOCAL(ashlsi3_table)
373 .byte LOCAL(ashlsi3_19)-LOCAL(ashlsi3_table)
374 .byte LOCAL(ashlsi3_20)-LOCAL(ashlsi3_table)
375 .byte LOCAL(ashlsi3_21)-LOCAL(ashlsi3_table)
376 .byte LOCAL(ashlsi3_22)-LOCAL(ashlsi3_table)
377 .byte LOCAL(ashlsi3_23)-LOCAL(ashlsi3_table)
378 .byte LOCAL(ashlsi3_24)-LOCAL(ashlsi3_table)
379 .byte LOCAL(ashlsi3_25)-LOCAL(ashlsi3_table)
380 .byte LOCAL(ashlsi3_26)-LOCAL(ashlsi3_table)
381 .byte LOCAL(ashlsi3_27)-LOCAL(ashlsi3_table)
382 .byte LOCAL(ashlsi3_28)-LOCAL(ashlsi3_table)
383 .byte LOCAL(ashlsi3_29)-LOCAL(ashlsi3_table)
384 .byte LOCAL(ashlsi3_30)-LOCAL(ashlsi3_table)
385 .byte LOCAL(ashlsi3_31)-LOCAL(ashlsi3_table)
494 .global GLOBAL(lshrsi3)
499 mova LOCAL(lshrsi3_table),r0
510 LOCAL(lshrsi3_table):
511 .byte LOCAL(lshrsi3_0)-LOCAL(lshrsi3_table)
512 .byte LOCAL(lshrsi3_1)-LOCAL(lshrsi3_table)
513 .byte LOCAL(lshrsi3_2)-LOCAL(lshrsi3_table)
514 .byte LOCAL(lshrsi3_3)-LOCAL(lshrsi3_table)
515 .byte LOCAL(lshrsi3_4)-LOCAL(lshrsi3_table)
516 .byte LOCAL(lshrsi3_5)-LOCAL(lshrsi3_table)
517 .byte LOCAL(lshrsi3_6)-LOCAL(lshrsi3_table)
518 .byte LOCAL(lshrsi3_7)-LOCAL(lshrsi3_table)
519 .byte LOCAL(lshrsi3_8)-LOCAL(lshrsi3_table)
520 .byte LOCAL(lshrsi3_9)-LOCAL(lshrsi3_table)
521 .byte LOCAL(lshrsi3_10)-LOCAL(lshrsi3_table)
522 .byte LOCAL(lshrsi3_11)-LOCAL(lshrsi3_table)
523 .byte LOCAL(lshrsi3_12)-LOCAL(lshrsi3_table)
524 .byte LOCAL(lshrsi3_13)-LOCAL(lshrsi3_table)
525 .byte LOCAL(lshrsi3_14)-LOCAL(lshrsi3_table)
526 .byte LOCAL(lshrsi3_15)-LOCAL(lshrsi3_table)
527 .byte LOCAL(lshrsi3_16)-LOCAL(lshrsi3_table)
528 .byte LOCAL(lshrsi3_17)-LOCAL(lshrsi3_table)
529 .byte LOCAL(lshrsi3_18)-LOCAL(lshrsi3_table)
530 .byte LOCAL(lshrsi3_19)-LOCAL(lshrsi3_table)
531 .byte LOCAL(lshrsi3_20)-LOCAL(lshrsi3_table)
532 .byte LOCAL(lshrsi3_21)-LOCAL(lshrsi3_table)
533 .byte LOCAL(lshrsi3_22)-LOCAL(lshrsi3_table)
534 .byte LOCAL(lshrsi3_23)-LOCAL(lshrsi3_table)
535 .byte LOCAL(lshrsi3_24)-LOCAL(lshrsi3_table)
536 .byte LOCAL(lshrsi3_25)-LOCAL(lshrsi3_table)
537 .byte LOCAL(lshrsi3_26)-LOCAL(lshrsi3_table)
538 .byte LOCAL(lshrsi3_27)-LOCAL(lshrsi3_table)
539 .byte LOCAL(lshrsi3_28)-LOCAL(lshrsi3_table)
540 .byte LOCAL(lshrsi3_29)-LOCAL(lshrsi3_table)
541 .byte LOCAL(lshrsi3_30)-LOCAL(lshrsi3_table)
542 .byte LOCAL(lshrsi3_31)-LOCAL(lshrsi3_table)
635 ! done all the large groups, do the remainder
640 mova GLOBAL(movstrSI0),r0
646 .global GLOBAL(movstrSI64)
650 .global GLOBAL(movstrSI60)
654 .global GLOBAL(movstrSI56)
658 .global GLOBAL(movstrSI52)
662 .global GLOBAL(movstrSI48)
666 .global GLOBAL(movstrSI44)
670 .global GLOBAL(movstrSI40)
674 .global GLOBAL(movstrSI36)
678 .global GLOBAL(movstrSI32)
682 .global GLOBAL(movstrSI28)
686 .global GLOBAL(movstrSI24)
690 .global GLOBAL(movstrSI20)
694 .global GLOBAL(movstrSI16)
698 .global GLOBAL(movstrSI12)
702 .global GLOBAL(movstrSI8)
706 .global GLOBAL(movstrSI4)
716 .global GLOBAL(movstr)
777 .global GLOBAL(movstr_i4_even)
778 .global GLOBAL(movstr_i4_odd)
779 .global GLOBAL(movstrSI12_i4)
789 GLOBAL(movstr_i4_odd):
801 bt/s L_movstr_2mod4_end
815 GLOBAL(movstr_i4_even):
817 bra L_movstr_start_even
821 GLOBAL(movstrSI12_i4):
834 .global GLOBAL(mulsi3)
838 ! r0 = aabb*ccdd via partial products
840 ! if aa == 0 and cc = 0
844 ! aa = bb*dd + (aa*dd*65536) + (cc*bb*65536)
848 mulu.w r4,r5 ! multiply the lsws macl=bb*dd
849 mov r5,r3 ! r3 = ccdd
850 swap.w r4,r2 ! r2 = bbaa
851 xtrct r2,r3 ! r3 = aacc
852 tst r3,r3 ! msws zero ?
854 rts ! yes - then we have the answer
857 hiset: sts macl,r0 ! r0 = bb*dd
858 mulu.w r2,r5 ! brewing macl = aa*dd
860 mulu.w r3,r4 ! brewing macl = cc*bb
871 !! 4 byte integer Divide code for the Hitachi SH
873 !! args in r4 and r5, result in fpul, clobber dr0, dr2
875 .global GLOBAL(sdivsi3_i4)
885 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
886 !! args in r4 and r5, result in fpul, clobber r2, dr0, dr2
888 .global GLOBAL(sdivsi3_i4)
903 #endif /* ! __SH4__ */
907 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
909 #if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__)
916 !! args in r4 and r5, result in r0 clobber r1,r2,r3
918 .global GLOBAL(sdivsi3)
1003 #endif /* ! __SH4__ */
1008 !! 4 byte integer Divide code for the Hitachi SH
1010 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1012 .global GLOBAL(udivsi3_i4)
1024 #ifdef __LITTLE_ENDIAN__
1048 .align 3 ! make double below 8 byte aligned.
1053 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
1054 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1056 .global GLOBAL(udivsi3_i4)
1070 #ifdef __LITTLE_ENDIAN__
1090 .align 3 ! make double below 8 byte aligned.
1105 #endif /* ! __SH4__ */
1109 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
1111 #if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__)
1113 !! Steve Chamberlain
1118 !! args in r4 and r5, result in r0, clobbers r4, pr, and t bit
1119 .global GLOBAL(udivsi3)
1125 ! get one bit from the msb of the numerator into the T
1126 ! bit and divide it by whats in r5. Put the answer bit
1127 ! into the T bit so it can come out again at the bottom
1129 rotcl r4 ; div1 r5,r0
1130 rotcl r4 ; div1 r5,r0
1131 rotcl r4 ; div1 r5,r0
1132 rotcl r4 ; div1 r5,r0
1133 rotcl r4 ; div1 r5,r0
1134 rotcl r4 ; div1 r5,r0
1135 rotcl r4 ; div1 r5,r0
1136 rotcl r4 ; div1 r5,r0
1138 rotcl r4 ; div1 r5,r0
1139 rotcl r4 ; div1 r5,r0
1140 rotcl r4 ; div1 r5,r0
1141 rotcl r4 ; div1 r5,r0
1142 rotcl r4 ; div1 r5,r0
1143 rotcl r4 ; div1 r5,r0
1144 rotcl r4 ; div1 r5,r0
1145 rotcl r4 ; div1 r5,r0
1147 rotcl r4 ; div1 r5,r0
1148 rotcl r4 ; div1 r5,r0
1149 rotcl r4 ; div1 r5,r0
1150 rotcl r4 ; div1 r5,r0
1151 rotcl r4 ; div1 r5,r0
1152 rotcl r4 ; div1 r5,r0
1153 rotcl r4 ; div1 r5,r0
1154 rotcl r4 ; div1 r5,r0
1157 rotcl r4 ; div1 r5,r0
1158 rotcl r4 ; div1 r5,r0
1159 rotcl r4 ; div1 r5,r0
1160 rotcl r4 ; div1 r5,r0
1161 rotcl r4 ; div1 r5,r0
1162 rotcl r4 ; div1 r5,r0
1163 rotcl r4 ; div1 r5,r0
1164 rotcl r4 ; div1 r5,r0
1169 #endif /* __SH4__ */
1172 #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
1173 .global GLOBAL(set_fpscr)
1176 mov.l LOCAL(set_fpscr_L1),r1
1182 #if defined(__SH4__)
1185 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1194 #if defined(__SH4__)
1198 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1204 LOCAL(set_fpscr_L1):
1205 .long GLOBAL(fpscr_values)
1207 .comm GLOBAL(fpscr_values),8,4
1209 .comm GLOBAL(fpscr_values),8
1211 #endif /* SH3E / SH4 */
1212 #endif /* L_set_fpscr */
1213 #ifdef L_ic_invalidate
1214 #if defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
1215 .global GLOBAL(ic_invalidate)
1216 GLOBAL(ic_invalidate):
1220 /* Compute how many cache lines 0f is away from r4. */
1223 /* Prepare to branch to 0f plus the cache-line offset. */
1230 /* This must be aligned to the beginning of a cache line. */
1232 .rept 256 /* There are 256 cache lines of 32 bytes. */
1239 #endif /* L_ic_invalidate */