]> gcc.gnu.org Git - gcc.git/blame - gcc/longlong.h
reload1.c (struct elim_table): Delete MAX_OFFSET member.
[gcc.git] / gcc / longlong.h
CommitLineData
e1a79915 1/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
39a96e84 2 Copyright (C) 1991, 92, 94, 95, 96, 1997 Free Software Foundation, Inc.
e1a79915
RS
3
4 This definition file is free software; you can redistribute it
5 and/or modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2, or (at your option) any later version.
8
9 This definition file is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied
11 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
a35311b0
RK
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
e1a79915 18
cf7d8fd0
TG
19#ifndef SI_TYPE_SIZE
20#define SI_TYPE_SIZE 32
e1a79915
RS
21#endif
22
cf7d8fd0
TG
23#define __BITS4 (SI_TYPE_SIZE / 4)
24#define __ll_B (1L << (SI_TYPE_SIZE / 2))
e6c5404d
TG
25#define __ll_lowpart(t) ((USItype) (t) % __ll_B)
26#define __ll_highpart(t) ((USItype) (t) / __ll_B)
e1a79915 27
2e8a6600 28/* Define auxiliary asm macros.
e1a79915
RS
29
30 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand)
e6c5404d
TG
31 multiplies two USItype integers MULTIPLER and MULTIPLICAND,
32 and generates a two-part USItype product in HIGH_PROD and
e1a79915
RS
33 LOW_PROD.
34
e6c5404d
TG
35 2) __umulsidi3(a,b) multiplies two USItype integers A and B,
36 and returns a UDItype product. This is just a variant of umul_ppmm.
e1a79915
RS
37
38 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
39 denominator) divides a two-word unsigned integer, composed by the
40 integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and
41 places the quotient in QUOTIENT and the remainder in REMAINDER.
42 HIGH_NUMERATOR must be less than DENOMINATOR for correct operation.
43 If, in addition, the most significant bit of DENOMINATOR must be 1,
44 then the pre-processor symbol UDIV_NEEDS_NORMALIZATION is defined to 1.
45
b6d2adc7
TG
46 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
47 denominator). Like udiv_qrnnd but the numbers are signed. The
48 quotient is rounded towards 0.
49
50 5) count_leading_zeros(count, x) counts the number of zero-bits from
e1a79915
RS
51 the msb to the first non-zero bit. This is the number of steps X
52 needs to be shifted left to set the msb. Undefined for X == 0.
53
b6d2adc7 54 6) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
e1a79915
RS
55 high_addend_2, low_addend_2) adds two two-word unsigned integers,
56 composed by HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and
57 LOW_ADDEND_2 respectively. The result is placed in HIGH_SUM and
58 LOW_SUM. Overflow (i.e. carry out) is not stored anywhere, and is
59 lost.
60
b6d2adc7 61 7) sub_ddmmss(high_difference, low_difference, high_minuend,
e1a79915
RS
62 low_minuend, high_subtrahend, low_subtrahend) subtracts two
63 two-word unsigned integers, composed by HIGH_MINUEND_1 and
64 LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2
65 respectively. The result is placed in HIGH_DIFFERENCE and
66 LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
67 and is lost.
68
69 If any of these macros are left undefined for a particular CPU,
70 C macros are used. */
71
72/* The CPUs come in alphabetical order below.
73
74 Please add support for more CPUs here, or improve the current support
75 for the CPUs below!
f71c71f1 76 (E.g. WE32100, IBM360.) */
d83dd29a 77
3a0d22dd
MM
78#if defined (__GNUC__) && !defined (NO_ASM)
79
d83dd29a
TG
80/* We sometimes need to clobber "cc" with gcc2, but that would not be
81 understood by gcc1. Use cpp to avoid major code duplication. */
82#if __GNUC__ < 2
83#define __CLOBBER_CC
84#define __AND_CLOBBER_CC
85#else /* __GNUC__ >= 2 */
86#define __CLOBBER_CC : "cc"
87#define __AND_CLOBBER_CC , "cc"
88#endif /* __GNUC__ < 2 */
e1a79915 89
f71c71f1 90#if defined (__a29k__) || defined (_AM29K)
e1a79915
RS
91#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
92 __asm__ ("add %1,%4,%5
93 addc %0,%2,%3" \
d6b0bb68
MS
94 : "=r" ((USItype) (sh)), \
95 "=&r" ((USItype) (sl)) \
96 : "%r" ((USItype) (ah)), \
97 "rI" ((USItype) (bh)), \
98 "%r" ((USItype) (al)), \
99 "rI" ((USItype) (bl)))
e1a79915
RS
100#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
101 __asm__ ("sub %1,%4,%5
102 subc %0,%2,%3" \
d6b0bb68
MS
103 : "=r" ((USItype) (sh)), \
104 "=&r" ((USItype) (sl)) \
105 : "r" ((USItype) (ah)), \
106 "rI" ((USItype) (bh)), \
107 "r" ((USItype) (al)), \
108 "rI" ((USItype) (bl)))
e1a79915
RS
109#define umul_ppmm(xh, xl, m0, m1) \
110 do { \
e6c5404d 111 USItype __m0 = (m0), __m1 = (m1); \
d83dd29a 112 __asm__ ("multiplu %0,%1,%2" \
d6b0bb68 113 : "=r" ((USItype) (xl)) \
d83dd29a
TG
114 : "r" (__m0), \
115 "r" (__m1)); \
116 __asm__ ("multmu %0,%1,%2" \
d6b0bb68 117 : "=r" ((USItype) (xh)) \
d83dd29a
TG
118 : "r" (__m0), \
119 "r" (__m1)); \
e1a79915
RS
120 } while (0)
121#define udiv_qrnnd(q, r, n1, n0, d) \
122 __asm__ ("dividu %0,%3,%4" \
d6b0bb68
MS
123 : "=r" ((USItype) (q)), \
124 "=q" ((USItype) (r)) \
125 : "1" ((USItype) (n1)), \
126 "r" ((USItype) (n0)), \
127 "r" ((USItype) (d)))
e1a79915 128#define count_leading_zeros(count, x) \
d83dd29a 129 __asm__ ("clz %0,%1" \
d6b0bb68
MS
130 : "=r" ((USItype) (count)) \
131 : "r" ((USItype) (x)))
e1a79915
RS
132#endif /* __a29k__ */
133
66ed0683
JL
134#if defined (__arc__)
135#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
136 __asm__ ("add.f %1, %4, %5
137 adc %0, %2, %3" \
138 : "=r" ((USItype) (sh)), \
139 "=&r" ((USItype) (sl)) \
140 : "%r" ((USItype) (ah)), \
141 "rIJ" ((USItype) (bh)), \
142 "%r" ((USItype) (al)), \
143 "rIJ" ((USItype) (bl)))
144#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
145 __asm__ ("sub.f %1, %4, %5
146 sbc %0, %2, %3" \
147 : "=r" ((USItype) (sh)), \
148 "=&r" ((USItype) (sl)) \
149 : "r" ((USItype) (ah)), \
150 "rIJ" ((USItype) (bh)), \
151 "r" ((USItype) (al)), \
152 "rIJ" ((USItype) (bl)))
153/* Call libgcc1 routine. */
154#define umul_ppmm(w1, w0, u, v) \
155do { \
156 DIunion __w; \
157 __w.ll = __umulsidi3 (u, v); \
158 w1 = __w.s.high; \
159 w0 = __w.s.low; \
160} while (0)
161#define __umulsidi3 __umulsidi3
162UDItype __umulsidi3 (USItype, USItype);
163#endif
164
e1a79915
RS
165#if defined (__arm__)
166#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
ac1e676a
RE
167 __asm__ ("adds %1, %4, %5
168 adc %0, %2, %3" \
d6b0bb68
MS
169 : "=r" ((USItype) (sh)), \
170 "=&r" ((USItype) (sl)) \
171 : "%r" ((USItype) (ah)), \
172 "rI" ((USItype) (bh)), \
173 "%r" ((USItype) (al)), \
174 "rI" ((USItype) (bl)))
e1a79915 175#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
ac1e676a
RE
176 __asm__ ("subs %1, %4, %5
177 sbc %0, %2, %3" \
d6b0bb68
MS
178 : "=r" ((USItype) (sh)), \
179 "=&r" ((USItype) (sl)) \
180 : "r" ((USItype) (ah)), \
181 "rI" ((USItype) (bh)), \
182 "r" ((USItype) (al)), \
183 "rI" ((USItype) (bl)))
f71c71f1 184#define umul_ppmm(xh, xl, a, b) \
6a04a634 185{register USItype __t0, __t1, __t2; \
ac1e676a 186 __asm__ ("%@ Inlined umul_ppmm
6a04a634
RE
187 mov %2, %5, lsr #16
188 mov %0, %6, lsr #16
189 bic %3, %5, %2, lsl #16
190 bic %4, %6, %0, lsl #16
191 mul %1, %3, %4
192 mul %4, %2, %4
193 mul %3, %0, %3
194 mul %0, %2, %0
195 adds %3, %4, %3
ac1e676a 196 addcs %0, %0, #65536
6a04a634
RE
197 adds %1, %1, %3, lsl #16
198 adc %0, %0, %3, lsr #16" \
0f41302f
MS
199 : "=&r" ((USItype) (xh)), \
200 "=r" ((USItype) (xl)), \
6a04a634 201 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
0f41302f
MS
202 : "r" ((USItype) (a)), \
203 "r" ((USItype) (b)));}
f71c71f1
TG
204#define UMUL_TIME 20
205#define UDIV_TIME 100
e1a79915
RS
206#endif /* __arm__ */
207
f71c71f1
TG
208#if defined (__clipper__)
209#define umul_ppmm(w1, w0, u, v) \
210 ({union {UDItype __ll; \
211 struct {USItype __l, __h;} __i; \
212 } __xx; \
213 __asm__ ("mulwux %2,%0" \
214 : "=r" (__xx.__ll) \
0f41302f
MS
215 : "%0" ((USItype) (u)), \
216 "r" ((USItype) (v))); \
f71c71f1
TG
217 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
218#define smul_ppmm(w1, w0, u, v) \
219 ({union {DItype __ll; \
220 struct {SItype __l, __h;} __i; \
221 } __xx; \
222 __asm__ ("mulwx %2,%0" \
223 : "=r" (__xx.__ll) \
0f41302f
MS
224 : "%0" ((SItype) (u)), \
225 "r" ((SItype) (v))); \
f71c71f1
TG
226 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
227#define __umulsidi3(u, v) \
228 ({UDItype __w; \
229 __asm__ ("mulwux %2,%0" \
230 : "=r" (__w) \
0f41302f
MS
231 : "%0" ((USItype) (u)), \
232 "r" ((USItype) (v))); \
f71c71f1
TG
233 __w; })
234#endif /* __clipper__ */
235
e1a79915
RS
236#if defined (__gmicro__)
237#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
238 __asm__ ("add.w %5,%1
239 addx %3,%0" \
0f41302f
MS
240 : "=g" ((USItype) (sh)), \
241 "=&g" ((USItype) (sl)) \
242 : "%0" ((USItype) (ah)), \
243 "g" ((USItype) (bh)), \
244 "%1" ((USItype) (al)), \
245 "g" ((USItype) (bl)))
e1a79915
RS
246#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
247 __asm__ ("sub.w %5,%1
248 subx %3,%0" \
0f41302f
MS
249 : "=g" ((USItype) (sh)), \
250 "=&g" ((USItype) (sl)) \
251 : "0" ((USItype) (ah)), \
252 "g" ((USItype) (bh)), \
253 "1" ((USItype) (al)), \
254 "g" ((USItype) (bl)))
e1a79915
RS
255#define umul_ppmm(ph, pl, m0, m1) \
256 __asm__ ("mulx %3,%0,%1" \
0f41302f
MS
257 : "=g" ((USItype) (ph)), \
258 "=r" ((USItype) (pl)) \
259 : "%0" ((USItype) (m0)), \
260 "g" ((USItype) (m1)))
e1a79915
RS
261#define udiv_qrnnd(q, r, nh, nl, d) \
262 __asm__ ("divx %4,%0,%1" \
0f41302f
MS
263 : "=g" ((USItype) (q)), \
264 "=r" ((USItype) (r)) \
265 : "1" ((USItype) (nh)), \
266 "0" ((USItype) (nl)), \
267 "g" ((USItype) (d)))
e1a79915
RS
268#define count_leading_zeros(count, x) \
269 __asm__ ("bsch/1 %1,%0" \
d83dd29a 270 : "=g" (count) \
0f41302f
MS
271 : "g" ((USItype) (x)), \
272 "0" ((USItype) 0))
e1a79915
RS
273#endif
274
275#if defined (__hppa)
276#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
277 __asm__ ("add %4,%5,%1
278 addc %2,%3,%0" \
0f41302f
MS
279 : "=r" ((USItype) (sh)), \
280 "=&r" ((USItype) (sl)) \
281 : "%rM" ((USItype) (ah)), \
282 "rM" ((USItype) (bh)), \
283 "%rM" ((USItype) (al)), \
284 "rM" ((USItype) (bl)))
e1a79915 285#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
7691f559
TG
286 __asm__ ("sub %4,%5,%1
287 subb %2,%3,%0" \
0f41302f
MS
288 : "=r" ((USItype) (sh)), \
289 "=&r" ((USItype) (sl)) \
290 : "rM" ((USItype) (ah)), \
291 "rM" ((USItype) (bh)), \
292 "rM" ((USItype) (al)), \
293 "rM" ((USItype) (bl)))
d83dd29a
TG
294#if defined (_PA_RISC1_1)
295#define umul_ppmm(w1, w0, u, v) \
296 do { \
297 union \
298 { \
e6c5404d
TG
299 UDItype __f; \
300 struct {USItype __w1, __w0;} __w1w0; \
d83dd29a
TG
301 } __t; \
302 __asm__ ("xmpyu %1,%2,%0" \
303 : "=x" (__t.__f) \
0f41302f
MS
304 : "x" ((USItype) (u)), \
305 "x" ((USItype) (v))); \
d83dd29a
TG
306 (w1) = __t.__w1w0.__w1; \
307 (w0) = __t.__w1w0.__w0; \
308 } while (0)
309#define UMUL_TIME 8
310#else
311#define UMUL_TIME 30
312#endif
313#define UDIV_TIME 40
f71c71f1
TG
314#define count_leading_zeros(count, x) \
315 do { \
316 USItype __tmp; \
317 __asm__ ( \
318 "ldi 1,%0
319 extru,= %1,15,16,%%r0 ; Bits 31..16 zero?
320 extru,tr %1,15,16,%1 ; No. Shift down, skip add.
321 ldo 16(%0),%0 ; Yes. Perform add.
322 extru,= %1,23,8,%%r0 ; Bits 15..8 zero?
323 extru,tr %1,23,8,%1 ; No. Shift down, skip add.
324 ldo 8(%0),%0 ; Yes. Perform add.
325 extru,= %1,27,4,%%r0 ; Bits 7..4 zero?
326 extru,tr %1,27,4,%1 ; No. Shift down, skip add.
327 ldo 4(%0),%0 ; Yes. Perform add.
328 extru,= %1,29,2,%%r0 ; Bits 3..2 zero?
329 extru,tr %1,29,2,%1 ; No. Shift down, skip add.
330 ldo 2(%0),%0 ; Yes. Perform add.
331 extru %1,30,1,%1 ; Extract bit 1.
332 sub %0,%1,%0 ; Subtract it.
333 " : "=r" (count), "=r" (__tmp) : "1" (x)); \
334 } while (0)
e1a79915
RS
335#endif
336
337#if defined (__i386__) || defined (__i486__)
338#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
339 __asm__ ("addl %5,%1
340 adcl %3,%0" \
0f41302f
MS
341 : "=r" ((USItype) (sh)), \
342 "=&r" ((USItype) (sl)) \
343 : "%0" ((USItype) (ah)), \
344 "g" ((USItype) (bh)), \
345 "%1" ((USItype) (al)), \
346 "g" ((USItype) (bl)))
e1a79915
RS
347#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
348 __asm__ ("subl %5,%1
349 sbbl %3,%0" \
0f41302f
MS
350 : "=r" ((USItype) (sh)), \
351 "=&r" ((USItype) (sl)) \
352 : "0" ((USItype) (ah)), \
353 "g" ((USItype) (bh)), \
354 "1" ((USItype) (al)), \
355 "g" ((USItype) (bl)))
e1a79915
RS
356#define umul_ppmm(w1, w0, u, v) \
357 __asm__ ("mull %3" \
0f41302f
MS
358 : "=a" ((USItype) (w0)), \
359 "=d" ((USItype) (w1)) \
360 : "%0" ((USItype) (u)), \
361 "rm" ((USItype) (v)))
e1a79915
RS
362#define udiv_qrnnd(q, r, n1, n0, d) \
363 __asm__ ("divl %4" \
0f41302f
MS
364 : "=a" ((USItype) (q)), \
365 "=d" ((USItype) (r)) \
366 : "0" ((USItype) (n0)), \
367 "1" ((USItype) (n1)), \
368 "rm" ((USItype) (d)))
e1a79915
RS
369#define count_leading_zeros(count, x) \
370 do { \
e6c5404d 371 USItype __cbtmp; \
e1a79915 372 __asm__ ("bsrl %1,%0" \
0f41302f 373 : "=r" (__cbtmp) : "rm" ((USItype) (x))); \
e1a79915
RS
374 (count) = __cbtmp ^ 31; \
375 } while (0)
d83dd29a
TG
376#define UMUL_TIME 40
377#define UDIV_TIME 40
e1a79915
RS
378#endif /* 80x86 */
379
380#if defined (__i860__)
381#if 0
382/* Make sure these patterns really improve the code before
383 switching them on. */
384#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
385 do { \
386 union \
387 { \
e6c5404d
TG
388 DItype __ll; \
389 struct {USItype __l, __h;} __i; \
e1a79915 390 } __a, __b, __s; \
e6c5404d
TG
391 __a.__i.__l = (al); \
392 __a.__i.__h = (ah); \
393 __b.__i.__l = (bl); \
394 __b.__i.__h = (bh); \
e1a79915 395 __asm__ ("fiadd.dd %1,%2,%0" \
e6c5404d
TG
396 : "=f" (__s.__ll) \
397 : "%f" (__a.__ll), "f" (__b.__ll)); \
398 (sh) = __s.__i.__h; \
399 (sl) = __s.__i.__l; \
e1a79915
RS
400 } while (0)
401#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
402 do { \
403 union \
404 { \
e6c5404d
TG
405 DItype __ll; \
406 struct {USItype __l, __h;} __i; \
e1a79915 407 } __a, __b, __s; \
e6c5404d
TG
408 __a.__i.__l = (al); \
409 __a.__i.__h = (ah); \
410 __b.__i.__l = (bl); \
411 __b.__i.__h = (bh); \
e1a79915 412 __asm__ ("fisub.dd %1,%2,%0" \
e6c5404d
TG
413 : "=f" (__s.__ll) \
414 : "%f" (__a.__ll), "f" (__b.__ll)); \
415 (sh) = __s.__i.__h; \
416 (sl) = __s.__i.__l; \
e1a79915
RS
417 } while (0)
418#endif
419#endif /* __i860__ */
420
f71c71f1
TG
421#if defined (__i960__)
422#define umul_ppmm(w1, w0, u, v) \
423 ({union {UDItype __ll; \
424 struct {USItype __l, __h;} __i; \
425 } __xx; \
426 __asm__ ("emul %2,%1,%0" \
427 : "=d" (__xx.__ll) \
0f41302f
MS
428 : "%dI" ((USItype) (u)), \
429 "dI" ((USItype) (v))); \
f71c71f1
TG
430 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
431#define __umulsidi3(u, v) \
432 ({UDItype __w; \
433 __asm__ ("emul %2,%1,%0" \
434 : "=d" (__w) \
0f41302f
MS
435 : "%dI" ((USItype) (u)), \
436 "dI" ((USItype) (v))); \
f71c71f1
TG
437 __w; })
438#endif /* __i960__ */
e1a79915 439
be20c0ad
DE
440#if defined (__M32R__)
441#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
442 /* The cmp clears the condition bit. */ \
443 __asm__ ("cmp %0,%0
444 addx %%5,%1
445 addx %%3,%0" \
446 : "=r" ((USItype) (sh)), \
447 "=&r" ((USItype) (sl)) \
448 : "%0" ((USItype) (ah)), \
449 "r" ((USItype) (bh)), \
450 "%1" ((USItype) (al)), \
451 "r" ((USItype) (bl)) \
452 : "cbit")
453#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
454 /* The cmp clears the condition bit. */ \
455 __asm__ ("cmp %0,%0
456 subx %5,%1
457 subx %3,%0" \
458 : "=r" ((USItype) (sh)), \
459 "=&r" ((USItype) (sl)) \
460 : "0" ((USItype) (ah)), \
461 "r" ((USItype) (bh)), \
462 "1" ((USItype) (al)), \
463 "r" ((USItype) (bl)) \
464 : "cbit")
465#endif /* __M32R__ */
466
e1a79915
RS
467#if defined (__mc68000__)
468#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
469 __asm__ ("add%.l %5,%1
470 addx%.l %3,%0" \
0f41302f
MS
471 : "=d" ((USItype) (sh)), \
472 "=&d" ((USItype) (sl)) \
473 : "%0" ((USItype) (ah)), \
474 "d" ((USItype) (bh)), \
475 "%1" ((USItype) (al)), \
476 "g" ((USItype) (bl)))
e1a79915
RS
477#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
478 __asm__ ("sub%.l %5,%1
479 subx%.l %3,%0" \
0f41302f
MS
480 : "=d" ((USItype) (sh)), \
481 "=&d" ((USItype) (sl)) \
482 : "0" ((USItype) (ah)), \
483 "d" ((USItype) (bh)), \
484 "1" ((USItype) (al)), \
485 "g" ((USItype) (bl)))
f3a5c9a4
RK
486
487/* The '020, '030, '040 and CPU32 have 32x32->64 and 64/32->32q-32r. */
488#if defined (__mc68020__) || defined(mc68020) \
489 || defined(__mc68030__) || defined(mc68030) \
490 || defined(__mc68040__) || defined(mc68040) \
74cf1c6d 491 || defined(__mcpu32__) || defined(mcpu32) \
f3a5c9a4 492 || defined(__NeXT__)
e1a79915
RS
493#define umul_ppmm(w1, w0, u, v) \
494 __asm__ ("mulu%.l %3,%1:%0" \
0f41302f
MS
495 : "=d" ((USItype) (w0)), \
496 "=d" ((USItype) (w1)) \
497 : "%0" ((USItype) (u)), \
498 "dmi" ((USItype) (v)))
d83dd29a 499#define UMUL_TIME 45
e1a79915
RS
500#define udiv_qrnnd(q, r, n1, n0, d) \
501 __asm__ ("divu%.l %4,%1:%0" \
0f41302f
MS
502 : "=d" ((USItype) (q)), \
503 "=d" ((USItype) (r)) \
504 : "0" ((USItype) (n0)), \
505 "1" ((USItype) (n1)), \
506 "dmi" ((USItype) (d)))
d83dd29a
TG
507#define UDIV_TIME 90
508#define sdiv_qrnnd(q, r, n1, n0, d) \
509 __asm__ ("divs%.l %4,%1:%0" \
0f41302f
MS
510 : "=d" ((USItype) (q)), \
511 "=d" ((USItype) (r)) \
512 : "0" ((USItype) (n0)), \
513 "1" ((USItype) (n1)), \
514 "dmi" ((USItype) (d)))
f3a5c9a4 515
e1a79915 516#else /* not mc68020 */
8fa71ff0 517#if !defined(__mcf5200__)
b24b1d78 518/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */
e1a79915
RS
519#define umul_ppmm(xh, xl, a, b) \
520 __asm__ ("| Inlined umul_ppmm
f71c71f1
TG
521 move%.l %2,%/d0
522 move%.l %3,%/d1
523 move%.l %/d0,%/d2
bb66e0f6 524 swap %/d0
f71c71f1 525 move%.l %/d1,%/d3
bb66e0f6 526 swap %/d1
f71c71f1 527 move%.w %/d2,%/d4
bb66e0f6
ILT
528 mulu %/d3,%/d4
529 mulu %/d1,%/d2
530 mulu %/d0,%/d3
531 mulu %/d0,%/d1
f71c71f1
TG
532 move%.l %/d4,%/d0
533 eor%.w %/d0,%/d0
bb66e0f6 534 swap %/d0
f71c71f1
TG
535 add%.l %/d0,%/d2
536 add%.l %/d3,%/d2
e1a79915 537 jcc 1f
b24b1d78 538 add%.l %#65536,%/d1
bb66e0f6 5391: swap %/d2
b24b1d78 540 moveq %#0,%/d0
f71c71f1
TG
541 move%.w %/d2,%/d0
542 move%.w %/d4,%/d2
543 move%.l %/d2,%1
544 add%.l %/d1,%/d0
545 move%.l %/d0,%0" \
0f41302f
MS
546 : "=g" ((USItype) (xh)), \
547 "=g" ((USItype) (xl)) \
548 : "g" ((USItype) (a)), \
f3a5c9a4 549 "g" ((USItype) (b)) \
d83dd29a
TG
550 : "d0", "d1", "d2", "d3", "d4")
551#define UMUL_TIME 100
552#define UDIV_TIME 400
f3a5c9a4 553#endif /* not mcf5200 */
e1a79915 554#endif /* not mc68020 */
f3a5c9a4
RK
555
556/* The '020, '030, '040 and '060 have bitfield insns. */
557#if defined (__mc68020__) || defined(mc68020) \
558 || defined(__mc68030__) || defined(mc68030) \
559 || defined(__mc68040__) || defined(mc68040) \
560 || defined(__mc68060__) || defined(mc68060) \
561 || defined(__NeXT__)
562#define count_leading_zeros(count, x) \
563 __asm__ ("bfffo %1{%b2:%b2},%0" \
564 : "=d" ((USItype) (count)) \
565 : "od" ((USItype) (x)), "n" (0))
566#endif
e1a79915
RS
567#endif /* mc68000 */
568
569#if defined (__m88000__)
570#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
571 __asm__ ("addu.co %1,%r4,%r5
572 addu.ci %0,%r2,%r3" \
0f41302f
MS
573 : "=r" ((USItype) (sh)), \
574 "=&r" ((USItype) (sl)) \
575 : "%rJ" ((USItype) (ah)), \
576 "rJ" ((USItype) (bh)), \
577 "%rJ" ((USItype) (al)), \
578 "rJ" ((USItype) (bl)))
e1a79915
RS
579#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
580 __asm__ ("subu.co %1,%r4,%r5
581 subu.ci %0,%r2,%r3" \
0f41302f
MS
582 : "=r" ((USItype) (sh)), \
583 "=&r" ((USItype) (sl)) \
584 : "rJ" ((USItype) (ah)), \
585 "rJ" ((USItype) (bh)), \
586 "rJ" ((USItype) (al)), \
587 "rJ" ((USItype) (bl)))
e1a79915
RS
588#define count_leading_zeros(count, x) \
589 do { \
e6c5404d 590 USItype __cbtmp; \
e1a79915 591 __asm__ ("ff1 %0,%1" \
d83dd29a 592 : "=r" (__cbtmp) \
0f41302f 593 : "r" ((USItype) (x))); \
e1a79915
RS
594 (count) = __cbtmp ^ 31; \
595 } while (0)
d83dd29a 596#if defined (__mc88110__)
f71c71f1
TG
597#define umul_ppmm(wh, wl, u, v) \
598 do { \
599 union {UDItype __ll; \
600 struct {USItype __h, __l;} __i; \
601 } __xx; \
602 __asm__ ("mulu.d %0,%1,%2" \
603 : "=r" (__xx.__ll) \
0f41302f
MS
604 : "r" ((USItype) (u)), \
605 "r" ((USItype) (v))); \
f71c71f1
TG
606 (wh) = __xx.__i.__h; \
607 (wl) = __xx.__i.__l; \
608 } while (0)
d83dd29a 609#define udiv_qrnnd(q, r, n1, n0, d) \
f71c71f1
TG
610 ({union {UDItype __ll; \
611 struct {USItype __h, __l;} __i; \
612 } __xx; \
613 USItype __q; \
614 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
615 __asm__ ("divu.d %0,%1,%2" \
616 : "=r" (__q) \
617 : "r" (__xx.__ll), \
0f41302f 618 "r" ((USItype) (d))); \
f71c71f1
TG
619 (r) = (n0) - __q * (d); (q) = __q; })
620#define UMUL_TIME 5
621#define UDIV_TIME 25
622#else
623#define UMUL_TIME 17
624#define UDIV_TIME 150
625#endif /* __mc88110__ */
e1a79915
RS
626#endif /* __m88000__ */
627
628#if defined (__mips__)
d28e1517 629#define umul_ppmm(w1, w0, u, v) \
df138bc2 630 __asm__ ("multu %2,%3" \
0f41302f
MS
631 : "=l" ((USItype) (w0)), \
632 "=h" ((USItype) (w1)) \
633 : "d" ((USItype) (u)), \
634 "d" ((USItype) (v)))
f71c71f1 635#define UMUL_TIME 10
e1a79915
RS
636#define UDIV_TIME 100
637#endif /* __mips__ */
638
639#if defined (__ns32000__)
f71c71f1
TG
640#define umul_ppmm(w1, w0, u, v) \
641 ({union {UDItype __ll; \
642 struct {USItype __l, __h;} __i; \
643 } __xx; \
644 __asm__ ("meid %2,%0" \
645 : "=g" (__xx.__ll) \
0f41302f
MS
646 : "%0" ((USItype) (u)), \
647 "g" ((USItype) (v))); \
f71c71f1 648 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
e1a79915 649#define __umulsidi3(u, v) \
e6c5404d 650 ({UDItype __w; \
d83dd29a
TG
651 __asm__ ("meid %2,%0" \
652 : "=g" (__w) \
0f41302f
MS
653 : "%0" ((USItype) (u)), \
654 "g" ((USItype) (v))); \
d83dd29a 655 __w; })
f71c71f1
TG
656#define udiv_qrnnd(q, r, n1, n0, d) \
657 ({union {UDItype __ll; \
658 struct {USItype __l, __h;} __i; \
659 } __xx; \
660 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
661 __asm__ ("deid %2,%0" \
662 : "=g" (__xx.__ll) \
663 : "0" (__xx.__ll), \
0f41302f 664 "g" ((USItype) (d))); \
f71c71f1 665 (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
e1a79915
RS
666#endif /* __ns32000__ */
667
325877e1 668#if (defined (_ARCH_PPC) || defined (_IBMR2)) && W_TYPE_SIZE == 32
f71c71f1
TG
669#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
670 do { \
671 if (__builtin_constant_p (bh) && (bh) == 0) \
672 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
0f41302f
MS
673 : "=r" ((USItype) (sh)), \
674 "=&r" ((USItype) (sl)) \
675 : "%r" ((USItype) (ah)), \
676 "%r" ((USItype) (al)), \
677 "rI" ((USItype) (bl))); \
f71c71f1
TG
678 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
679 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
0f41302f
MS
680 : "=r" ((USItype) (sh)), \
681 "=&r" ((USItype) (sl)) \
682 : "%r" ((USItype) (ah)), \
683 "%r" ((USItype) (al)), \
684 "rI" ((USItype) (bl))); \
f71c71f1
TG
685 else \
686 __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
0f41302f
MS
687 : "=r" ((USItype) (sh)), \
688 "=&r" ((USItype) (sl)) \
689 : "%r" ((USItype) (ah)), \
690 "r" ((USItype) (bh)), \
691 "%r" ((USItype) (al)), \
692 "rI" ((USItype) (bl))); \
f71c71f1
TG
693 } while (0)
694#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
695 do { \
696 if (__builtin_constant_p (ah) && (ah) == 0) \
325877e1 697 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
0f41302f
MS
698 : "=r" ((USItype) (sh)), \
699 "=&r" ((USItype) (sl)) \
700 : "r" ((USItype) (bh)), \
701 "rI" ((USItype) (al)), \
702 "r" ((USItype) (bl))); \
f71c71f1 703 else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \
325877e1 704 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
0f41302f
MS
705 : "=r" ((USItype) (sh)), \
706 "=&r" ((USItype) (sl)) \
707 : "r" ((USItype) (bh)), \
708 "rI" ((USItype) (al)), \
709 "r" ((USItype) (bl))); \
f71c71f1
TG
710 else if (__builtin_constant_p (bh) && (bh) == 0) \
711 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
0f41302f
MS
712 : "=r" ((USItype) (sh)), \
713 "=&r" ((USItype) (sl)) \
714 : "r" ((USItype) (ah)), \
715 "rI" ((USItype) (al)), \
716 "r" ((USItype) (bl))); \
f71c71f1
TG
717 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
718 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
0f41302f
MS
719 : "=r" ((USItype) (sh)), \
720 "=&r" ((USItype) (sl)) \
721 : "r" ((USItype) (ah)), \
722 "rI" ((USItype) (al)), \
723 "r" ((USItype) (bl))); \
f71c71f1
TG
724 else \
725 __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
0f41302f
MS
726 : "=r" ((USItype) (sh)), \
727 "=&r" ((USItype) (sl)) \
728 : "r" ((USItype) (ah)), \
729 "r" ((USItype) (bh)), \
730 "rI" ((USItype) (al)), \
731 "r" ((USItype) (bl))); \
f71c71f1
TG
732 } while (0)
733#define count_leading_zeros(count, x) \
734 __asm__ ("{cntlz|cntlzw} %0,%1" \
0f41302f
MS
735 : "=r" ((USItype) (count)) \
736 : "r" ((USItype) (x)))
325877e1 737#if defined (_ARCH_PPC)
f71c71f1
TG
738#define umul_ppmm(ph, pl, m0, m1) \
739 do { \
740 USItype __m0 = (m0), __m1 = (m1); \
741 __asm__ ("mulhwu %0,%1,%2" \
742 : "=r" ((USItype) ph) \
743 : "%r" (__m0), \
744 "r" (__m1)); \
745 (pl) = __m0 * __m1; \
746 } while (0)
747#define UMUL_TIME 15
748#define smul_ppmm(ph, pl, m0, m1) \
749 do { \
750 SItype __m0 = (m0), __m1 = (m1); \
751 __asm__ ("mulhw %0,%1,%2" \
752 : "=r" ((SItype) ph) \
753 : "%r" (__m0), \
754 "r" (__m1)); \
755 (pl) = __m0 * __m1; \
756 } while (0)
757#define SMUL_TIME 14
758#define UDIV_TIME 120
759#else
760#define umul_ppmm(xh, xl, m0, m1) \
761 do { \
762 USItype __m0 = (m0), __m1 = (m1); \
763 __asm__ ("mul %0,%2,%3" \
0f41302f
MS
764 : "=r" ((USItype) (xh)), \
765 "=q" ((USItype) (xl)) \
f71c71f1
TG
766 : "r" (__m0), \
767 "r" (__m1)); \
768 (xh) += ((((SItype) __m0 >> 31) & __m1) \
769 + (((SItype) __m1 >> 31) & __m0)); \
770 } while (0)
771#define UMUL_TIME 8
772#define smul_ppmm(xh, xl, m0, m1) \
773 __asm__ ("mul %0,%2,%3" \
0f41302f
MS
774 : "=r" ((SItype) (xh)), \
775 "=q" ((SItype) (xl)) \
f71c71f1
TG
776 : "r" (m0), \
777 "r" (m1))
778#define SMUL_TIME 4
779#define sdiv_qrnnd(q, r, nh, nl, d) \
780 __asm__ ("div %0,%2,%4" \
0f41302f
MS
781 : "=r" ((SItype) (q)), "=q" ((SItype) (r)) \
782 : "r" ((SItype) (nh)), "1" ((SItype) (nl)), "r" ((SItype) (d)))
f71c71f1
TG
783#define UDIV_TIME 100
784#endif
785#endif /* Power architecture variants. */
786
e1a79915
RS
787#if defined (__pyr__)
788#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
789 __asm__ ("addw %5,%1
790 addwc %3,%0" \
0f41302f
MS
791 : "=r" ((USItype) (sh)), \
792 "=&r" ((USItype) (sl)) \
793 : "%0" ((USItype) (ah)), \
794 "g" ((USItype) (bh)), \
795 "%1" ((USItype) (al)), \
796 "g" ((USItype) (bl)))
e1a79915
RS
797#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
798 __asm__ ("subw %5,%1
799 subwb %3,%0" \
0f41302f
MS
800 : "=r" ((USItype) (sh)), \
801 "=&r" ((USItype) (sl)) \
802 : "0" ((USItype) (ah)), \
803 "g" ((USItype) (bh)), \
804 "1" ((USItype) (al)), \
805 "g" ((USItype) (bl)))
f4432e94 806/* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */
e1a79915 807#define umul_ppmm(w1, w0, u, v) \
f4432e94
RK
808 ({union {UDItype __ll; \
809 struct {USItype __h, __l;} __i; \
810 } __xx; \
811 __asm__ ("movw %1,%R0
812 uemul %2,%0" \
813 : "=&r" (__xx.__ll) \
814 : "g" ((USItype) (u)), \
0f41302f 815 "g" ((USItype) (v))); \
f4432e94 816 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
e1a79915
RS
817#endif /* __pyr__ */
818
819#if defined (__ibm032__) /* RT/ROMP */
820#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
821 __asm__ ("a %1,%5
822 ae %0,%3" \
0f41302f
MS
823 : "=r" ((USItype) (sh)), \
824 "=&r" ((USItype) (sl)) \
825 : "%0" ((USItype) (ah)), \
826 "r" ((USItype) (bh)), \
827 "%1" ((USItype) (al)), \
828 "r" ((USItype) (bl)))
e1a79915
RS
829#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
830 __asm__ ("s %1,%5
831 se %0,%3" \
0f41302f
MS
832 : "=r" ((USItype) (sh)), \
833 "=&r" ((USItype) (sl)) \
834 : "0" ((USItype) (ah)), \
835 "r" ((USItype) (bh)), \
836 "1" ((USItype) (al)), \
837 "r" ((USItype) (bl)))
e1a79915
RS
838#define umul_ppmm(ph, pl, m0, m1) \
839 do { \
e6c5404d 840 USItype __m0 = (m0), __m1 = (m1); \
e1a79915
RS
841 __asm__ ( \
842 "s r2,r2
843 mts r10,%2
844 m r2,%3
845 m r2,%3
846 m r2,%3
847 m r2,%3
848 m r2,%3
849 m r2,%3
850 m r2,%3
851 m r2,%3
852 m r2,%3
853 m r2,%3
854 m r2,%3
855 m r2,%3
856 m r2,%3
857 m r2,%3
858 m r2,%3
859 m r2,%3
860 cas %0,r2,r0
861 mfs r10,%1" \
0f41302f
MS
862 : "=r" ((USItype) (ph)), \
863 "=r" ((USItype) (pl)) \
d83dd29a
TG
864 : "%r" (__m0), \
865 "r" (__m1) \
866 : "r2"); \
e6c5404d
TG
867 (ph) += ((((SItype) __m0 >> 31) & __m1) \
868 + (((SItype) __m1 >> 31) & __m0)); \
e1a79915 869 } while (0)
d83dd29a
TG
870#define UMUL_TIME 20
871#define UDIV_TIME 200
e1a79915
RS
872#define count_leading_zeros(count, x) \
873 do { \
874 if ((x) >= 0x10000) \
875 __asm__ ("clz %0,%1" \
0f41302f
MS
876 : "=r" ((USItype) (count)) \
877 : "r" ((USItype) (x) >> 16)); \
e1a79915
RS
878 else \
879 { \
880 __asm__ ("clz %0,%1" \
0f41302f
MS
881 : "=r" ((USItype) (count)) \
882 : "r" ((USItype) (x))); \
e1a79915
RS
883 (count) += 16; \
884 } \
885 } while (0)
886#endif
887
888#if defined (__sparc__)
889#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
f71c71f1
TG
890 __asm__ ("addcc %r4,%5,%1
891 addx %r2,%3,%0" \
0f41302f
MS
892 : "=r" ((USItype) (sh)), \
893 "=&r" ((USItype) (sl)) \
894 : "%rJ" ((USItype) (ah)), \
895 "rI" ((USItype) (bh)), \
896 "%rJ" ((USItype) (al)), \
897 "rI" ((USItype) (bl)) \
d83dd29a 898 __CLOBBER_CC)
e1a79915 899#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
f71c71f1
TG
900 __asm__ ("subcc %r4,%5,%1
901 subx %r2,%3,%0" \
0f41302f
MS
902 : "=r" ((USItype) (sh)), \
903 "=&r" ((USItype) (sl)) \
904 : "rJ" ((USItype) (ah)), \
905 "rI" ((USItype) (bh)), \
906 "rJ" ((USItype) (al)), \
907 "rI" ((USItype) (bl)) \
d83dd29a 908 __CLOBBER_CC)
d9d3acb6 909#if defined (__sparc_v8__)
e1a79915
RS
910#define umul_ppmm(w1, w0, u, v) \
911 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
0f41302f
MS
912 : "=r" ((USItype) (w1)), \
913 "=r" ((USItype) (w0)) \
914 : "r" ((USItype) (u)), \
915 "r" ((USItype) (v)))
e1a79915
RS
916#define udiv_qrnnd(q, r, n1, n0, d) \
917 __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
0f41302f
MS
918 : "=&r" ((USItype) (q)), \
919 "=&r" ((USItype) (r)) \
920 : "r" ((USItype) (n1)), \
921 "r" ((USItype) (n0)), \
922 "r" ((USItype) (d)))
e1a79915 923#else
d9d3acb6
JW
924#if defined (__sparclite__)
925/* This has hardware multiply but not divide. It also has two additional
926 instructions scan (ffs from high bit) and divscc. */
927#define umul_ppmm(w1, w0, u, v) \
928 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
0f41302f
MS
929 : "=r" ((USItype) (w1)), \
930 "=r" ((USItype) (w0)) \
931 : "r" ((USItype) (u)), \
932 "r" ((USItype) (v)))
d9d3acb6
JW
933#define udiv_qrnnd(q, r, n1, n0, d) \
934 __asm__ ("! Inlined udiv_qrnnd
935 wr %%g0,%2,%%y ! Not a delayed write for sparclite
936 tst %%g0
937 divscc %3,%4,%%g1
938 divscc %%g1,%4,%%g1
939 divscc %%g1,%4,%%g1
940 divscc %%g1,%4,%%g1
941 divscc %%g1,%4,%%g1
942 divscc %%g1,%4,%%g1
943 divscc %%g1,%4,%%g1
944 divscc %%g1,%4,%%g1
945 divscc %%g1,%4,%%g1
946 divscc %%g1,%4,%%g1
947 divscc %%g1,%4,%%g1
948 divscc %%g1,%4,%%g1
949 divscc %%g1,%4,%%g1
950 divscc %%g1,%4,%%g1
951 divscc %%g1,%4,%%g1
952 divscc %%g1,%4,%%g1
953 divscc %%g1,%4,%%g1
954 divscc %%g1,%4,%%g1
955 divscc %%g1,%4,%%g1
956 divscc %%g1,%4,%%g1
957 divscc %%g1,%4,%%g1
958 divscc %%g1,%4,%%g1
959 divscc %%g1,%4,%%g1
960 divscc %%g1,%4,%%g1
961 divscc %%g1,%4,%%g1
962 divscc %%g1,%4,%%g1
963 divscc %%g1,%4,%%g1
964 divscc %%g1,%4,%%g1
965 divscc %%g1,%4,%%g1
966 divscc %%g1,%4,%%g1
967 divscc %%g1,%4,%%g1
968 divscc %%g1,%4,%0
969 rd %%y,%1
970 bl,a 1f
971 add %1,%4,%1
9721: ! End of inline udiv_qrnnd" \
0f41302f
MS
973 : "=r" ((USItype) (q)), \
974 "=r" ((USItype) (r)) \
975 : "r" ((USItype) (n1)), \
976 "r" ((USItype) (n0)), \
977 "rI" ((USItype) (d)) \
210d97af 978 : "%g1" __AND_CLOBBER_CC)
d9d3acb6
JW
979#define UDIV_TIME 37
980#define count_leading_zeros(count, x) \
84530511
SC
981 do { \
982 __asm__ ("scan %1,1,%0" \
983 : "=r" ((USItype) (count)) \
984 : "r" ((USItype) (x))); \
985 } while (0)
d9d3acb6 986#else
e1a79915
RS
987/* SPARC without integer multiplication and divide instructions.
988 (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
989#define umul_ppmm(w1, w0, u, v) \
990 __asm__ ("! Inlined umul_ppmm
991 wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr
992 sra %3,31,%%g2 ! Don't move this insn
993 and %2,%%g2,%%g2 ! Don't move this insn
994 andcc %%g0,0,%%g1 ! Don't move this insn
995 mulscc %%g1,%3,%%g1
996 mulscc %%g1,%3,%%g1
997 mulscc %%g1,%3,%%g1
998 mulscc %%g1,%3,%%g1
999 mulscc %%g1,%3,%%g1
1000 mulscc %%g1,%3,%%g1
1001 mulscc %%g1,%3,%%g1
1002 mulscc %%g1,%3,%%g1
1003 mulscc %%g1,%3,%%g1
1004 mulscc %%g1,%3,%%g1
1005 mulscc %%g1,%3,%%g1
1006 mulscc %%g1,%3,%%g1
1007 mulscc %%g1,%3,%%g1
1008 mulscc %%g1,%3,%%g1
1009 mulscc %%g1,%3,%%g1
1010 mulscc %%g1,%3,%%g1
1011 mulscc %%g1,%3,%%g1
1012 mulscc %%g1,%3,%%g1
1013 mulscc %%g1,%3,%%g1
1014 mulscc %%g1,%3,%%g1
1015 mulscc %%g1,%3,%%g1
1016 mulscc %%g1,%3,%%g1
1017 mulscc %%g1,%3,%%g1
1018 mulscc %%g1,%3,%%g1
1019 mulscc %%g1,%3,%%g1
1020 mulscc %%g1,%3,%%g1
1021 mulscc %%g1,%3,%%g1
1022 mulscc %%g1,%3,%%g1
1023 mulscc %%g1,%3,%%g1
1024 mulscc %%g1,%3,%%g1
1025 mulscc %%g1,%3,%%g1
1026 mulscc %%g1,%3,%%g1
1027 mulscc %%g1,0,%%g1
1028 add %%g1,%%g2,%0
1029 rd %%y,%1" \
0f41302f
MS
1030 : "=r" ((USItype) (w1)), \
1031 "=r" ((USItype) (w0)) \
1032 : "%rI" ((USItype) (u)), \
1033 "r" ((USItype) (v)) \
d83dd29a 1034 : "%g1", "%g2" __AND_CLOBBER_CC)
e1a79915
RS
1035#define UMUL_TIME 39 /* 39 instructions */
1036/* It's quite necessary to add this much assembler for the sparc.
1037 The default udiv_qrnnd (in C) is more than 10 times slower! */
1038#define udiv_qrnnd(q, r, n1, n0, d) \
1039 __asm__ ("! Inlined udiv_qrnnd
1040 mov 32,%%g1
1041 subcc %1,%2,%%g0
10421: bcs 5f
1043 addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb
1044 sub %1,%2,%1 ! this kills msb of n
1045 addx %1,%1,%1 ! so this can't give carry
1046 subcc %%g1,1,%%g1
10472: bne 1b
1048 subcc %1,%2,%%g0
1049 bcs 3f
1050 addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb
1051 b 3f
1052 sub %1,%2,%1 ! this kills msb of n
10534: sub %1,%2,%1
10545: addxcc %1,%1,%1
1055 bcc 2b
1056 subcc %%g1,1,%%g1
1057! Got carry from n. Subtract next step to cancel this carry.
1058 bne 4b
1059 addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb
1060 sub %1,%2,%1
10613: xnor %0,0,%0
1062 ! End of inline udiv_qrnnd" \
0f41302f
MS
1063 : "=&r" ((USItype) (q)), \
1064 "=&r" ((USItype) (r)) \
1065 : "r" ((USItype) (d)), \
1066 "1" ((USItype) (n1)), \
1067 "0" ((USItype) (n0)) : "%g1" __AND_CLOBBER_CC)
e1a79915 1068#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */
d9d3acb6
JW
1069#endif /* __sparclite__ */
1070#endif /* __sparc_v8__ */
d83dd29a 1071#endif /* __sparc__ */
e1a79915
RS
1072
1073#if defined (__vax__)
1074#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1075 __asm__ ("addl2 %5,%1
1076 adwc %3,%0" \
0f41302f
MS
1077 : "=g" ((USItype) (sh)), \
1078 "=&g" ((USItype) (sl)) \
1079 : "%0" ((USItype) (ah)), \
1080 "g" ((USItype) (bh)), \
1081 "%1" ((USItype) (al)), \
1082 "g" ((USItype) (bl)))
e1a79915
RS
1083#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1084 __asm__ ("subl2 %5,%1
1085 sbwc %3,%0" \
0f41302f
MS
1086 : "=g" ((USItype) (sh)), \
1087 "=&g" ((USItype) (sl)) \
1088 : "0" ((USItype) (ah)), \
1089 "g" ((USItype) (bh)), \
1090 "1" ((USItype) (al)), \
1091 "g" ((USItype) (bl)))
e1a79915
RS
1092#define umul_ppmm(xh, xl, m0, m1) \
1093 do { \
e6c5404d
TG
1094 union { \
1095 UDItype __ll; \
1096 struct {USItype __l, __h;} __i; \
1097 } __xx; \
1098 USItype __m0 = (m0), __m1 = (m1); \
e1a79915 1099 __asm__ ("emul %1,%2,$0,%0" \
e6c5404d 1100 : "=r" (__xx.__ll) \
d83dd29a
TG
1101 : "g" (__m0), \
1102 "g" (__m1)); \
e6c5404d
TG
1103 (xh) = __xx.__i.__h; \
1104 (xl) = __xx.__i.__l; \
1105 (xh) += ((((SItype) __m0 >> 31) & __m1) \
1106 + (((SItype) __m1 >> 31) & __m0)); \
e1a79915 1107 } while (0)
f71c71f1
TG
1108#define sdiv_qrnnd(q, r, n1, n0, d) \
1109 do { \
1110 union {DItype __ll; \
1111 struct {SItype __l, __h;} __i; \
1112 } __xx; \
1113 __xx.__i.__h = n1; __xx.__i.__l = n0; \
1114 __asm__ ("ediv %3,%2,%0,%1" \
1115 : "=g" (q), "=g" (r) \
451c2f82 1116 : "g" (__xx.__ll), "g" (d)); \
f71c71f1 1117 } while (0)
e1a79915
RS
1118#endif /* __vax__ */
1119
1120#endif /* __GNUC__ */
1121
1122/* If this machine has no inline assembler, use C macros. */
1123
1124#if !defined (add_ssaaaa)
1125#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1126 do { \
e6c5404d 1127 USItype __x; \
e1a79915
RS
1128 __x = (al) + (bl); \
1129 (sh) = (ah) + (bh) + (__x < (al)); \
1130 (sl) = __x; \
1131 } while (0)
1132#endif
1133
1134#if !defined (sub_ddmmss)
1135#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1136 do { \
e6c5404d 1137 USItype __x; \
e1a79915
RS
1138 __x = (al) - (bl); \
1139 (sh) = (ah) - (bh) - (__x > (al)); \
1140 (sl) = __x; \
1141 } while (0)
1142#endif
1143
1144#if !defined (umul_ppmm)
1145#define umul_ppmm(w1, w0, u, v) \
1146 do { \
e6c5404d
TG
1147 USItype __x0, __x1, __x2, __x3; \
1148 USItype __ul, __vl, __uh, __vh; \
e1a79915
RS
1149 \
1150 __ul = __ll_lowpart (u); \
1151 __uh = __ll_highpart (u); \
1152 __vl = __ll_lowpart (v); \
1153 __vh = __ll_highpart (v); \
1154 \
e6c5404d
TG
1155 __x0 = (USItype) __ul * __vl; \
1156 __x1 = (USItype) __ul * __vh; \
1157 __x2 = (USItype) __uh * __vl; \
1158 __x3 = (USItype) __uh * __vh; \
e1a79915
RS
1159 \
1160 __x1 += __ll_highpart (__x0);/* this can't give carry */ \
1161 __x1 += __x2; /* but this indeed can */ \
1162 if (__x1 < __x2) /* did we get it? */ \
1163 __x3 += __ll_B; /* yes, add it in the proper pos. */ \
1164 \
1165 (w1) = __x3 + __ll_highpart (__x1); \
1166 (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
1167 } while (0)
1168#endif
1169
1170#if !defined (__umulsidi3)
1171#define __umulsidi3(u, v) \
e6c5404d 1172 ({DIunion __w; \
e1a79915
RS
1173 umul_ppmm (__w.s.high, __w.s.low, u, v); \
1174 __w.ll; })
1175#endif
1176
d83dd29a
TG
1177/* Define this unconditionally, so it can be used for debugging. */
1178#define __udiv_qrnnd_c(q, r, n1, n0, d) \
e1a79915 1179 do { \
e6c5404d
TG
1180 USItype __d1, __d0, __q1, __q0; \
1181 USItype __r1, __r0, __m; \
e1a79915
RS
1182 __d1 = __ll_highpart (d); \
1183 __d0 = __ll_lowpart (d); \
1184 \
1185 __r1 = (n1) % __d1; \
1186 __q1 = (n1) / __d1; \
e6c5404d 1187 __m = (USItype) __q1 * __d0; \
e1a79915
RS
1188 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
1189 if (__r1 < __m) \
1190 { \
1191 __q1--, __r1 += (d); \
1192 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
1193 if (__r1 < __m) \
1194 __q1--, __r1 += (d); \
1195 } \
1196 __r1 -= __m; \
1197 \
1198 __r0 = __r1 % __d1; \
1199 __q0 = __r1 / __d1; \
e6c5404d 1200 __m = (USItype) __q0 * __d0; \
e1a79915
RS
1201 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
1202 if (__r0 < __m) \
1203 { \
1204 __q0--, __r0 += (d); \
1205 if (__r0 >= (d)) \
1206 if (__r0 < __m) \
1207 __q0--, __r0 += (d); \
1208 } \
1209 __r0 -= __m; \
1210 \
e6c5404d 1211 (q) = (USItype) __q1 * __ll_B | __q0; \
e1a79915
RS
1212 (r) = __r0; \
1213 } while (0)
1814cfd9
TG
1214
1215/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
9077d7fa 1216 __udiv_w_sdiv (defined in libgcc or elsewhere). */
1814cfd9
TG
1217#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
1218#define udiv_qrnnd(q, r, nh, nl, d) \
1219 do { \
1220 USItype __r; \
9077d7fa 1221 (q) = __udiv_w_sdiv (&__r, nh, nl, d); \
1814cfd9
TG
1222 (r) = __r; \
1223 } while (0)
1224#endif
1225
d83dd29a
TG
1226/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
1227#if !defined (udiv_qrnnd)
1228#define UDIV_NEEDS_NORMALIZATION 1
1229#define udiv_qrnnd __udiv_qrnnd_c
e1a79915
RS
1230#endif
1231
1232#if !defined (count_leading_zeros)
e6c5404d 1233extern const UQItype __clz_tab[];
e1a79915
RS
1234#define count_leading_zeros(count, x) \
1235 do { \
e6c5404d
TG
1236 USItype __xr = (x); \
1237 USItype __a; \
e1a79915 1238 \
cf7d8fd0 1239 if (SI_TYPE_SIZE <= 32) \
d83dd29a 1240 { \
7d4f2e6c
R
1241 __a = __xr < ((USItype)1<<2*__BITS4) \
1242 ? (__xr < ((USItype)1<<__BITS4) ? 0 : __BITS4) \
1243 : (__xr < ((USItype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
d83dd29a
TG
1244 } \
1245 else \
1246 { \
f4432e94 1247 for (__a = SI_TYPE_SIZE - 8; __a > 0; __a -= 8) \
d83dd29a
TG
1248 if (((__xr >> __a) & 0xff) != 0) \
1249 break; \
1250 } \
e1a79915 1251 \
cf7d8fd0 1252 (count) = SI_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
e1a79915
RS
1253 } while (0)
1254#endif
1255
1256#ifndef UDIV_NEEDS_NORMALIZATION
1257#define UDIV_NEEDS_NORMALIZATION 0
1258#endif
This page took 0.769049 seconds and 5 git commands to generate.