1 /* Copyright
(C
) 1994, 1995, 1997, 1998 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 with other programs
, and to distribute
11 those programs without any restriction coming from the use of
this
12 file.
(The General
Public License restrictions do apply
in other
13 respects
; for example, they cover modification of the file, and
14 distribution when
not linked
into another program.
)
16 This file is distributed
in the hope that it will be useful
, but
17 WITHOUT ANY WARRANTY
; without even the implied warranty of
18 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General
Public License for more details.
21 You should have received a copy of the GNU General
Public License
22 along with
this program
; see the file COPYING. If not, write to
23 the Free Software Foundation
, 59 Temple Place
- Suite
330,
24 Boston
, MA
02111-1307, USA.
*/
26 /* As a special exception
, if you link
this library with other files
,
27 some of which are compiled with GCC
, to produce an executable
,
28 this library does
not by itself cause the resulting executable
29 to be covered by the GNU General
Public License.
30 This exception does
not however invalidate any other reasons why
31 the executable file might be covered by the GNU General
Public License.
*/
34 !! libgcc1 routines for the Hitachi SH cpu.
35 !! Contributed by Steve Chamberlain.
38 !! ashiftrt_r4_x
, ___ashrsi3
, ___ashlsi3
, ___lshrsi3 routines
39 !! recoded
in assembly by Toshiyasu Morita
42 /* SH2 optimizations for ___ashrsi3
, ___ashlsi3
, ___lshrsi3
and
43 ELF
local label prefixes by J
"orn Rennecke
47 #define LOCAL(X) .L_##X
49 #define LOCAL(X) L_##X
53 .global ___ashiftrt_r4_0
54 .global ___ashiftrt_r4_1
55 .global ___ashiftrt_r4_2
56 .global ___ashiftrt_r4_3
57 .global ___ashiftrt_r4_4
58 .global ___ashiftrt_r4_5
59 .global ___ashiftrt_r4_6
60 .global ___ashiftrt_r4_7
61 .global ___ashiftrt_r4_8
62 .global ___ashiftrt_r4_9
63 .global ___ashiftrt_r4_10
64 .global ___ashiftrt_r4_11
65 .global ___ashiftrt_r4_12
66 .global ___ashiftrt_r4_13
67 .global ___ashiftrt_r4_14
68 .global ___ashiftrt_r4_15
69 .global ___ashiftrt_r4_16
70 .global ___ashiftrt_r4_17
71 .global ___ashiftrt_r4_18
72 .global ___ashiftrt_r4_19
73 .global ___ashiftrt_r4_20
74 .global ___ashiftrt_r4_21
75 .global ___ashiftrt_r4_22
76 .global ___ashiftrt_r4_23
77 .global ___ashiftrt_r4_24
78 .global ___ashiftrt_r4_25
79 .global ___ashiftrt_r4_26
80 .global ___ashiftrt_r4_27
81 .global ___ashiftrt_r4_28
82 .global ___ashiftrt_r4_29
83 .global ___ashiftrt_r4_30
84 .global ___ashiftrt_r4_31
85 .global ___ashiftrt_r4_32
192 mova LOCAL(ashrsi3_table),r0
203 LOCAL(ashrsi3_table):
204 .byte LOCAL(ashrsi3_0)-LOCAL(ashrsi3_table)
205 .byte LOCAL(ashrsi3_1)-LOCAL(ashrsi3_table)
206 .byte LOCAL(ashrsi3_2)-LOCAL(ashrsi3_table)
207 .byte LOCAL(ashrsi3_3)-LOCAL(ashrsi3_table)
208 .byte LOCAL(ashrsi3_4)-LOCAL(ashrsi3_table)
209 .byte LOCAL(ashrsi3_5)-LOCAL(ashrsi3_table)
210 .byte LOCAL(ashrsi3_6)-LOCAL(ashrsi3_table)
211 .byte LOCAL(ashrsi3_7)-LOCAL(ashrsi3_table)
212 .byte LOCAL(ashrsi3_8)-LOCAL(ashrsi3_table)
213 .byte LOCAL(ashrsi3_9)-LOCAL(ashrsi3_table)
214 .byte LOCAL(ashrsi3_10)-LOCAL(ashrsi3_table)
215 .byte LOCAL(ashrsi3_11)-LOCAL(ashrsi3_table)
216 .byte LOCAL(ashrsi3_12)-LOCAL(ashrsi3_table)
217 .byte LOCAL(ashrsi3_13)-LOCAL(ashrsi3_table)
218 .byte LOCAL(ashrsi3_14)-LOCAL(ashrsi3_table)
219 .byte LOCAL(ashrsi3_15)-LOCAL(ashrsi3_table)
220 .byte LOCAL(ashrsi3_16)-LOCAL(ashrsi3_table)
221 .byte LOCAL(ashrsi3_17)-LOCAL(ashrsi3_table)
222 .byte LOCAL(ashrsi3_18)-LOCAL(ashrsi3_table)
223 .byte LOCAL(ashrsi3_19)-LOCAL(ashrsi3_table)
224 .byte LOCAL(ashrsi3_20)-LOCAL(ashrsi3_table)
225 .byte LOCAL(ashrsi3_21)-LOCAL(ashrsi3_table)
226 .byte LOCAL(ashrsi3_22)-LOCAL(ashrsi3_table)
227 .byte LOCAL(ashrsi3_23)-LOCAL(ashrsi3_table)
228 .byte LOCAL(ashrsi3_24)-LOCAL(ashrsi3_table)
229 .byte LOCAL(ashrsi3_25)-LOCAL(ashrsi3_table)
230 .byte LOCAL(ashrsi3_26)-LOCAL(ashrsi3_table)
231 .byte LOCAL(ashrsi3_27)-LOCAL(ashrsi3_table)
232 .byte LOCAL(ashrsi3_28)-LOCAL(ashrsi3_table)
233 .byte LOCAL(ashrsi3_29)-LOCAL(ashrsi3_table)
234 .byte LOCAL(ashrsi3_30)-LOCAL(ashrsi3_table)
235 .byte LOCAL(ashrsi3_31)-LOCAL(ashrsi3_table)
340 mova LOCAL(ashlsi3_table),r0
351 LOCAL(ashlsi3_table):
352 .byte LOCAL(ashlsi3_0)-LOCAL(ashlsi3_table)
353 .byte LOCAL(ashlsi3_1)-LOCAL(ashlsi3_table)
354 .byte LOCAL(ashlsi3_2)-LOCAL(ashlsi3_table)
355 .byte LOCAL(ashlsi3_3)-LOCAL(ashlsi3_table)
356 .byte LOCAL(ashlsi3_4)-LOCAL(ashlsi3_table)
357 .byte LOCAL(ashlsi3_5)-LOCAL(ashlsi3_table)
358 .byte LOCAL(ashlsi3_6)-LOCAL(ashlsi3_table)
359 .byte LOCAL(ashlsi3_7)-LOCAL(ashlsi3_table)
360 .byte LOCAL(ashlsi3_8)-LOCAL(ashlsi3_table)
361 .byte LOCAL(ashlsi3_9)-LOCAL(ashlsi3_table)
362 .byte LOCAL(ashlsi3_10)-LOCAL(ashlsi3_table)
363 .byte LOCAL(ashlsi3_11)-LOCAL(ashlsi3_table)
364 .byte LOCAL(ashlsi3_12)-LOCAL(ashlsi3_table)
365 .byte LOCAL(ashlsi3_13)-LOCAL(ashlsi3_table)
366 .byte LOCAL(ashlsi3_14)-LOCAL(ashlsi3_table)
367 .byte LOCAL(ashlsi3_15)-LOCAL(ashlsi3_table)
368 .byte LOCAL(ashlsi3_16)-LOCAL(ashlsi3_table)
369 .byte LOCAL(ashlsi3_17)-LOCAL(ashlsi3_table)
370 .byte LOCAL(ashlsi3_18)-LOCAL(ashlsi3_table)
371 .byte LOCAL(ashlsi3_19)-LOCAL(ashlsi3_table)
372 .byte LOCAL(ashlsi3_20)-LOCAL(ashlsi3_table)
373 .byte LOCAL(ashlsi3_21)-LOCAL(ashlsi3_table)
374 .byte LOCAL(ashlsi3_22)-LOCAL(ashlsi3_table)
375 .byte LOCAL(ashlsi3_23)-LOCAL(ashlsi3_table)
376 .byte LOCAL(ashlsi3_24)-LOCAL(ashlsi3_table)
377 .byte LOCAL(ashlsi3_25)-LOCAL(ashlsi3_table)
378 .byte LOCAL(ashlsi3_26)-LOCAL(ashlsi3_table)
379 .byte LOCAL(ashlsi3_27)-LOCAL(ashlsi3_table)
380 .byte LOCAL(ashlsi3_28)-LOCAL(ashlsi3_table)
381 .byte LOCAL(ashlsi3_29)-LOCAL(ashlsi3_table)
382 .byte LOCAL(ashlsi3_30)-LOCAL(ashlsi3_table)
383 .byte LOCAL(ashlsi3_31)-LOCAL(ashlsi3_table)
497 mova LOCAL(lshrsi3_table),r0
508 LOCAL(lshrsi3_table):
509 .byte LOCAL(lshrsi3_0)-LOCAL(lshrsi3_table)
510 .byte LOCAL(lshrsi3_1)-LOCAL(lshrsi3_table)
511 .byte LOCAL(lshrsi3_2)-LOCAL(lshrsi3_table)
512 .byte LOCAL(lshrsi3_3)-LOCAL(lshrsi3_table)
513 .byte LOCAL(lshrsi3_4)-LOCAL(lshrsi3_table)
514 .byte LOCAL(lshrsi3_5)-LOCAL(lshrsi3_table)
515 .byte LOCAL(lshrsi3_6)-LOCAL(lshrsi3_table)
516 .byte LOCAL(lshrsi3_7)-LOCAL(lshrsi3_table)
517 .byte LOCAL(lshrsi3_8)-LOCAL(lshrsi3_table)
518 .byte LOCAL(lshrsi3_9)-LOCAL(lshrsi3_table)
519 .byte LOCAL(lshrsi3_10)-LOCAL(lshrsi3_table)
520 .byte LOCAL(lshrsi3_11)-LOCAL(lshrsi3_table)
521 .byte LOCAL(lshrsi3_12)-LOCAL(lshrsi3_table)
522 .byte LOCAL(lshrsi3_13)-LOCAL(lshrsi3_table)
523 .byte LOCAL(lshrsi3_14)-LOCAL(lshrsi3_table)
524 .byte LOCAL(lshrsi3_15)-LOCAL(lshrsi3_table)
525 .byte LOCAL(lshrsi3_16)-LOCAL(lshrsi3_table)
526 .byte LOCAL(lshrsi3_17)-LOCAL(lshrsi3_table)
527 .byte LOCAL(lshrsi3_18)-LOCAL(lshrsi3_table)
528 .byte LOCAL(lshrsi3_19)-LOCAL(lshrsi3_table)
529 .byte LOCAL(lshrsi3_20)-LOCAL(lshrsi3_table)
530 .byte LOCAL(lshrsi3_21)-LOCAL(lshrsi3_table)
531 .byte LOCAL(lshrsi3_22)-LOCAL(lshrsi3_table)
532 .byte LOCAL(lshrsi3_23)-LOCAL(lshrsi3_table)
533 .byte LOCAL(lshrsi3_24)-LOCAL(lshrsi3_table)
534 .byte LOCAL(lshrsi3_25)-LOCAL(lshrsi3_table)
535 .byte LOCAL(lshrsi3_26)-LOCAL(lshrsi3_table)
536 .byte LOCAL(lshrsi3_27)-LOCAL(lshrsi3_table)
537 .byte LOCAL(lshrsi3_28)-LOCAL(lshrsi3_table)
538 .byte LOCAL(lshrsi3_29)-LOCAL(lshrsi3_table)
539 .byte LOCAL(lshrsi3_30)-LOCAL(lshrsi3_table)
540 .byte LOCAL(lshrsi3_31)-LOCAL(lshrsi3_table)
633 ! done all the large groups, do the remainder
644 .global ___movstrSI64
648 .global ___movstrSI60
652 .global ___movstrSI56
656 .global ___movstrSI52
660 .global ___movstrSI48
664 .global ___movstrSI44
668 .global ___movstrSI40
672 .global ___movstrSI36
676 .global ___movstrSI32
680 .global ___movstrSI28
684 .global ___movstrSI24
688 .global ___movstrSI20
692 .global ___movstrSI16
696 .global ___movstrSI12
774 #if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
776 .global ___movstr_i4_even
777 .global ___movstr_i4_odd
778 .global ___movstrSI12_i4
800 bt/s L_movstr_2mod4_end
816 bra L_movstr_start_even
828 #endif /* ! __SH4__ */
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 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 r2,r5 ! brewing macl = aa*dd
860 mulu 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 ___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 ___sdivsi3_i4
903 #endif /* ! __SH4__ */
907 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
909 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
916 !! args in r4 and r5, result in r0 clobber r1,r2,r3
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 ___udivsi3_i4
1024 #ifdef __LITTLE_ENDIAN__
1050 #elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
1051 !! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
1053 .global ___udivsi3_i4
1067 #ifdef __LITTLE_ENDIAN__
1092 #if defined (__LITTLE_ENDIAN__) || ! defined (FMOVD_WORKS)
1099 #endif /* ! __SH4__ */
1103 /* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
1105 #if ! defined(__SH4__) && ! defined (__SH4_SINGLE__)
1107 !! Steve Chamberlain
1112 !! args in r4 and r5, result in r0, clobbers r4, pr, and t bit
1119 ! get one bit from the msb of the numerator into the T
1120 ! bit and divide it by whats in r5. Put the answer bit
1121 ! into the T bit so it can come out again at the bottom
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
1130 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
1139 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
1148 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
1158 rotcl r4 ; div1 r5,r0
1163 #endif /* __SH4__ */
1166 #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
1167 .global ___set_fpscr
1170 mov.l ___set_fpscr_L1,r1
1176 #if defined(__SH4__)
1179 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1188 #if defined(__SH4__)
1192 #else /* defined(__SH3E__) || defined(__SH4_SINGLE*__) */
1199 .long ___fpscr_values
1201 .comm ___fpscr_values,8,4
1203 .comm ___fpscr_values,8
1205 #endif /* SH3E / SH4 */
1206 #endif /* L_set_fpscr */