Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / gnu / usr.bin / cc / libgcc / _udiv_w_sdiv.c
CommitLineData
9bf86ebb
PR
1extern int target_flags;
2
3enum reg_class
4{
5 NO_REGS,
6 AREG, DREG, CREG, BREG,
7 Q_REGS,
8 SIREG, DIREG,
9 INDEX_REGS,
10 GENERAL_REGS,
11 FP_TOP_REG, FP_SECOND_REG,
12 FLOAT_REGS,
13 ALL_REGS, LIM_REG_CLASSES
14};
15extern enum reg_class regclass_map[17 ];
16
17
18extern struct rtx_def *i386_compare_op0, *i386_compare_op1;
19extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)();
20extern char *hi_reg_name[];
21extern char *qi_reg_name[];
22extern char *qi_high_reg_name[];
23
24enum machine_mode {
25 VOIDmode ,
26 QImode ,
27 HImode ,
28 PSImode ,
29 SImode ,
30 PDImode ,
31 DImode ,
32 TImode ,
33 OImode ,
34 QFmode ,
35 HFmode ,
36 SFmode ,
37 DFmode ,
38 XFmode ,
39 TFmode ,
40 SCmode ,
41 DCmode ,
42 XCmode ,
43 TCmode ,
44 CQImode ,
45 CHImode ,
46 CSImode ,
47 CDImode ,
48 CTImode ,
49 COImode ,
50 BLKmode ,
51 CCmode ,
52 CCFPEQmode ,
53MAX_MACHINE_MODE };
54extern char *mode_name[];
55enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC,
56 MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS};
57extern enum mode_class mode_class[];
58extern int mode_size[];
59extern int mode_unit_size[];
60extern enum machine_mode mode_wider_mode[];
61extern enum machine_mode mode_for_size (unsigned int, enum mode_class, int) ;
62extern enum machine_mode get_best_mode (int, int, int, enum machine_mode, int) ;
63extern enum machine_mode class_narrowest_mode[];
64extern enum machine_mode byte_mode;
65extern enum machine_mode word_mode;
66typedef int ptrdiff_t;
67typedef unsigned int size_t;
68typedef short unsigned int wchar_t;
69typedef unsigned int UQItype __attribute__ ((mode (QI)));
70typedef int SItype __attribute__ ((mode (SI)));
71typedef unsigned int USItype __attribute__ ((mode (SI)));
72typedef int DItype __attribute__ ((mode (DI)));
73typedef unsigned int UDItype __attribute__ ((mode (DI)));
74typedef float SFtype __attribute__ ((mode (SF)));
75typedef float DFtype __attribute__ ((mode (DF)));
76typedef int word_type __attribute__ ((mode (SI)));
77 struct DIstruct {SItype low, high;};
78typedef union
79{
80 struct DIstruct s;
81 DItype ll;
82} DIunion;
83extern DItype __fixunssfdi (SFtype a);
84extern DItype __fixunsdfdi (DFtype a);
85USItype
86__udiv_w_sdiv (rp, a1, a0, d)
87 USItype *rp, a1, a0, d;
88{
89 USItype q, r;
90 USItype c0, c1, b1;
91 if ((SItype) d >= 0)
92 {
93 if (a1 < d - a1 - (a0 >> ((sizeof (SItype) * 8 ) - 1)))
94 {
95
96 sdiv_qrnnd (q, r, a1, a0, d);
97 }
98 else
99 {
100
101 __asm__ ("subl %5,%1
102 sbbl %3,%0" : "=r" ((USItype)( c1 )), "=&r" ((USItype)( c0 )) : "0" ((USItype)( a1 )), "g" ((USItype)( d >> 1 )), "1" ((USItype)( a0 )), "g" ((USItype)( d << ((sizeof (SItype) * 8 ) - 1) ))) ;
103
104 sdiv_qrnnd (q, r, c1, c0, d);
105
106 q += (USItype) 1 << ((sizeof (SItype) * 8 ) - 1);
107 }
108 }
109 else
110 {
111 b1 = d >> 1;
112 c1 = a1 >> 1;
113 c0 = (a1 << ((sizeof (SItype) * 8 ) - 1)) + (a0 >> 1);
114 if (a1 < b1)
115 {
116 sdiv_qrnnd (q, r, c1, c0, b1);
117 r = 2*r + (a0 & 1);
118 if ((d & 1) != 0)
119 {
120 if (r >= q)
121 r = r - q;
122 else if (q - r <= d)
123 {
124 r = r - q + d;
125 q--;
126 }
127 else
128 {
129 r = r - q + 2*d;
130 q -= 2;
131 }
132 }
133 }
134 else if (c1 < b1)
135 {
136 c1 = (b1 - 1) - c1;
137 c0 = ~c0;
138 sdiv_qrnnd (q, r, c1, c0, b1);
139 q = ~q;
140 r = (b1 - 1) - r;
141 r = 2*r + (a0 & 1);
142 if ((d & 1) != 0)
143 {
144 if (r >= q)
145 r = r - q;
146 else if (q - r <= d)
147 {
148 r = r - q + d;
149 q--;
150 }
151 else
152 {
153 r = r - q + 2*d;
154 q -= 2;
155 }
156 }
157 }
158 else
159 {
160 if (a0 >= -d)
161 {
162 q = -1;
163 r = a0 + d;
164 }
165 else
166 {
167 q = -2;
168 r = a0 + 2*d;
169 }
170 }
171 }
172 *rp = r;
173 return q;
174}