1 /* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3 Free Software Foundation, Inc.
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
19 This file is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; see the file COPYING. If not, write to
26 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA. */
29 !! libgcc routines for the Renesas / SuperH SH CPUs.
30 !! Contributed by Steve Chamberlain.
33 !! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
34 !! recoded in assembly by Toshiyasu Morita
37 /* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
38 ELF local label prefixes by J"orn Rennecke
41 /* This code used shld, thus is not suitable for SH1 / SH2. */
43 /* Signed / unsigned division without use of FPU, optimized for SH4.
44 Uses a lookup table for divisors in the range -128 .. +128, and
45 div1 with case distinction for larger divisors in three more ranges.
46 The code is lumped together with the table to allow the use of mova. */
47 #ifdef CONFIG_CPU_LITTLE_ENDIAN
60 .set __udivsi3, __udivsi3_i4i
61 .type __udivsi3_i4i, @function
142 mov.b r0,@(L_LSWMSB,r15)
176 .global __sdivsi3_i4i
178 .set __sdivsi3, __sdivsi3_i4i
179 .type __sdivsi3_i4i, @function
180 /* This is link-compatible with a __sdivsi3 call,
181 but we effectively clobber only r1. */
214 mov.b r0,@(L_MSWLSB,r15)
220 mov.b r0,@(L_LSWMSB,r15)
225 mov.l @r15+,r4 ! zero-extension and swap using LS unit.
237 mova div_table_inv,r0
240 mova div_table_clz,r0
274 mov.b r0,@(L_MSWLSB,r15)
280 mov.b r0,@(L_LSWMSB,r15)
285 mov.l @r15+,r4 ! zero-extension and swap using LS unit.
307 mov.b r0,@(L_LSWMSB,r15)
310 bra div_ge64k_neg_end
332 /* This table has been generated by divtab-sh4.c. */
463 /* Lookup table translating positive divisor to index into table of
464 normalized inverse. N.B. the '0' entry is also the last entry of the
465 previous table, and causes an unaligned access for division by zero. */
596 /* 1/64 .. 1/127, normalized. There is an implicit leading 1 in bit 32. */
664 /* maximum error: 0.987342 scaled: 0.921875*/