796ebe2d07f4715ec129d9f6b8e42ffdac7aabb6
1 /* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
2 Copyright (C) 1991,92,94,95,96,97,98,99, 2000 Free Software Foundation, Inc.
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.
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.
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
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 /* You have to define the following before including this file:
21 UWtype -- An unsigned type, default type for operations (typically a "word")
22 UHWtype -- An unsigned type, at least half the size of UWtype.
23 UDWtype -- An unsigned type, at least twice as large a UWtype
24 W_TYPE_SIZE -- size in bits of UWtype
26 UQItype -- Unsigned 8 bit type.
27 SItype, USItype -- Signed and unsigned 32 bit types.
28 DItype, UDItype -- Signed and unsigned 64 bit types.
30 On a 32 bit machine UWtype should typically be USItype;
31 on a 64 bit machine, UWtype should typically be UDItype.
34 #define __BITS4 (W_TYPE_SIZE / 4)
35 #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
36 #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
37 #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
40 #define W_TYPE_SIZE 32
41 #define UWtype USItype
42 #define UHWtype USItype
43 #define UDWtype UDItype
46 /* Define auxiliary asm macros.
48 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
49 UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
50 word product in HIGH_PROD and LOW_PROD.
52 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
53 UDWtype product. This is just a variant of umul_ppmm.
55 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
56 denominator) divides a UDWtype, composed by the UWtype integers
57 HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
58 in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
59 than DENOMINATOR for correct operation. If, in addition, the most
60 significant bit of DENOMINATOR must be 1, then the pre-processor symbol
61 UDIV_NEEDS_NORMALIZATION is defined to 1.
63 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
64 denominator). Like udiv_qrnnd but the numbers are signed. The quotient
67 5) count_leading_zeros(count, x) counts the number of zero-bits from the
68 msb to the first non-zero bit in the UWtype X. This is the number of
69 steps X needs to be shifted left to set the msb. Undefined for X == 0,
70 unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
72 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
73 from the least significant end.
75 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
76 high_addend_2, low_addend_2) adds two UWtype integers, composed by
77 HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
78 respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
79 (i.e. carry out) is not stored anywhere, and is lost.
81 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
82 high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
83 composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
84 LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
85 and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
88 If any of these macros are left undefined for a particular CPU,
91 /* The CPUs come in alphabetical order below.
93 Please add support for more CPUs here, or improve the current support
95 (E.g. WE32100, IBM360.) */
97 #if defined (__GNUC__) && !defined (NO_ASM)
99 /* We sometimes need to clobber "cc" with gcc2, but that would not be
100 understood by gcc1. Use cpp to avoid major code duplication. */
103 #define __AND_CLOBBER_CC
104 #else /* __GNUC__ >= 2 */
105 #define __CLOBBER_CC : "cc"
106 #define __AND_CLOBBER_CC , "cc"
107 #endif /* __GNUC__ < 2 */
109 #if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32
110 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
111 __asm__ ("add %1,%4,%5
113 : "=r" ((USItype) (sh)), \
114 "=&r" ((USItype) (sl)) \
115 : "%r" ((USItype) (ah)), \
116 "rI" ((USItype) (bh)), \
117 "%r" ((USItype) (al)), \
118 "rI" ((USItype) (bl)))
119 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
120 __asm__ ("sub %1,%4,%5
122 : "=r" ((USItype) (sh)), \
123 "=&r" ((USItype) (sl)) \
124 : "r" ((USItype) (ah)), \
125 "rI" ((USItype) (bh)), \
126 "r" ((USItype) (al)), \
127 "rI" ((USItype) (bl)))
128 #define umul_ppmm(xh, xl, m0, m1) \
130 USItype __m0 = (m0), __m1 = (m1); \
131 __asm__ ("multiplu %0,%1,%2" \
132 : "=r" ((USItype) (xl)) \
135 __asm__ ("multmu %0,%1,%2" \
136 : "=r" ((USItype) (xh)) \
140 #define udiv_qrnnd(q, r, n1, n0, d) \
141 __asm__ ("dividu %0,%3,%4" \
142 : "=r" ((USItype) (q)), \
143 "=q" ((USItype) (r)) \
144 : "1" ((USItype) (n1)), \
145 "r" ((USItype) (n0)), \
147 #define count_leading_zeros(count, x) \
148 __asm__ ("clz %0,%1" \
149 : "=r" ((USItype) (count)) \
150 : "r" ((USItype) (x)))
151 #define COUNT_LEADING_ZEROS_0 32
152 #endif /* __a29k__ */
154 #if defined (__alpha) && W_TYPE_SIZE == 64
155 #define umul_ppmm(ph, pl, m0, m1) \
157 UDItype __m0 = (m0), __m1 = (m1); \
158 __asm__ ("umulh %r1,%2,%0" \
159 : "=r" ((UDItype) ph) \
162 (pl) = __m0 * __m1; \
165 #ifndef LONGLONG_STANDALONE
166 #define udiv_qrnnd(q, r, n1, n0, d) \
168 (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
171 extern UDItype __udiv_qrnnd
__P ((UDItype
*, UDItype
, UDItype
, UDItype
));
172 #define UDIV_TIME 220
173 #endif /* LONGLONG_STANDALONE */
176 #if defined (__arc__) && W_TYPE_SIZE == 32
177 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
178 __asm__ ("add.f %1, %4, %5
180 : "=r" ((USItype) (sh)), \
181 "=&r" ((USItype) (sl)) \
182 : "%r" ((USItype) (ah)), \
183 "rIJ" ((USItype) (bh)), \
184 "%r" ((USItype) (al)), \
185 "rIJ" ((USItype) (bl)))
186 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
187 __asm__ ("sub.f %1, %4, %5
189 : "=r" ((USItype) (sh)), \
190 "=&r" ((USItype) (sl)) \
191 : "r" ((USItype) (ah)), \
192 "rIJ" ((USItype) (bh)), \
193 "r" ((USItype) (al)), \
194 "rIJ" ((USItype) (bl)))
195 /* Call libgcc1 routine. */
196 #define umul_ppmm(w1, w0, u, v) \
199 __w.ll = __umulsidi3 (u, v); \
203 #define __umulsidi3 __umulsidi3
204 UDItype
__umulsidi3 (USItype
, USItype
);
207 #if defined (__arm__) && W_TYPE_SIZE == 32
208 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
209 __asm__ ("adds %1, %4, %5
211 : "=r" ((USItype) (sh)), \
212 "=&r" ((USItype) (sl)) \
213 : "%r" ((USItype) (ah)), \
214 "rI" ((USItype) (bh)), \
215 "%r" ((USItype) (al)), \
216 "rI" ((USItype) (bl)))
217 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
218 __asm__ ("subs %1, %4, %5
220 : "=r" ((USItype) (sh)), \
221 "=&r" ((USItype) (sl)) \
222 : "r" ((USItype) (ah)), \
223 "rI" ((USItype) (bh)), \
224 "r" ((USItype) (al)), \
225 "rI" ((USItype) (bl)))
226 #define umul_ppmm(xh, xl, a, b) \
227 {register USItype __t0, __t1, __t2; \
228 __asm__ ("%@ Inlined umul_ppmm
231 bic %3, %5, %2, lsl #16
232 bic %4, %6, %0, lsl #16
239 adds %1, %1, %3, lsl #16
240 adc %0, %0, %3, lsr #16" \
241 : "=&r" ((USItype) (xh)), \
242 "=r" ((USItype) (xl)), \
243 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
244 : "r" ((USItype) (a)), \
245 "r" ((USItype) (b)));}
247 #define UDIV_TIME 100
250 #if defined (__clipper__) && W_TYPE_SIZE == 32
251 #define umul_ppmm(w1, w0, u, v) \
252 ({union {UDItype __ll; \
253 struct {USItype __l, __h;} __i; \
255 __asm__ ("mulwux %2,%0" \
257 : "%0" ((USItype) (u)), \
258 "r" ((USItype) (v))); \
259 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
260 #define smul_ppmm(w1, w0, u, v) \
261 ({union {DItype __ll; \
262 struct {SItype __l, __h;} __i; \
264 __asm__ ("mulwx %2,%0" \
266 : "%0" ((SItype) (u)), \
267 "r" ((SItype) (v))); \
268 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
269 #define __umulsidi3(u, v) \
271 __asm__ ("mulwux %2,%0" \
273 : "%0" ((USItype) (u)), \
274 "r" ((USItype) (v))); \
276 #endif /* __clipper__ */
278 #if defined (__gmicro__) && W_TYPE_SIZE == 32
279 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
280 __asm__ ("add.w %5,%1
282 : "=g" ((USItype) (sh)), \
283 "=&g" ((USItype) (sl)) \
284 : "%0" ((USItype) (ah)), \
285 "g" ((USItype) (bh)), \
286 "%1" ((USItype) (al)), \
287 "g" ((USItype) (bl)))
288 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
289 __asm__ ("sub.w %5,%1
291 : "=g" ((USItype) (sh)), \
292 "=&g" ((USItype) (sl)) \
293 : "0" ((USItype) (ah)), \
294 "g" ((USItype) (bh)), \
295 "1" ((USItype) (al)), \
296 "g" ((USItype) (bl)))
297 #define umul_ppmm(ph, pl, m0, m1) \
298 __asm__ ("mulx %3,%0,%1" \
299 : "=g" ((USItype) (ph)), \
300 "=r" ((USItype) (pl)) \
301 : "%0" ((USItype) (m0)), \
302 "g" ((USItype) (m1)))
303 #define udiv_qrnnd(q, r, nh, nl, d) \
304 __asm__ ("divx %4,%0,%1" \
305 : "=g" ((USItype) (q)), \
306 "=r" ((USItype) (r)) \
307 : "1" ((USItype) (nh)), \
308 "0" ((USItype) (nl)), \
310 #define count_leading_zeros(count, x) \
311 __asm__ ("bsch/1 %1,%0" \
313 : "g" ((USItype) (x)), \
317 #if defined (__hppa) && W_TYPE_SIZE == 32
318 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
319 __asm__ ("add %4,%5,%1
321 : "=r" ((USItype) (sh)), \
322 "=&r" ((USItype) (sl)) \
323 : "%rM" ((USItype) (ah)), \
324 "rM" ((USItype) (bh)), \
325 "%rM" ((USItype) (al)), \
326 "rM" ((USItype) (bl)))
327 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
328 __asm__ ("sub %4,%5,%1
330 : "=r" ((USItype) (sh)), \
331 "=&r" ((USItype) (sl)) \
332 : "rM" ((USItype) (ah)), \
333 "rM" ((USItype) (bh)), \
334 "rM" ((USItype) (al)), \
335 "rM" ((USItype) (bl)))
336 #if defined (_PA_RISC1_1)
337 #define umul_ppmm(w1, w0, u, v) \
342 struct {USItype __w1, __w0;} __w1w0; \
344 __asm__ ("xmpyu %1,%2,%0" \
346 : "x" ((USItype) (u)), \
347 "x" ((USItype) (v))); \
348 (w1) = __t.__w1w0.__w1; \
349 (w0) = __t.__w1w0.__w0; \
356 #define count_leading_zeros(count, x) \
361 extru,= %1,15,16,%%r0 ; Bits 31..16 zero?
362 extru,tr %1,15,16,%1 ; No. Shift down, skip add.
363 ldo 16(%0),%0 ; Yes. Perform add.
364 extru,= %1,23,8,%%r0 ; Bits 15..8 zero?
365 extru,tr %1,23,8,%1 ; No. Shift down, skip add.
366 ldo 8(%0),%0 ; Yes. Perform add.
367 extru,= %1,27,4,%%r0 ; Bits 7..4 zero?
368 extru,tr %1,27,4,%1 ; No. Shift down, skip add.
369 ldo 4(%0),%0 ; Yes. Perform add.
370 extru,= %1,29,2,%%r0 ; Bits 3..2 zero?
371 extru,tr %1,29,2,%1 ; No. Shift down, skip add.
372 ldo 2(%0),%0 ; Yes. Perform add.
373 extru %1,30,1,%1 ; Extract bit 1.
374 sub %0,%1,%0 ; Subtract it.
375 " : "=r" (count), "=r" (__tmp) : "1" (x)); \
379 #if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
380 #define umul_ppmm(xh, xl, m0, m1) \
382 union {UDItype __ll; \
383 struct {USItype __h, __l;} __i; \
385 USItype __m0 = (m0), __m1 = (m1); \
386 __asm__ ("mr %0,%3" \
387 : "=r" (__xx.__i.__h), \
388 "=r" (__xx.__i.__l) \
391 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
392 (xh) += ((((SItype) __m0 >> 31) & __m1) \
393 + (((SItype) __m1 >> 31) & __m0)); \
395 #define smul_ppmm(xh, xl, m0, m1) \
397 union {DItype __ll; \
398 struct {USItype __h, __l;} __i; \
400 __asm__ ("mr %0,%3" \
401 : "=r" (__xx.__i.__h), \
402 "=r" (__xx.__i.__l) \
405 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
407 #define sdiv_qrnnd(q, r, n1, n0, d) \
409 union {DItype __ll; \
410 struct {USItype __h, __l;} __i; \
412 __xx.__i.__h = n1; __xx.__i.__l = n0; \
413 __asm__ ("dr %0,%2" \
415 : "0" (__xx.__ll), "r" (d)); \
416 (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
420 #if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
421 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
424 : "=r" ((USItype) (sh)), \
425 "=&r" ((USItype) (sl)) \
426 : "%0" ((USItype) (ah)), \
427 "g" ((USItype) (bh)), \
428 "%1" ((USItype) (al)), \
429 "g" ((USItype) (bl)))
430 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
433 : "=r" ((USItype) (sh)), \
434 "=&r" ((USItype) (sl)) \
435 : "0" ((USItype) (ah)), \
436 "g" ((USItype) (bh)), \
437 "1" ((USItype) (al)), \
438 "g" ((USItype) (bl)))
439 #define umul_ppmm(w1, w0, u, v) \
441 : "=a" ((USItype) (w0)), \
442 "=d" ((USItype) (w1)) \
443 : "%0" ((USItype) (u)), \
444 "rm" ((USItype) (v)))
445 #define udiv_qrnnd(q, r, n1, n0, dv) \
447 : "=a" ((USItype) (q)), \
448 "=d" ((USItype) (r)) \
449 : "0" ((USItype) (n0)), \
450 "1" ((USItype) (n1)), \
451 "rm" ((USItype) (dv)))
452 #define count_leading_zeros(count, x) \
455 __asm__ ("bsrl %1,%0" \
456 : "=r" (__cbtmp) : "rm" ((USItype) (x))); \
457 (count) = __cbtmp ^ 31; \
459 #define count_trailing_zeros(count, x) \
460 __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
465 #if defined (__i860__) && W_TYPE_SIZE == 32
467 /* Make sure these patterns really improve the code before
468 switching them on. */
469 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
474 struct {USItype __l, __h;} __i; \
476 __a.__i.__l = (al); \
477 __a.__i.__h = (ah); \
478 __b.__i.__l = (bl); \
479 __b.__i.__h = (bh); \
480 __asm__ ("fiadd.dd %1,%2,%0" \
482 : "%f" (__a.__ll), "f" (__b.__ll)); \
483 (sh) = __s.__i.__h; \
484 (sl) = __s.__i.__l; \
486 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
491 struct {USItype __l, __h;} __i; \
493 __a.__i.__l = (al); \
494 __a.__i.__h = (ah); \
495 __b.__i.__l = (bl); \
496 __b.__i.__h = (bh); \
497 __asm__ ("fisub.dd %1,%2,%0" \
499 : "%f" (__a.__ll), "f" (__b.__ll)); \
500 (sh) = __s.__i.__h; \
501 (sl) = __s.__i.__l; \
504 #endif /* __i860__ */
506 #if defined (__i960__) && W_TYPE_SIZE == 32
507 #define umul_ppmm(w1, w0, u, v) \
508 ({union {UDItype __ll; \
509 struct {USItype __l, __h;} __i; \
511 __asm__ ("emul %2,%1,%0" \
513 : "%dI" ((USItype) (u)), \
514 "dI" ((USItype) (v))); \
515 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
516 #define __umulsidi3(u, v) \
518 __asm__ ("emul %2,%1,%0" \
520 : "%dI" ((USItype) (u)), \
521 "dI" ((USItype) (v))); \
523 #endif /* __i960__ */
525 #if defined (__M32R__) && W_TYPE_SIZE == 32
526 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
527 /* The cmp clears the condition bit. */ \
531 : "=r" ((USItype) (sh)), \
532 "=&r" ((USItype) (sl)) \
533 : "%0" ((USItype) (ah)), \
534 "r" ((USItype) (bh)), \
535 "%1" ((USItype) (al)), \
536 "r" ((USItype) (bl)) \
538 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
539 /* The cmp clears the condition bit. */ \
543 : "=r" ((USItype) (sh)), \
544 "=&r" ((USItype) (sl)) \
545 : "0" ((USItype) (ah)), \
546 "r" ((USItype) (bh)), \
547 "1" ((USItype) (al)), \
548 "r" ((USItype) (bl)) \
550 #endif /* __M32R__ */
552 #if defined (__mc68000__) && W_TYPE_SIZE == 32
553 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
554 __asm__ ("add%.l %5,%1
556 : "=d" ((USItype) (sh)), \
557 "=&d" ((USItype) (sl)) \
558 : "%0" ((USItype) (ah)), \
559 "d" ((USItype) (bh)), \
560 "%1" ((USItype) (al)), \
561 "g" ((USItype) (bl)))
562 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
563 __asm__ ("sub%.l %5,%1
565 : "=d" ((USItype) (sh)), \
566 "=&d" ((USItype) (sl)) \
567 : "0" ((USItype) (ah)), \
568 "d" ((USItype) (bh)), \
569 "1" ((USItype) (al)), \
570 "g" ((USItype) (bl)))
572 /* The '020, '030, '040 and CPU32 have 32x32->64 and 64/32->32q-32r. */
573 #if defined (__mc68020__) || defined(mc68020) \
574 || defined(__mc68030__) || defined(mc68030) \
575 || defined(__mc68040__) || defined(mc68040) \
576 || defined(__mcpu32__) || defined(mcpu32) \
578 #define umul_ppmm(w1, w0, u, v) \
579 __asm__ ("mulu%.l %3,%1:%0" \
580 : "=d" ((USItype) (w0)), \
581 "=d" ((USItype) (w1)) \
582 : "%0" ((USItype) (u)), \
583 "dmi" ((USItype) (v)))
585 #define udiv_qrnnd(q, r, n1, n0, d) \
586 __asm__ ("divu%.l %4,%1:%0" \
587 : "=d" ((USItype) (q)), \
588 "=d" ((USItype) (r)) \
589 : "0" ((USItype) (n0)), \
590 "1" ((USItype) (n1)), \
591 "dmi" ((USItype) (d)))
593 #define sdiv_qrnnd(q, r, n1, n0, d) \
594 __asm__ ("divs%.l %4,%1:%0" \
595 : "=d" ((USItype) (q)), \
596 "=d" ((USItype) (r)) \
597 : "0" ((USItype) (n0)), \
598 "1" ((USItype) (n1)), \
599 "dmi" ((USItype) (d)))
601 #else /* not mc68020 */
602 #if !defined(__mcf5200__)
603 /* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */
604 #define umul_ppmm(xh, xl, a, b) \
605 __asm__ ("| Inlined umul_ppmm
631 : "=g" ((USItype) (xh)), \
632 "=g" ((USItype) (xl)) \
633 : "g" ((USItype) (a)), \
634 "g" ((USItype) (b)) \
635 : "d0", "d1", "d2", "d3", "d4")
636 #define UMUL_TIME 100
637 #define UDIV_TIME 400
638 #endif /* not mcf5200 */
639 #endif /* not mc68020 */
641 /* The '020, '030, '040 and '060 have bitfield insns. */
642 #if defined (__mc68020__) || defined(mc68020) \
643 || defined(__mc68030__) || defined(mc68030) \
644 || defined(__mc68040__) || defined(mc68040) \
645 || defined(__mc68060__) || defined(mc68060) \
647 #define count_leading_zeros(count, x) \
648 __asm__ ("bfffo %1{%b2:%b2},%0" \
649 : "=d" ((USItype) (count)) \
650 : "od" ((USItype) (x)), "n" (0))
654 #if defined (__m88000__) && W_TYPE_SIZE == 32
655 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
656 __asm__ ("addu.co %1,%r4,%r5
657 addu.ci %0,%r2,%r3" \
658 : "=r" ((USItype) (sh)), \
659 "=&r" ((USItype) (sl)) \
660 : "%rJ" ((USItype) (ah)), \
661 "rJ" ((USItype) (bh)), \
662 "%rJ" ((USItype) (al)), \
663 "rJ" ((USItype) (bl)))
664 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
665 __asm__ ("subu.co %1,%r4,%r5
666 subu.ci %0,%r2,%r3" \
667 : "=r" ((USItype) (sh)), \
668 "=&r" ((USItype) (sl)) \
669 : "rJ" ((USItype) (ah)), \
670 "rJ" ((USItype) (bh)), \
671 "rJ" ((USItype) (al)), \
672 "rJ" ((USItype) (bl)))
673 #define count_leading_zeros(count, x) \
676 __asm__ ("ff1 %0,%1" \
678 : "r" ((USItype) (x))); \
679 (count) = __cbtmp ^ 31; \
681 #define COUNT_LEADING_ZEROS_0 63 /* sic */
682 #if defined (__mc88110__)
683 #define umul_ppmm(wh, wl, u, v) \
685 union {UDItype __ll; \
686 struct {USItype __h, __l;} __i; \
688 __asm__ ("mulu.d %0,%1,%2" \
690 : "r" ((USItype) (u)), \
691 "r" ((USItype) (v))); \
692 (wh) = __xx.__i.__h; \
693 (wl) = __xx.__i.__l; \
695 #define udiv_qrnnd(q, r, n1, n0, d) \
696 ({union {UDItype __ll; \
697 struct {USItype __h, __l;} __i; \
700 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
701 __asm__ ("divu.d %0,%1,%2" \
704 "r" ((USItype) (d))); \
705 (r) = (n0) - __q * (d); (q) = __q; })
710 #define UDIV_TIME 150
711 #endif /* __mc88110__ */
712 #endif /* __m88000__ */
714 #if defined (__mips__) && W_TYPE_SIZE == 32
715 #define umul_ppmm(w1, w0, u, v) \
716 __asm__ ("multu %2,%3" \
717 : "=l" ((USItype) (w0)), \
718 "=h" ((USItype) (w1)) \
719 : "d" ((USItype) (u)), \
722 #define UDIV_TIME 100
723 #endif /* __mips__ */
725 #if defined (__ns32000__) && W_TYPE_SIZE == 32
726 #define umul_ppmm(w1, w0, u, v) \
727 ({union {UDItype __ll; \
728 struct {USItype __l, __h;} __i; \
730 __asm__ ("meid %2,%0" \
732 : "%0" ((USItype) (u)), \
733 "g" ((USItype) (v))); \
734 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
735 #define __umulsidi3(u, v) \
737 __asm__ ("meid %2,%0" \
739 : "%0" ((USItype) (u)), \
740 "g" ((USItype) (v))); \
742 #define udiv_qrnnd(q, r, n1, n0, d) \
743 ({union {UDItype __ll; \
744 struct {USItype __l, __h;} __i; \
746 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
747 __asm__ ("deid %2,%0" \
750 "g" ((USItype) (d))); \
751 (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
752 #define count_trailing_zeros(count,x) \
754 __asm__ ("ffsd %2,%0" \
755 : "=r" ((USItype
) (count
)) \
756 : "0" ((USItype
) 0), \
757 "r" ((USItype
) (x
))); \
759 #endif /* __ns32000__ */
761 #if (defined (_ARCH_PPC) || defined (_IBMR2))
762 #if W_TYPE_SIZE == 32
763 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
765 if (__builtin_constant_p (bh) && (bh) == 0) \
766 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
767 : "=r" ((USItype) (sh)), \
768 "=&r" ((USItype) (sl)) \
769 : "%r" ((USItype) (ah)), \
770 "%r" ((USItype) (al)), \
771 "rI" ((USItype) (bl))); \
772 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
773 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
774 : "=r" ((USItype) (sh)), \
775 "=&r" ((USItype) (sl)) \
776 : "%r" ((USItype) (ah)), \
777 "%r" ((USItype) (al)), \
778 "rI" ((USItype) (bl))); \
780 __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
781 : "=r" ((USItype) (sh)), \
782 "=&r" ((USItype) (sl)) \
783 : "%r" ((USItype) (ah)), \
784 "r" ((USItype) (bh)), \
785 "%r" ((USItype) (al)), \
786 "rI" ((USItype) (bl))); \
788 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
790 if (__builtin_constant_p (ah) && (ah) == 0) \
791 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
792 : "=r" ((USItype) (sh)), \
793 "=&r" ((USItype) (sl)) \
794 : "r" ((USItype) (bh)), \
795 "rI" ((USItype) (al)), \
796 "r" ((USItype) (bl))); \
797 else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \
798 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
799 : "=r" ((USItype) (sh)), \
800 "=&r" ((USItype) (sl)) \
801 : "r" ((USItype) (bh)), \
802 "rI" ((USItype) (al)), \
803 "r" ((USItype) (bl))); \
804 else if (__builtin_constant_p (bh) && (bh) == 0) \
805 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
806 : "=r" ((USItype) (sh)), \
807 "=&r" ((USItype) (sl)) \
808 : "r" ((USItype) (ah)), \
809 "rI" ((USItype) (al)), \
810 "r" ((USItype) (bl))); \
811 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
812 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
813 : "=r" ((USItype) (sh)), \
814 "=&r" ((USItype) (sl)) \
815 : "r" ((USItype) (ah)), \
816 "rI" ((USItype) (al)), \
817 "r" ((USItype) (bl))); \
819 __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
820 : "=r" ((USItype) (sh)), \
821 "=&r" ((USItype) (sl)) \
822 : "r" ((USItype) (ah)), \
823 "r" ((USItype) (bh)), \
824 "rI" ((USItype) (al)), \
825 "r" ((USItype) (bl))); \
827 #endif /* W_TYPE_SIZE */
828 #define count_leading_zeros(count, x) \
829 __asm__ ("{cntlz|cntlzw} %0,%1" \
830 : "=r" ((USItype) (count)) \
831 : "r" ((USItype) (x)))
832 #define COUNT_LEADING_ZEROS_0 32
833 #if defined (_ARCH_PPC)
834 #define umul_ppmm(ph, pl, m0, m1) \
836 USItype __m0 = (m0), __m1 = (m1); \
837 __asm__ ("mulhwu %0,%1,%2" \
838 : "=r" ((USItype) ph) \
841 (pl) = __m0 * __m1; \
844 #define smul_ppmm(ph, pl, m0, m1) \
846 SItype __m0 = (m0), __m1 = (m1); \
847 __asm__ ("mulhw %0,%1,%2" \
848 : "=r" ((SItype) ph) \
851 (pl) = __m0 * __m1; \
854 #define UDIV_TIME 120
855 #elif defined (_ARCH_POWER)
856 #define umul_ppmm(xh, xl, m0, m1) \
858 USItype __m0 = (m0), __m1 = (m1); \
859 __asm__ ("mul %0,%2,%3" \
860 : "=r" ((USItype) (xh)), \
861 "=q" ((USItype) (xl)) \
864 (xh) += ((((SItype) __m0 >> 31) & __m1) \
865 + (((SItype) __m1 >> 31) & __m0)); \
868 #define smul_ppmm(xh, xl, m0, m1) \
869 __asm__ ("mul %0,%2,%3" \
870 : "=r" ((SItype) (xh)), \
871 "=q" ((SItype) (xl)) \
875 #define sdiv_qrnnd(q, r, nh, nl, d) \
876 __asm__ ("div %0,%2,%4" \
877 : "=r" ((SItype) (q)), "=q" ((SItype) (r)) \
878 : "r" ((SItype) (nh)), "1" ((SItype) (nl)), "r" ((SItype) (d)))
879 #define UDIV_TIME 100
881 #endif /* Power architecture variants. */
883 #if defined (__pyr__) && W_TYPE_SIZE == 32
884 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
887 : "=r" ((USItype) (sh)), \
888 "=&r" ((USItype) (sl)) \
889 : "%0" ((USItype) (ah)), \
890 "g" ((USItype) (bh)), \
891 "%1" ((USItype) (al)), \
892 "g" ((USItype) (bl)))
893 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
896 : "=r" ((USItype) (sh)), \
897 "=&r" ((USItype) (sl)) \
898 : "0" ((USItype) (ah)), \
899 "g" ((USItype) (bh)), \
900 "1" ((USItype) (al)), \
901 "g" ((USItype) (bl)))
902 /* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */
903 #define umul_ppmm(w1, w0, u, v) \
904 ({union {UDItype __ll; \
905 struct {USItype __h, __l;} __i; \
907 __asm__ ("movw %1,%R0
909 : "=&r" (__xx.__ll) \
910 : "g" ((USItype) (u)), \
911 "g" ((USItype) (v))); \
912 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
915 #if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
916 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
919 : "=r" ((USItype) (sh)), \
920 "=&r" ((USItype) (sl)) \
921 : "%0" ((USItype) (ah)), \
922 "r" ((USItype) (bh)), \
923 "%1" ((USItype) (al)), \
924 "r" ((USItype) (bl)))
925 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
928 : "=r" ((USItype) (sh)), \
929 "=&r" ((USItype) (sl)) \
930 : "0" ((USItype) (ah)), \
931 "r" ((USItype) (bh)), \
932 "1" ((USItype) (al)), \
933 "r" ((USItype) (bl)))
934 #define umul_ppmm(ph, pl, m0, m1) \
936 USItype __m0 = (m0), __m1 = (m1); \
958 : "=r" ((USItype) (ph)), \
959 "=r" ((USItype) (pl)) \
963 (ph) += ((((SItype) __m0 >> 31) & __m1) \
964 + (((SItype) __m1 >> 31) & __m0)); \
967 #define UDIV_TIME 200
968 #define count_leading_zeros(count, x) \
970 if ((x) >= 0x10000) \
971 __asm__ ("clz %0,%1" \
972 : "=r" ((USItype) (count)) \
973 : "r" ((USItype) (x) >> 16)); \
976 __asm__ ("clz %0,%1" \
977 : "=r" ((USItype) (count)) \
978 : "r" ((USItype) (x))); \
984 #if defined (__sh2__) && W_TYPE_SIZE == 32
985 #define umul_ppmm(w1, w0, u, v) \
990 : "=r" ((USItype)(w1)), \
991 "=r" ((USItype)(w0)) \
992 : "r" ((USItype)(u)), \
998 #if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
1000 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1001 __asm__ ("addcc %r4,%5,%1
1003 : "=r" ((USItype) (sh)), \
1004 "=&r" ((USItype) (sl)) \
1005 : "%rJ" ((USItype) (ah)), \
1006 "rI" ((USItype) (bh)), \
1007 "%rJ" ((USItype) (al)), \
1008 "rI" ((USItype) (bl)) \
1010 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1011 __asm__ ("subcc %r4,%5,%1
1013 : "=r" ((USItype) (sh)), \
1014 "=&r" ((USItype) (sl)) \
1015 : "rJ" ((USItype) (ah)), \
1016 "rI" ((USItype) (bh)), \
1017 "rJ" ((USItype) (al)), \
1018 "rI" ((USItype) (bl)) \
1020 #if defined (__sparc_v8__)
1021 #define umul_ppmm(w1, w0, u, v) \
1022 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
1023 : "=r" ((USItype) (w1)), \
1024 "=r" ((USItype) (w0)) \
1025 : "r" ((USItype) (u)), \
1026 "r" ((USItype) (v)))
1027 #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
1028 __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
1029 : "=&r" ((USItype) (__q)), \
1030 "=&r" ((USItype) (__r)) \
1031 : "r" ((USItype) (__n1)), \
1032 "r" ((USItype) (__n0)), \
1033 "r" ((USItype) (__d)))
1035 #if defined (__sparclite__)
1036 /* This has hardware multiply but not divide. It also has two additional
1037 instructions scan (ffs from high bit) and divscc. */
1038 #define umul_ppmm(w1, w0, u, v) \
1039 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
1040 : "=r" ((USItype) (w1)), \
1041 "=r" ((USItype) (w0)) \
1042 : "r" ((USItype) (u)), \
1043 "r" ((USItype) (v)))
1044 #define udiv_qrnnd(q, r, n1, n0, d) \
1045 __asm__ ("! Inlined udiv_qrnnd
1046 wr %%g0,%2,%%y ! Not a delayed write for sparclite
1083 1: ! End of inline udiv_qrnnd" \
1084 : "=r" ((USItype) (q)), \
1085 "=r" ((USItype) (r)) \
1086 : "r" ((USItype) (n1)), \
1087 "r" ((USItype) (n0)), \
1088 "rI" ((USItype) (d)) \
1089 : "g1" __AND_CLOBBER_CC)
1090 #define UDIV_TIME 37
1091 #define count_leading_zeros(count, x) \
1093 __asm__ ("scan %1,1,%0" \
1094 : "=r" ((USItype) (count)) \
1095 : "r" ((USItype) (x))); \
1097 /* Early sparclites return 63 for an argument of 0, but they warn that future
1098 implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
1101 /* SPARC without integer multiplication and divide instructions.
1102 (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
1103 #define umul_ppmm(w1, w0, u, v) \
1104 __asm__ ("! Inlined umul_ppmm
1105 wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr
1106 sra %3,31,%%o5 ! Don't move this insn
1107 and %2,%%o5,%%o5 ! Don't move this insn
1108 andcc %%g0,0,%%g1 ! Don't move this insn
1144 : "=r" ((USItype) (w1)), \
1145 "=r" ((USItype) (w0)) \
1146 : "%rI" ((USItype) (u)), \
1147 "r" ((USItype) (v)) \
1148 : "g1", "o5" __AND_CLOBBER_CC)
1149 #define UMUL_TIME 39 /* 39 instructions */
1150 /* It's quite necessary to add this much assembler for the sparc.
1151 The default udiv_qrnnd (in C) is more than 10 times slower! */
1152 #define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
1153 __asm__ ("! Inlined udiv_qrnnd
1157 addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb
1158 sub %1,%2,%1 ! this kills msb of n
1159 addx %1,%1,%1 ! so this can't give carry
1164 addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb
1166 sub %1,%2,%1 ! this kills msb of n
1171 ! Got carry from n. Subtract next step to cancel this carry.
1173 addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb
1176 ! End of inline udiv_qrnnd" \
1177 : "=&r" ((USItype) (__q)), \
1178 "=&r" ((USItype) (__r)) \
1179 : "r" ((USItype) (__d)), \
1180 "1" ((USItype) (__n1)), \
1181 "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
1182 #define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */
1183 #endif /* __sparclite__ */
1184 #endif /* __sparc_v8__ */
1185 #endif /* sparc32 */
1187 #if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \
1188 && W_TYPE_SIZE == 64
1189 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1190 __asm__ ("addcc %r4,%5,%1
1195 : "=r" ((UDItype)(sh)), \
1196 "=&r" ((UDItype)(sl)) \
1197 : "%rJ" ((UDItype)(ah)), \
1198 "rI" ((UDItype)(bh)), \
1199 "%rJ" ((UDItype)(al)), \
1200 "rI" ((UDItype)(bl)) \
1203 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1204 __asm__ ("subcc %r4,%5,%1
1209 : "=r" ((UDItype)(sh)), \
1210 "=&r" ((UDItype)(sl)) \
1211 : "rJ" ((UDItype)(ah)), \
1212 "rI" ((UDItype)(bh)), \
1213 "rJ" ((UDItype)(al)), \
1214 "rI" ((UDItype)(bl)) \
1217 #define umul_ppmm(wh, wl, u, v) \
1219 UDItype tmp1, tmp2, tmp3, tmp4; \
1220 __asm__ __volatile__ ( \
1233 sethi %%hi(0x80000000),%2
1242 : "=r" ((UDItype)(wh)), \
1243 "=&r" ((UDItype)(wl)), \
1244 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
1245 : "r" ((UDItype)(u)), \
1246 "r" ((UDItype)(v)) \
1249 #define UMUL_TIME 96
1250 #define UDIV_TIME 230
1251 #endif /* sparc64 */
1253 #if defined (__vax__) && W_TYPE_SIZE == 32
1254 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1255 __asm__ ("addl2 %5,%1
1257 : "=g" ((USItype) (sh)), \
1258 "=&g" ((USItype) (sl)) \
1259 : "%0" ((USItype) (ah)), \
1260 "g" ((USItype) (bh)), \
1261 "%1" ((USItype) (al)), \
1262 "g" ((USItype) (bl)))
1263 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1264 __asm__ ("subl2 %5,%1
1266 : "=g" ((USItype) (sh)), \
1267 "=&g" ((USItype) (sl)) \
1268 : "0" ((USItype) (ah)), \
1269 "g" ((USItype) (bh)), \
1270 "1" ((USItype) (al)), \
1271 "g" ((USItype) (bl)))
1272 #define umul_ppmm(xh, xl, m0, m1) \
1276 struct {USItype __l, __h;} __i; \
1278 USItype __m0 = (m0), __m1 = (m1); \
1279 __asm__ ("emul %1,%2,$0,%0" \
1280 : "=r" (__xx.__ll) \
1283 (xh) = __xx.__i.__h; \
1284 (xl) = __xx.__i.__l; \
1285 (xh) += ((((SItype) __m0 >> 31) & __m1) \
1286 + (((SItype) __m1 >> 31) & __m0)); \
1288 #define sdiv_qrnnd(q, r, n1, n0, d) \
1290 union {DItype __ll; \
1291 struct {SItype __l, __h;} __i; \
1293 __xx.__i.__h = n1; __xx.__i.__l = n0; \
1294 __asm__ ("ediv %3,%2,%0,%1" \
1295 : "=g" (q), "=g" (r) \
1296 : "g" (__xx.__ll), "g" (d)); \
1298 #endif /* __vax__ */
1300 #if defined (__z8000__) && W_TYPE_SIZE == 16
1301 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1302 __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
1303 : "=r" ((unsigned int)(sh)), \
1304 "=&r" ((unsigned int)(sl)) \
1305 : "%0" ((unsigned int)(ah)), \
1306 "r" ((unsigned int)(bh)), \
1307 "%1" ((unsigned int)(al)), \
1308 "rQR" ((unsigned int)(bl)))
1309 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1310 __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
1311 : "=r" ((unsigned int)(sh)), \
1312 "=&r" ((unsigned int)(sl)) \
1313 : "0" ((unsigned int)(ah)), \
1314 "r" ((unsigned int)(bh)), \
1315 "1" ((unsigned int)(al)), \
1316 "rQR" ((unsigned int)(bl)))
1317 #define umul_ppmm(xh, xl, m0, m1) \
1319 union {long int __ll; \
1320 struct {unsigned int __h, __l;} __i; \
1322 unsigned int __m0 = (m0), __m1 = (m1); \
1323 __asm__ ("mult %S0,%H3" \
1324 : "=r" (__xx.__i.__h), \
1325 "=r" (__xx.__i.__l) \
1328 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
1329 (xh) += ((((signed int) __m0 >> 15) & __m1) \
1330 + (((signed int) __m1 >> 15) & __m0)); \
1332 #endif /* __z8000__ */
1334 #endif /* __GNUC__ */
1336 /* If this machine has no inline assembler, use C macros. */
1338 #if !defined (add_ssaaaa)
1339 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1342 __x = (al) + (bl); \
1343 (sh) = (ah) + (bh) + (__x < (al)); \
1348 #if !defined (sub_ddmmss)
1349 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1352 __x = (al) - (bl); \
1353 (sh) = (ah) - (bh) - (__x > (al)); \
1358 #if !defined (umul_ppmm)
1359 #define umul_ppmm(w1, w0, u, v) \
1361 UWtype __x0, __x1, __x2, __x3; \
1362 UHWtype __ul, __vl, __uh, __vh; \
1364 __ul = __ll_lowpart (u); \
1365 __uh = __ll_highpart (u); \
1366 __vl = __ll_lowpart (v); \
1367 __vh = __ll_highpart (v); \
1369 __x0 = (UWtype) __ul * __vl; \
1370 __x1 = (UWtype) __ul * __vh; \
1371 __x2 = (UWtype) __uh * __vl; \
1372 __x3 = (UWtype) __uh * __vh; \
1374 __x1 += __ll_highpart (__x0);/* this can't give carry */ \
1375 __x1 += __x2; /* but this indeed can */ \
1376 if (__x1 < __x2) /* did we get it? */ \
1377 __x3 += __ll_B; /* yes, add it in the proper pos. */ \
1379 (w1) = __x3 + __ll_highpart (__x1); \
1380 (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
1384 #if !defined (__umulsidi3)
1385 #define __umulsidi3(u, v) \
1387 umul_ppmm (__w.s.high, __w.s.low, u, v); \
1391 /* Define this unconditionally, so it can be used for debugging. */
1392 #define __udiv_qrnnd_c(q, r, n1, n0, d) \
1394 UWtype __d1, __d0, __q1, __q0; \
1395 UWtype __r1, __r0, __m; \
1396 __d1 = __ll_highpart (d); \
1397 __d0 = __ll_lowpart (d); \
1399 __r1 = (n1) % __d1; \
1400 __q1 = (n1) / __d1; \
1401 __m = (UWtype) __q1 * __d0; \
1402 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
1405 __q1--, __r1 += (d); \
1406 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
1408 __q1--, __r1 += (d); \
1412 __r0 = __r1 % __d1; \
1413 __q0 = __r1 / __d1; \
1414 __m = (UWtype) __q0 * __d0; \
1415 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
1418 __q0--, __r0 += (d); \
1421 __q0--, __r0 += (d); \
1425 (q) = (UWtype) __q1 * __ll_B | __q0; \
1429 /* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
1430 __udiv_w_sdiv (defined in libgcc or elsewhere). */
1431 #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
1432 #define udiv_qrnnd(q, r, nh, nl, d) \
1435 (q) = __udiv_w_sdiv (&__r, nh, nl, d); \
1440 /* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
1441 #if !defined (udiv_qrnnd)
1442 #define UDIV_NEEDS_NORMALIZATION 1
1443 #define udiv_qrnnd __udiv_qrnnd_c
1446 #if !defined (count_leading_zeros)
1447 static const UQItype __clz_tab
[];
1448 #define count_leading_zeros(count, x) \
1450 UWtype __xr = (x); \
1453 if (W_TYPE_SIZE <= 32) \
1455 __a = __xr < ((UWtype)1<<2*__BITS4) \
1456 ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \
1457 : (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
1461 for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
1462 if (((__xr >> __a) & 0xff) != 0) \
1466 (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
1468 #define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
1471 #if !defined (count_trailing_zeros)
1472 /* Define count_trailing_zeros using count_leading_zeros. The latter might be
1473 defined in asm, but if it is not, the C version above is good enough. */
1474 #define count_trailing_zeros(count, x) \
1476 UWtype __ctz_x = (x); \
1478 count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
1479 (count) = W_TYPE_SIZE - 1 - __ctz_c; \
1483 #ifndef UDIV_NEEDS_NORMALIZATION
1484 #define UDIV_NEEDS_NORMALIZATION 0