1 /* Copyright (C) 1994, 95, 97, 98, 1999, 2000 Free Software Foundation, Inc.
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
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
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.
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 the Free Software Foundation, 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. */
27 !! libgcc1 routines for the Hitachi SH cpu.
28 !! Contributed by Steve Chamberlain.
31 !! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
32 !! recoded in assembly by Toshiyasu Morita
35 /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
36 ELF local label prefixes by J"orn Rennecke
40 #define LOCAL(X) .L_##X
42 #define LOCAL(X) L_##X
46 .global ___ashiftrt_r4_0
47 .global ___ashiftrt_r4_1
48 .global ___ashiftrt_r4_2
49 .global ___ashiftrt_r4_3
50 .global ___ashiftrt_r4_4
51 .global ___ashiftrt_r4_5
52 .global ___ashiftrt_r4_6
53 .global ___ashiftrt_r4_7
54 .global ___ashiftrt_r4_8
55 .global ___ashiftrt_r4_9
56 .global ___ashiftrt_r4_10
57 .global ___ashiftrt_r4_11
58 .global ___ashiftrt_r4_12
59 .global ___ashiftrt_r4_13
60 .global ___ashiftrt_r4_14
61 .global ___ashiftrt_r4_15
62 .global ___ashiftrt_r4_16
63 .global ___ashiftrt_r4_17
64 .global ___ashiftrt_r4_18
65 .global ___ashiftrt_r4_19
66 .global ___ashiftrt_r4_20
67 .global ___ashiftrt_r4_21
68 .global ___ashiftrt_r4_22
69 .global ___ashiftrt_r4_23
70 .global ___ashiftrt_r4_24
71 .global ___ashiftrt_r4_25
72 .global ___ashiftrt_r4_26
73 .global ___ashiftrt_r4_27
74 .global ___ashiftrt_r4_28
75 .global ___ashiftrt_r4_29
76 .global ___ashiftrt_r4_30
77 .global ___ashiftrt_r4_31
78 .global ___ashiftrt_r4_32
185 mova LOCAL(ashrsi3_table),r0
196 LOCAL(ashrsi3_table):
197 .byte LOCAL(ashrsi3_0)-LOCAL(ashrsi3_table)
198 .byte LOCAL(ashrsi3_1)-LOCAL(ashrsi3_table)
199 .byte LOCAL(ashrsi3_2)-LOCAL(ashrsi3_table)
200 .byte LOCAL(ashrsi3_3)-LOCAL(ashrsi3_table)
201 .byte LOCAL(ashrsi3_4)-LOCAL(ashrsi3_table)
202 .byte LOCAL(ashrsi3_5)-LOCAL(ashrsi3_table)
203 .byte LOCAL(ashrsi3_6)-LOCAL(ashrsi3_table)
204 .byte LOCAL(ashrsi3_7)-LOCAL(ashrsi3_table)
205 .byte LOCAL(ashrsi3_8)-LOCAL(ashrsi3_table)
206 .byte LOCAL(ashrsi3_9)-LOCAL(ashrsi3_table)
207 .byte LOCAL(ashrsi3_10)-LOCAL(ashrsi3_table)
208 .byte LOCAL(ashrsi3_11)-LOCAL(ashrsi3_table)
209 .byte LOCAL(ashrsi3_12)-LOCAL(ashrsi3_table)
210 .byte LOCAL(ashrsi3_13)-LOCAL(ashrsi3_table)
211 .byte LOCAL(ashrsi3_14)-LOCAL(ashrsi3_table)
212 .byte LOCAL(ashrsi3_15)-LOCAL(ashrsi3_table)
213 .byte LOCAL(ashrsi3_16)-LOCAL(ashrsi3_table)
214 .byte LOCAL(ashrsi3_17)-LOCAL(ashrsi3_table)
215 .byte LOCAL(ashrsi3_18)-LOCAL(ashrsi3_table)
216 .byte LOCAL(ashrsi3_19)-LOCAL(ashrsi3_table)
217 .byte LOCAL(ashrsi3_20)-LOCAL(ashrsi3_table)
218 .byte LOCAL(ashrsi3_21)-LOCAL(ashrsi3_table)
219 .byte LOCAL(ashrsi3_22)-LOCAL(ashrsi3_table)
220 .byte LOCAL(ashrsi3_23)-LOCAL(ashrsi3_table)
221 .byte LOCAL(ashrsi3_24)-LOCAL(ashrsi3_table)
222 .byte LOCAL(ashrsi3_25)-LOCAL(ashrsi3_table)
223 .byte LOCAL(ashrsi3_26)-LOCAL(ashrsi3_table)
224 .byte LOCAL(ashrsi3_27)-LOCAL(ashrsi3_table)
225 .byte LOCAL(ashrsi3_28)-LOCAL(ashrsi3_table)
226 .byte LOCAL(ashrsi3_29)-LOCAL(ashrsi3_table)
227 .byte LOCAL(ashrsi3_30)-LOCAL(ashrsi3_table)
228 .byte LOCAL(ashrsi3_31)-LOCAL(ashrsi3_table)
333 mova LOCAL(ashlsi3_table),r0
344 LOCAL(ashlsi3_table):
345 .byte LOCAL(ashlsi3_0)-LOCAL(ashlsi3_table)
346 .byte LOCAL(ashlsi3_1)-LOCAL(ashlsi3_table)
347 .byte LOCAL(ashlsi3_2)-LOCAL(ashlsi3_table)
348 .byte LOCAL(ashlsi3_3)-LOCAL(ashlsi3_table)
349 .byte LOCAL(ashlsi3_4)-LOCAL(ashlsi3_table)
350 .byte LOCAL(ashlsi3_5)-LOCAL(ashlsi3_table)
351 .byte LOCAL(ashlsi3_6)-LOCAL(ashlsi3_table)
352 .byte LOCAL(ashlsi3_7)-LOCAL(ashlsi3_table)
353 .byte LOCAL(ashlsi3_8)-LOCAL(ashlsi3_table)
354 .byte LOCAL(ashlsi3_9)-LOCAL(ashlsi3_table)
355 .byte LOCAL(ashlsi3_10)-LOCAL(ashlsi3_table)
356 .byte LOCAL(ashlsi3_11)-LOCAL(ashlsi3_table)
357 .byte LOCAL(ashlsi3_12)-LOCAL(ashlsi3_table)
358 .byte LOCAL(ashlsi3_13)-LOCAL(ashlsi3_table)
359 .byte LOCAL(ashlsi3_14)-LOCAL(ashlsi3_table)
360 .byte LOCAL(ashlsi3_15)-LOCAL(ashlsi3_table)
361 .byte LOCAL(ashlsi3_16)-LOCAL(ashlsi3_table)
362 .byte LOCAL(ashlsi3_17)-LOCAL(ashlsi3_table)
363 .byte LOCAL(ashlsi3_18)-LOCAL(ashlsi3_table)
364 .byte LOCAL(ashlsi3_19)-LOCAL(ashlsi3_table)
365 .byte LOCAL(ashlsi3_20)-LOCAL(ashlsi3_table)
366 .byte LOCAL(ashlsi3_21)-LOCAL(ashlsi3_table)
367 .byte LOCAL(ashlsi3_22)-LOCAL(ashlsi3_table)
368 .byte LOCAL(ashlsi3_23)-LOCAL(ashlsi3_table)
369 .byte LOCAL(ashlsi3_24)-LOCAL(ashlsi3_table)
370 .byte LOCAL(ashlsi3_25)-LOCAL(ashlsi3_table)
371 .byte LOCAL(ashlsi3_26)-LOCAL(ashlsi3_table)
372 .byte LOCAL(ashlsi3_27)-LOCAL(ashlsi3_table)
373 .byte LOCAL(ashlsi3_28)-LOCAL(ashlsi3_table)
374 .byte LOCAL(ashlsi3_29)-LOCAL(ashlsi3_table)
375 .byte LOCAL(ashlsi3_30)-LOCAL(ashlsi3_table)
376 .byte LOCAL(ashlsi3_31)-LOCAL(ashlsi3_table)
490 mova LOCAL(lshrsi3_table),r0
501 LOCAL(lshrsi3_table):
502 .byte LOCAL(lshrsi3_0)-LOCAL(lshrsi3_table)
503 .byte LOCAL(lshrsi3_1)-LOCAL(lshrsi3_table)
504 .byte LOCAL(lshrsi3_2)-LOCAL(lshrsi3_table)
505 .byte LOCAL(lshrsi3_3)-LOCAL(lshrsi3_table)
506 .byte LOCAL(lshrsi3_4)-LOCAL(lshrsi3_table)
507 .byte LOCAL(lshrsi3_5)-LOCAL(lshrsi3_table)
508 .byte LOCAL(lshrsi3_6)-LOCAL(lshrsi3_table)
509 .byte LOCAL(lshrsi3_7)-LOCAL(lshrsi3_table)
510 .byte LOCAL(lshrsi3_8)-LOCAL(lshrsi3_table)
511 .byte LOCAL(lshrsi3_9)-LOCAL(lshrsi3_table)
512 .byte LOCAL(lshrsi3_10)-LOCAL(lshrsi3_table)
513 .byte LOCAL(lshrsi3_11)-LOCAL(lshrsi3_table)
514 .byte LOCAL(lshrsi3_12)-LOCAL(lshrsi3_table)
515 .byte LOCAL(lshrsi3_13)-LOCAL(lshrsi3_table)
516 .byte LOCAL(lshrsi3_14)-LOCAL(lshrsi3_table)
517 .byte LOCAL(lshrsi3_15)-LOCAL(lshrsi3_table)
518 .byte LOCAL(lshrsi3_16)-LOCAL(lshrsi3_table)
519 .byte LOCAL(lshrsi3_17)-LOCAL(lshrsi3_table)
520 .byte LOCAL(lshrsi3_18)-LOCAL(lshrsi3_table)
521 .byte LOCAL(lshrsi3_19)-LOCAL(lshrsi3_table)
522 .byte LOCAL(lshrsi3_20)-LOCAL(lshrsi3_table)
523 .byte LOCAL(lshrsi3_21)-LOCAL(lshrsi3_table)
524 .byte LOCAL(lshrsi3_22)-LOCAL(lshrsi3_table)
525 .byte LOCAL(lshrsi3_23)-LOCAL(lshrsi3_table)
526 .byte LOCAL(lshrsi3_24)-LOCAL(lshrsi3_table)
527 .byte LOCAL(lshrsi3_25)-LOCAL(lshrsi3_table)
528 .byte LOCAL(lshrsi3_26)-LOCAL(lshrsi3_table)
529 .byte LOCAL(lshrsi3_27)-LOCAL(lshrsi3_table)
530 .byte LOCAL(lshrsi3_28)-LOCAL(lshrsi3_table)
531 .byte LOCAL(lshrsi3_29)-LOCAL(lshrsi3_table)
532 .byte LOCAL(lshrsi3_30)-LOCAL(lshrsi3_table)
533 .byte LOCAL(lshrsi3_31)-LOCAL(lshrsi3_table)
626 ! done all the large groups, do the remainder
637 .global ___movstrSI64
641 .global ___movstrSI60
645 .global ___movstrSI56
649 .global ___movstrSI52
653 .global ___movstrSI48
657 .global ___movstrSI44
661 .global ___movstrSI40
665 .global ___movstrSI36
669 .global ___movstrSI32
673 .global ___movstrSI28
677 .global ___movstrSI24
681 .global ___movstrSI20
685 .global ___movstrSI16
689 .global ___movstrSI12
767 #if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
769 .global ___movstr_i4_even
770 .global ___movstr_i4_odd
771 .global ___movstrSI12_i4
793 bt/s L_movstr_2mod4_end
809 bra L_movstr_start_even
821 #endif /* ! __SH4__ */
831 ! r0 = aabb*ccdd via partial products
833 ! if aa == 0 and cc = 0
837 ! aa = bb*dd + (aa*dd*65536) + (cc*bb*65536)
841 mulu r4,r5 ! multiply the lsws macl=bb*dd
842 mov r5,r3 ! r3 = ccdd
843 swap.w r4,r2 ! r2 = bbaa
844 xtrct r2,r3 ! r3 = aacc
845 tst r3,r3 ! msws zero ?
847 rts ! yes - then we have the answer
850 hiset: sts macl,r0 ! r0 = bb*dd
851 mulu r2,r5 ! brewing macl = aa*dd
853 mulu r3,r4 ! brewing macl = cc*bb
864 !! 4 byte integer Divide code for the Hitachi SH
866 !! args in r4 and r5, result in fpul, clobber dr0, dr2
868 .global ___sdivsi3_i4
878 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
879 !! args in r4 and r5, result in fpul, clobber r2, dr0, dr2
881 .global ___sdivsi3_i4
896 #endif /* ! __SH4__ */
900 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
902 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
909 !! args in r4 and r5, result in r0 clobber r1,r2,r3
996 #endif /* ! __SH4__ */
1001 !! 4 byte integer Divide code for the Hitachi SH
1003 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1005 .global ___udivsi3_i4
1017 #ifdef __LITTLE_ENDIAN__
1041 .align 3 ! make double below 8 byte aligned.
1046 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
1047 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1049 .global ___udivsi3_i4
1063 #ifdef __LITTLE_ENDIAN__
1083 .align 3 ! make double below 8 byte aligned.
1098 #endif /* ! __SH4__ */
1102 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
1104 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
1106 !! Steve Chamberlain
1111 !! args in r4 and r5, result in r0, clobbers r4, pr, and t bit
1118 ! get one bit from the msb of the numerator into the T
1119 ! bit and divide it by whats in r5. Put the answer bit
1120 ! into the T bit so it can come out again at the bottom
1122 rotcl r4 ; div1 r5,r0
1123 rotcl r4 ; div1 r5,r0
1124 rotcl r4 ; div1 r5,r0
1125 rotcl r4 ; div1 r5,r0
1126 rotcl r4 ; div1 r5,r0
1127 rotcl r4 ; div1 r5,r0
1128 rotcl r4 ; div1 r5,r0
1129 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
1137 rotcl r4 ; div1 r5,r0
1138 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
1146 rotcl r4 ; div1 r5,r0
1147 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
1155 rotcl r4 ; div1 r5,r0
1156 rotcl r4 ; div1 r5,r0
1157 rotcl r4 ; div1 r5,r0
1162 #endif /* __SH4__ */
1165 #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
1166 .global ___set_fpscr
1169 mov.l ___set_fpscr_L1,r1
1175 #if defined(__SH4__)
1178 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1187 #if defined(__SH4__)
1191 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1198 .long ___fpscr_values
1200 .comm ___fpscr_values,8,4
1202 .comm ___fpscr_values,8
1204 #endif /* SH3E / SH4 */
1205 #endif /* L_set_fpscr */