1 /* Copyright (C) 2005 Free Software Foundation,
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
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 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 You should have received a copy of the GNU General Public License
25 along with GCC; see the file COPYING. If not, write to the Free
26 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
29 #define BITS_PER_UNIT 8
31 typedef int HItype
__attribute__ ((mode (HI
)));
32 typedef unsigned int UHItype
__attribute__ ((mode (HI
)));
34 typedef int SItype
__attribute__ ((mode (SI
)));
35 typedef unsigned int USItype
__attribute__ ((mode (SI
)));
37 typedef int word_type
__attribute__ ((mode (__word__
)));
39 struct SIstruct
{HItype low
, high
;};
48 __lshrsi3 (SItype u
, word_type b
)
59 bm
= (sizeof (HItype
) * BITS_PER_UNIT
) - b
;
63 w
.s
.low
= (UHItype
)uu
.s
.high
>> -bm
;
67 UHItype carries
= (UHItype
)uu
.s
.high
<< bm
;
68 w
.s
.high
= (UHItype
)uu
.s
.high
>> b
;
69 w
.s
.low
= ((UHItype
)uu
.s
.low
>> b
) | carries
;
76 __ashlsi3 (SItype u
, word_type b
)
87 bm
= (sizeof (HItype
) * BITS_PER_UNIT
) - b
;
91 w
.s
.high
= (UHItype
)uu
.s
.low
<< -bm
;
95 UHItype carries
= (UHItype
)uu
.s
.low
>> bm
;
96 w
.s
.low
= (UHItype
)uu
.s
.low
<< b
;
97 w
.s
.high
= ((UHItype
)uu
.s
.high
<< b
) | carries
;
104 __ashrsi3 (SItype u
, word_type b
)
115 bm
= (sizeof (HItype
) * BITS_PER_UNIT
) - b
;
118 /* w.s.high = 1..1 or 0..0 */
119 w
.s
.high
= uu
.s
.high
>> (sizeof (HItype
) * BITS_PER_UNIT
- 1);
120 w
.s
.low
= uu
.s
.high
>> -bm
;
124 UHItype carries
= (UHItype
)uu
.s
.high
<< bm
;
125 w
.s
.high
= uu
.s
.high
>> b
;
126 w
.s
.low
= ((UHItype
)uu
.s
.low
>> b
) | carries
;
133 __mulsi3 (USItype a
, USItype b
)
149 udivmodsi4(USItype num
, USItype den
, word_type modwanted
)
154 while (den
< num
&& bit
&& !(den
& (1L<<31)))
169 if (modwanted
) return num
;
174 __divsi3 (SItype a
, SItype b
)
191 res
= udivmodsi4 (a
, b
, 0);
200 __modsi3 (SItype a
, SItype b
)
214 res
= udivmodsi4 (a
, b
, 1);
223 __udivsi3 (SItype a
, SItype b
)
225 return udivmodsi4 (a
, b
, 0);
229 __umodsi3 (SItype a
, SItype b
)
231 return udivmodsi4 (a
, b
, 1);