1 /* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
3 Copyright (C) 1991, 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This file is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this file; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA. */
20 /* You have to define the following before including this file:
22 UWtype -- An unsigned type, default type for operations (typically a "word")
23 UHWtype -- An unsigned type, at least half the size of UWtype.
24 UDWtype -- An unsigned type, at least twice as large a UWtype
25 W_TYPE_SIZE -- size in bits of UWtype
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))
39 /* This is used to make sure no undesirable sharing between different libraries
40 that use this file takes place. */
42 #define __MPN(x) __##x
45 /* Define auxiliary asm macros.
47 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two
48 UWtype integers MULTIPLER and MULTIPLICAND, and generates a two UWtype
49 word product in HIGH_PROD and LOW_PROD.
51 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
52 UDWtype product. This is just a variant of umul_ppmm.
54 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
55 denominator) divides a UDWtype, composed by the UWtype integers
56 HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
57 in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
58 than DENOMINATOR for correct operation. If, in addition, the most
59 significant bit of DENOMINATOR must be 1, then the pre-processor symbol
60 UDIV_NEEDS_NORMALIZATION is defined to 1.
62 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
63 denominator). Like udiv_qrnnd but the numbers are signed. The quotient
66 5) count_leading_zeros(count, x) counts the number of zero-bits from the
67 msb to the first non-zero bit in the UWtype X. This is the number of
68 steps X needs to be shifted left to set the msb. Undefined for X == 0,
69 unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
71 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
72 from the least significant end.
74 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
75 high_addend_2, low_addend_2) adds two UWtype integers, composed by
76 HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
77 respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
78 (i.e. carry out) is not stored anywhere, and is lost.
80 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
81 high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
82 composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
83 LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
84 and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
87 If any of these macros are left undefined for a particular CPU,
90 /* The CPUs come in alphabetical order below.
92 Please add support for more CPUs here, or improve the current support
93 for the CPUs below! */
95 #if defined (__GNUC__) && !defined (NO_ASM)
97 /* We sometimes need to clobber "cc" with gcc2, but that would not be
98 understood by gcc1. Use cpp to avoid major code duplication. */
101 #define __AND_CLOBBER_CC
102 #else /* __GNUC__ >= 2 */
103 #define __CLOBBER_CC : "cc"
104 #define __AND_CLOBBER_CC , "cc"
105 #endif /* __GNUC__ < 2 */
107 #if (defined (__a29k__) || defined (_AM29K)) && W_TYPE_SIZE == 32
108 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
109 __asm__ ("add %1,%4,%5
111 : "=r" ((USItype)(sh)), \
112 "=&r" ((USItype)(sl)) \
113 : "%r" ((USItype)(ah)), \
114 "rI" ((USItype)(bh)), \
115 "%r" ((USItype)(al)), \
116 "rI" ((USItype)(bl)))
117 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
118 __asm__ ("sub %1,%4,%5
120 : "=r" ((USItype)(sh)), \
121 "=&r" ((USItype)(sl)) \
122 : "r" ((USItype)(ah)), \
123 "rI" ((USItype)(bh)), \
124 "r" ((USItype)(al)), \
125 "rI" ((USItype)(bl)))
126 #define umul_ppmm(xh, xl, m0, m1) \
128 USItype __m0 = (m0), __m1 = (m1); \
129 __asm__ ("multiplu %0,%1,%2" \
130 : "=r" ((USItype)(xl)) \
133 __asm__ ("multmu %0,%1,%2" \
134 : "=r" ((USItype)(xh)) \
138 #define udiv_qrnnd(q, r, n1, n0, d) \
139 __asm__ ("dividu %0,%3,%4" \
140 : "=r" ((USItype)(q)), \
141 "=q" ((USItype)(r)) \
142 : "1" ((USItype)(n1)), \
143 "r" ((USItype)(n0)), \
145 #define count_leading_zeros(count, x) \
146 __asm__ ("clz %0,%1" \
147 : "=r" ((USItype)(count)) \
148 : "r" ((USItype)(x)))
149 #define COUNT_LEADING_ZEROS_0 32
150 #endif /* __a29k__ */
152 #if defined (__alpha) && W_TYPE_SIZE == 64
153 #define umul_ppmm(ph, pl, m0, m1) \
155 UDItype __m0 = (m0), __m1 = (m1); \
156 __asm__ ("umulh %r1,%2,%0" \
157 : "=r" ((UDItype) ph) \
160 (pl) = __m0 * __m1; \
163 #ifndef LONGLONG_STANDALONE
164 #define udiv_qrnnd(q, r, n1, n0, d) \
166 (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
169 extern UDItype __udiv_qrnnd __P ((UDItype *, UDItype, UDItype, UDItype));
170 #define UDIV_TIME 220
171 #endif /* LONGLONG_STANDALONE */
174 #if defined (__arm__) && W_TYPE_SIZE == 32
175 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
176 __asm__ ("adds %1, %4, %5
178 : "=r" ((USItype)(sh)), \
179 "=&r" ((USItype)(sl)) \
180 : "%r" ((USItype)(ah)), \
181 "rI" ((USItype)(bh)), \
182 "%r" ((USItype)(al)), \
183 "rI" ((USItype)(bl)))
184 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
185 __asm__ ("subs %1, %4, %5
187 : "=r" ((USItype)(sh)), \
188 "=&r" ((USItype)(sl)) \
189 : "r" ((USItype)(ah)), \
190 "rI" ((USItype)(bh)), \
191 "r" ((USItype)(al)), \
192 "rI" ((USItype)(bl)))
193 #define umul_ppmm(xh, xl, a, b) \
194 __asm__ ("%@ Inlined umul_ppmm
195 mov %|r0, %2, lsr #16
196 mov %|r2, %3, lsr #16
197 bic %|r1, %2, %|r0, lsl #16
198 bic %|r2, %3, %|r2, lsl #16
203 adds %|r1, %|r2, %|r1
205 adds %1, %1, %|r1, lsl #16
206 adc %0, %0, %|r1, lsr #16" \
207 : "=&r" ((USItype)(xh)), \
208 "=r" ((USItype)(xl)) \
209 : "r" ((USItype)(a)), \
213 #define UDIV_TIME 100
216 #if defined (__clipper__) && W_TYPE_SIZE == 32
217 #define umul_ppmm(w1, w0, u, v) \
218 ({union {UDItype __ll; \
219 struct {USItype __l, __h;} __i; \
221 __asm__ ("mulwux %2,%0" \
223 : "%0" ((USItype)(u)), \
224 "r" ((USItype)(v))); \
225 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
226 #define smul_ppmm(w1, w0, u, v) \
227 ({union {DItype __ll; \
228 struct {SItype __l, __h;} __i; \
230 __asm__ ("mulwx %2,%0" \
232 : "%0" ((SItype)(u)), \
233 "r" ((SItype)(v))); \
234 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
235 #define __umulsidi3(u, v) \
237 __asm__ ("mulwux %2,%0" \
239 : "%0" ((USItype)(u)), \
240 "r" ((USItype)(v))); \
242 #endif /* __clipper__ */
244 #if defined (__gmicro__) && W_TYPE_SIZE == 32
245 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
246 __asm__ ("add.w %5,%1
248 : "=g" ((USItype)(sh)), \
249 "=&g" ((USItype)(sl)) \
250 : "%0" ((USItype)(ah)), \
251 "g" ((USItype)(bh)), \
252 "%1" ((USItype)(al)), \
254 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
255 __asm__ ("sub.w %5,%1
257 : "=g" ((USItype)(sh)), \
258 "=&g" ((USItype)(sl)) \
259 : "0" ((USItype)(ah)), \
260 "g" ((USItype)(bh)), \
261 "1" ((USItype)(al)), \
263 #define umul_ppmm(ph, pl, m0, m1) \
264 __asm__ ("mulx %3,%0,%1" \
265 : "=g" ((USItype)(ph)), \
266 "=r" ((USItype)(pl)) \
267 : "%0" ((USItype)(m0)), \
269 #define udiv_qrnnd(q, r, nh, nl, d) \
270 __asm__ ("divx %4,%0,%1" \
271 : "=g" ((USItype)(q)), \
272 "=r" ((USItype)(r)) \
273 : "1" ((USItype)(nh)), \
274 "0" ((USItype)(nl)), \
276 #define count_leading_zeros(count, x) \
277 __asm__ ("bsch/1 %1,%0" \
279 : "g" ((USItype)(x)), \
283 #if defined (__hppa) && W_TYPE_SIZE == 32
284 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
285 __asm__ ("add %4,%5,%1
287 : "=r" ((USItype)(sh)), \
288 "=&r" ((USItype)(sl)) \
289 : "%rM" ((USItype)(ah)), \
290 "rM" ((USItype)(bh)), \
291 "%rM" ((USItype)(al)), \
292 "rM" ((USItype)(bl)))
293 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
294 __asm__ ("sub %4,%5,%1
296 : "=r" ((USItype)(sh)), \
297 "=&r" ((USItype)(sl)) \
298 : "rM" ((USItype)(ah)), \
299 "rM" ((USItype)(bh)), \
300 "rM" ((USItype)(al)), \
301 "rM" ((USItype)(bl)))
302 #if defined (_PA_RISC1_1)
303 #define umul_ppmm(wh, wl, u, v) \
305 union {UDItype __ll; \
306 struct {USItype __h, __l;} __i; \
308 __asm__ ("xmpyu %1,%2,%0" \
309 : "=*f" (__xx.__ll) \
310 : "*f" ((USItype)(u)), \
311 "*f" ((USItype)(v))); \
312 (wh) = __xx.__i.__h; \
313 (wl) = __xx.__i.__l; \
321 #ifndef LONGLONG_STANDALONE
322 #define udiv_qrnnd(q, r, n1, n0, d) \
324 (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
327 extern USItype __udiv_qrnnd ();
328 #endif /* LONGLONG_STANDALONE */
329 #define count_leading_zeros(count, x) \
334 extru,= %1,15,16,%%r0 ; Bits 31..16 zero?
335 extru,tr %1,15,16,%1 ; No. Shift down, skip add.
336 ldo 16(%0),%0 ; Yes. Perform add.
337 extru,= %1,23,8,%%r0 ; Bits 15..8 zero?
338 extru,tr %1,23,8,%1 ; No. Shift down, skip add.
339 ldo 8(%0),%0 ; Yes. Perform add.
340 extru,= %1,27,4,%%r0 ; Bits 7..4 zero?
341 extru,tr %1,27,4,%1 ; No. Shift down, skip add.
342 ldo 4(%0),%0 ; Yes. Perform add.
343 extru,= %1,29,2,%%r0 ; Bits 3..2 zero?
344 extru,tr %1,29,2,%1 ; No. Shift down, skip add.
345 ldo 2(%0),%0 ; Yes. Perform add.
346 extru %1,30,1,%1 ; Extract bit 1.
347 sub %0,%1,%0 ; Subtract it.
348 " : "=r" (count), "=r" (__tmp) : "1" (x)); \
352 #if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
353 #define umul_ppmm(xh, xl, m0, m1) \
355 union {UDItype __ll; \
356 struct {USItype __h, __l;} __i; \
358 USItype __m0 = (m0), __m1 = (m1); \
359 __asm__ ("mr %0,%3" \
360 : "=r" (__xx.__i.__h), \
361 "=r" (__xx.__i.__l) \
364 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
365 (xh) += ((((SItype) __m0 >> 31) & __m1) \
366 + (((SItype) __m1 >> 31) & __m0)); \
368 #define smul_ppmm(xh, xl, m0, m1) \
370 union {DItype __ll; \
371 struct {USItype __h, __l;} __i; \
373 __asm__ ("mr %0,%3" \
374 : "=r" (__xx.__i.__h), \
375 "=r" (__xx.__i.__l) \
378 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
380 #define sdiv_qrnnd(q, r, n1, n0, d) \
382 union {DItype __ll; \
383 struct {USItype __h, __l;} __i; \
385 __xx.__i.__h = n1; __xx.__i.__l = n0; \
386 __asm__ ("dr %0,%2" \
388 : "0" (__xx.__ll), "r" (d)); \
389 (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
393 #if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
394 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
397 : "=r" ((USItype)(sh)), \
398 "=&r" ((USItype)(sl)) \
399 : "%0" ((USItype)(ah)), \
400 "g" ((USItype)(bh)), \
401 "%1" ((USItype)(al)), \
403 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
406 : "=r" ((USItype)(sh)), \
407 "=&r" ((USItype)(sl)) \
408 : "0" ((USItype)(ah)), \
409 "g" ((USItype)(bh)), \
410 "1" ((USItype)(al)), \
412 #define umul_ppmm(w1, w0, u, v) \
414 : "=a" ((USItype)(w0)), \
415 "=d" ((USItype)(w1)) \
416 : "%0" ((USItype)(u)), \
418 #define udiv_qrnnd(q, r, n1, n0, d) \
420 : "=a" ((USItype)(q)), \
421 "=d" ((USItype)(r)) \
422 : "0" ((USItype)(n0)), \
423 "1" ((USItype)(n1)), \
425 #define count_leading_zeros(count, x) \
428 __asm__ ("bsrl %1,%0" \
429 : "=r" (__cbtmp) : "rm" ((USItype)(x))); \
430 (count) = __cbtmp ^ 31; \
432 #define count_trailing_zeros(count, x) \
433 __asm__ ("bsfl %1,%0" : "=r" (count) : "rm" ((USItype)(x)))
442 #if defined (__i860__) && W_TYPE_SIZE == 32
443 #define rshift_rhlc(r,h,l,c) \
444 __asm__ ("shr %3,r0,r0\;shrd %1,%2,%0" \
445 "=r" (r) : "r" (h), "r" (l), "rn" (c))
448 #if defined (__i960__) && W_TYPE_SIZE == 32
449 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
450 __asm__ ("cmpo 1,0\;addc %5,%4,%1\;addc %3,%2,%0" \
451 : "=r" ((USItype)(sh)), \
452 "=&r" ((USItype)(sl)) \
453 : "%dI" ((USItype)(ah)), \
454 "dI" ((USItype)(bh)), \
455 "%dI" ((USItype)(al)), \
456 "dI" ((USItype)(bl)))
457 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
458 __asm__ ("cmpo 0,0\;subc %5,%4,%1\;subc %3,%2,%0" \
459 : "=r" ((USItype)(sh)), \
460 "=&r" ((USItype)(sl)) \
461 : "dI" ((USItype)(ah)), \
462 "dI" ((USItype)(bh)), \
463 "dI" ((USItype)(al)), \
464 "dI" ((USItype)(bl)))
465 #define umul_ppmm(w1, w0, u, v) \
466 ({union {UDItype __ll; \
467 struct {USItype __l, __h;} __i; \
469 __asm__ ("emul %2,%1,%0" \
471 : "%dI" ((USItype)(u)), \
472 "dI" ((USItype)(v))); \
473 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
474 #define __umulsidi3(u, v) \
476 __asm__ ("emul %2,%1,%0" \
478 : "%dI" ((USItype)(u)), \
479 "dI" ((USItype)(v))); \
481 #define udiv_qrnnd(q, r, nh, nl, d) \
483 union {UDItype __ll; \
484 struct {USItype __l, __h;} __i; \
486 __nn.__i.__h = (nh); __nn.__i.__l = (nl); \
487 __asm__ ("ediv %d,%n,%0" \
489 : "dI" (__nn.__ll), \
490 "dI" ((USItype)(d))); \
491 (r) = __rq.__i.__l; (q) = __rq.__i.__h; \
493 #define count_leading_zeros(count, x) \
496 __asm__ ("scanbit %1,%0" \
498 : "r" ((USItype)(x))); \
499 (count) = __cbtmp ^ 31; \
501 #define COUNT_LEADING_ZEROS_0 (-32) /* sic */
502 #if defined (__i960mx) /* what is the proper symbol to test??? */
503 #define rshift_rhlc(r,h,l,c) \
505 union {UDItype __ll; \
506 struct {USItype __l, __h;} __i; \
508 __nn.__i.__h = (h); __nn.__i.__l = (l); \
509 __asm__ ("shre %2,%1,%0" \
510 : "=d" (r) : "dI" (__nn.__ll), "dI" (c)); \
515 #if (defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
516 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
517 __asm__ ("add%.l %5,%1
519 : "=d" ((USItype)(sh)), \
520 "=&d" ((USItype)(sl)) \
521 : "%0" ((USItype)(ah)), \
522 "d" ((USItype)(bh)), \
523 "%1" ((USItype)(al)), \
525 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
526 __asm__ ("sub%.l %5,%1
528 : "=d" ((USItype)(sh)), \
529 "=&d" ((USItype)(sl)) \
530 : "0" ((USItype)(ah)), \
531 "d" ((USItype)(bh)), \
532 "1" ((USItype)(al)), \
534 #if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
535 #define umul_ppmm(w1, w0, u, v) \
536 __asm__ ("mulu%.l %3,%1:%0" \
537 : "=d" ((USItype)(w0)), \
538 "=d" ((USItype)(w1)) \
539 : "%0" ((USItype)(u)), \
540 "dmi" ((USItype)(v)))
542 #define udiv_qrnnd(q, r, n1, n0, d) \
543 __asm__ ("divu%.l %4,%1:%0" \
544 : "=d" ((USItype)(q)), \
545 "=d" ((USItype)(r)) \
546 : "0" ((USItype)(n0)), \
547 "1" ((USItype)(n1)), \
548 "dmi" ((USItype)(d)))
550 #define sdiv_qrnnd(q, r, n1, n0, d) \
551 __asm__ ("divs%.l %4,%1:%0" \
552 : "=d" ((USItype)(q)), \
553 "=d" ((USItype)(r)) \
554 : "0" ((USItype)(n0)), \
555 "1" ((USItype)(n1)), \
556 "dmi" ((USItype)(d)))
557 #define count_leading_zeros(count, x) \
558 __asm__ ("bfffo %1{%b2:%b2},%0" \
559 : "=d" ((USItype)(count)) \
560 : "od" ((USItype)(x)), "n" (0))
561 #define COUNT_LEADING_ZEROS_0 32
562 #else /* not mc68020 */
563 #define umul_ppmm(xh, xl, a, b) \
564 do { USItype __umul_tmp1, __umul_tmp2; \
565 __asm__ ("| Inlined umul_ppmm
586 | End inlined umul_ppmm" \
587 : "=&d" ((USItype)(xh)), "=&d" ((USItype)(xl)), \
588 "=d" (__umul_tmp1), "=&d" (__umul_tmp2) \
589 : "%2" ((USItype)(a)), "d" ((USItype)(b))); \
591 #define UMUL_TIME 100
592 #define UDIV_TIME 400
593 #endif /* not mc68020 */
596 #if defined (__m88000__) && W_TYPE_SIZE == 32
597 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
598 __asm__ ("addu.co %1,%r4,%r5
599 addu.ci %0,%r2,%r3" \
600 : "=r" ((USItype)(sh)), \
601 "=&r" ((USItype)(sl)) \
602 : "%rJ" ((USItype)(ah)), \
603 "rJ" ((USItype)(bh)), \
604 "%rJ" ((USItype)(al)), \
605 "rJ" ((USItype)(bl)))
606 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
607 __asm__ ("subu.co %1,%r4,%r5
608 subu.ci %0,%r2,%r3" \
609 : "=r" ((USItype)(sh)), \
610 "=&r" ((USItype)(sl)) \
611 : "rJ" ((USItype)(ah)), \
612 "rJ" ((USItype)(bh)), \
613 "rJ" ((USItype)(al)), \
614 "rJ" ((USItype)(bl)))
615 #define count_leading_zeros(count, x) \
618 __asm__ ("ff1 %0,%1" \
620 : "r" ((USItype)(x))); \
621 (count) = __cbtmp ^ 31; \
623 #define COUNT_LEADING_ZEROS_0 63 /* sic */
624 #if defined (__m88110__)
625 #define umul_ppmm(wh, wl, u, v) \
627 union {UDItype __ll; \
628 struct {USItype __h, __l;} __i; \
630 __asm__ ("mulu.d %0,%1,%2" \
632 : "r" ((USItype)(u)), \
633 "r" ((USItype)(v))); \
634 (wh) = __xx.__i.__h; \
635 (wl) = __xx.__i.__l; \
637 #define udiv_qrnnd(q, r, n1, n0, d) \
638 ({union {UDItype __ll; \
639 struct {USItype __h, __l;} __i; \
642 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
643 __asm__ ("divu.d %0,%1,%2" \
646 "r" ((USItype)(d))); \
647 (r) = (n0) - __q * (d); (q) = __q; })
652 #define UDIV_TIME 150
653 #endif /* __m88110__ */
654 #endif /* __m88000__ */
656 #if defined (__mips__) && W_TYPE_SIZE == 32
657 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
658 #define umul_ppmm(w1, w0, u, v) \
659 __asm__ ("multu %2,%3" \
660 : "=l" ((USItype)(w0)), \
661 "=h" ((USItype)(w1)) \
662 : "d" ((USItype)(u)), \
665 #define umul_ppmm(w1, w0, u, v) \
666 __asm__ ("multu %2,%3
669 : "=d" ((USItype)(w0)), \
670 "=d" ((USItype)(w1)) \
671 : "d" ((USItype)(u)), \
675 #define UDIV_TIME 100
676 #endif /* __mips__ */
678 #if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
679 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
680 #define umul_ppmm(w1, w0, u, v) \
681 __asm__ ("dmultu %2,%3" \
682 : "=l" ((UDItype)(w0)), \
683 "=h" ((UDItype)(w1)) \
684 : "d" ((UDItype)(u)), \
687 #define umul_ppmm(w1, w0, u, v) \
688 __asm__ ("dmultu %2,%3
691 : "=d" ((UDItype)(w0)), \
692 "=d" ((UDItype)(w1)) \
693 : "d" ((UDItype)(u)), \
697 #define UDIV_TIME 140
698 #endif /* __mips__ */
700 #if defined (__ns32000__) && W_TYPE_SIZE == 32
701 #define umul_ppmm(w1, w0, u, v) \
702 ({union {UDItype __ll; \
703 struct {USItype __l, __h;} __i; \
705 __asm__ ("meid %2,%0" \
707 : "%0" ((USItype)(u)), \
708 "g" ((USItype)(v))); \
709 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
710 #define __umulsidi3(u, v) \
712 __asm__ ("meid %2,%0" \
714 : "%0" ((USItype)(u)), \
715 "g" ((USItype)(v))); \
717 #define udiv_qrnnd(q, r, n1, n0, d) \
718 ({union {UDItype __ll; \
719 struct {USItype __l, __h;} __i; \
721 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
722 __asm__ ("deid %2,%0" \
725 "g" ((USItype)(d))); \
726 (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
727 #define count_trailing_zeros(count,x) \
729 __asm__ ("ffsd %2,%0" \
730 : "=r" ((USItype) (count)) \
731 : "0" ((USItype) 0), \
732 "r" ((USItype) (x))); \
734 #endif /* __ns32000__ */
736 #if (defined (_ARCH_PPC) || defined (_IBMR2)) && W_TYPE_SIZE == 32
737 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
739 if (__builtin_constant_p (bh) && (bh) == 0) \
740 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
741 : "=r" ((USItype)(sh)), \
742 "=&r" ((USItype)(sl)) \
743 : "%r" ((USItype)(ah)), \
744 "%r" ((USItype)(al)), \
745 "rI" ((USItype)(bl))); \
746 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
747 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
748 : "=r" ((USItype)(sh)), \
749 "=&r" ((USItype)(sl)) \
750 : "%r" ((USItype)(ah)), \
751 "%r" ((USItype)(al)), \
752 "rI" ((USItype)(bl))); \
754 __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
755 : "=r" ((USItype)(sh)), \
756 "=&r" ((USItype)(sl)) \
757 : "%r" ((USItype)(ah)), \
758 "r" ((USItype)(bh)), \
759 "%r" ((USItype)(al)), \
760 "rI" ((USItype)(bl))); \
762 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
764 if (__builtin_constant_p (ah) && (ah) == 0) \
765 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
766 : "=r" ((USItype)(sh)), \
767 "=&r" ((USItype)(sl)) \
768 : "r" ((USItype)(bh)), \
769 "rI" ((USItype)(al)), \
770 "r" ((USItype)(bl))); \
771 else if (__builtin_constant_p (ah) && (ah) ==~(USItype) 0) \
772 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
773 : "=r" ((USItype)(sh)), \
774 "=&r" ((USItype)(sl)) \
775 : "r" ((USItype)(bh)), \
776 "rI" ((USItype)(al)), \
777 "r" ((USItype)(bl))); \
778 else if (__builtin_constant_p (bh) && (bh) == 0) \
779 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
780 : "=r" ((USItype)(sh)), \
781 "=&r" ((USItype)(sl)) \
782 : "r" ((USItype)(ah)), \
783 "rI" ((USItype)(al)), \
784 "r" ((USItype)(bl))); \
785 else if (__builtin_constant_p (bh) && (bh) ==~(USItype) 0) \
786 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
787 : "=r" ((USItype)(sh)), \
788 "=&r" ((USItype)(sl)) \
789 : "r" ((USItype)(ah)), \
790 "rI" ((USItype)(al)), \
791 "r" ((USItype)(bl))); \
793 __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
794 : "=r" ((USItype)(sh)), \
795 "=&r" ((USItype)(sl)) \
796 : "r" ((USItype)(ah)), \
797 "r" ((USItype)(bh)), \
798 "rI" ((USItype)(al)), \
799 "r" ((USItype)(bl))); \
801 #define count_leading_zeros(count, x) \
802 __asm__ ("{cntlz|cntlzw} %0,%1" \
803 : "=r" ((USItype)(count)) \
804 : "r" ((USItype)(x)))
805 #define COUNT_LEADING_ZEROS_0 32
806 #if defined (_ARCH_PPC)
807 #define umul_ppmm(ph, pl, m0, m1) \
809 USItype __m0 = (m0), __m1 = (m1); \
810 __asm__ ("mulhwu %0,%1,%2" \
811 : "=r" ((USItype) ph) \
814 (pl) = __m0 * __m1; \
817 #define smul_ppmm(ph, pl, m0, m1) \
819 SItype __m0 = (m0), __m1 = (m1); \
820 __asm__ ("mulhw %0,%1,%2" \
821 : "=r" ((SItype) ph) \
824 (pl) = __m0 * __m1; \
827 #define UDIV_TIME 120
829 #define umul_ppmm(xh, xl, m0, m1) \
831 USItype __m0 = (m0), __m1 = (m1); \
832 __asm__ ("mul %0,%2,%3" \
833 : "=r" ((USItype)(xh)), \
834 "=q" ((USItype)(xl)) \
837 (xh) += ((((SItype) __m0 >> 31) & __m1) \
838 + (((SItype) __m1 >> 31) & __m0)); \
841 #define smul_ppmm(xh, xl, m0, m1) \
842 __asm__ ("mul %0,%2,%3" \
843 : "=r" ((SItype)(xh)), \
844 "=q" ((SItype)(xl)) \
848 #define sdiv_qrnnd(q, r, nh, nl, d) \
849 __asm__ ("div %0,%2,%4" \
850 : "=r" ((SItype)(q)), "=q" ((SItype)(r)) \
851 : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d)))
852 #define UDIV_TIME 100
854 #endif /* Power architecture variants. */
856 #if defined (__pyr__) && W_TYPE_SIZE == 32
857 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
860 : "=r" ((USItype)(sh)), \
861 "=&r" ((USItype)(sl)) \
862 : "%0" ((USItype)(ah)), \
863 "g" ((USItype)(bh)), \
864 "%1" ((USItype)(al)), \
866 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
869 : "=r" ((USItype)(sh)), \
870 "=&r" ((USItype)(sl)) \
871 : "0" ((USItype)(ah)), \
872 "g" ((USItype)(bh)), \
873 "1" ((USItype)(al)), \
875 /* This insn works on Pyramids with AP, XP, or MI CPUs, but not with SP. */
876 #define umul_ppmm(w1, w0, u, v) \
877 ({union {UDItype __ll; \
878 struct {USItype __h, __l;} __i; \
880 __asm__ ("movw %1,%R0
882 : "=&r" (__xx.__ll) \
883 : "g" ((USItype) (u)), \
884 "g" ((USItype)(v))); \
885 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
888 #if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
889 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
892 : "=r" ((USItype)(sh)), \
893 "=&r" ((USItype)(sl)) \
894 : "%0" ((USItype)(ah)), \
895 "r" ((USItype)(bh)), \
896 "%1" ((USItype)(al)), \
898 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
901 : "=r" ((USItype)(sh)), \
902 "=&r" ((USItype)(sl)) \
903 : "0" ((USItype)(ah)), \
904 "r" ((USItype)(bh)), \
905 "1" ((USItype)(al)), \
907 #define umul_ppmm(ph, pl, m0, m1) \
909 USItype __m0 = (m0), __m1 = (m1); \
931 : "=r" ((USItype)(ph)), \
932 "=r" ((USItype)(pl)) \
936 (ph) += ((((SItype) __m0 >> 31) & __m1) \
937 + (((SItype) __m1 >> 31) & __m0)); \
940 #define UDIV_TIME 200
941 #define count_leading_zeros(count, x) \
943 if ((x) >= 0x10000) \
944 __asm__ ("clz %0,%1" \
945 : "=r" ((USItype)(count)) \
946 : "r" ((USItype)(x) >> 16)); \
949 __asm__ ("clz %0,%1" \
950 : "=r" ((USItype)(count)) \
951 : "r" ((USItype)(x))); \
957 #if defined (__sh2__) && W_TYPE_SIZE == 32
958 #define umul_ppmm(w1, w0, u, v) \
963 : "=r" ((USItype)(w1)), \
964 "=r" ((USItype)(w0)) \
965 : "r" ((USItype)(u)), \
971 #if defined (__sparc__) && W_TYPE_SIZE == 32
972 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
973 __asm__ ("addcc %r4,%5,%1
975 : "=r" ((USItype)(sh)), \
976 "=&r" ((USItype)(sl)) \
977 : "%rJ" ((USItype)(ah)), \
978 "rI" ((USItype)(bh)), \
979 "%rJ" ((USItype)(al)), \
980 "rI" ((USItype)(bl)) \
982 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
983 __asm__ ("subcc %r4,%5,%1
985 : "=r" ((USItype)(sh)), \
986 "=&r" ((USItype)(sl)) \
987 : "rJ" ((USItype)(ah)), \
988 "rI" ((USItype)(bh)), \
989 "rJ" ((USItype)(al)), \
990 "rI" ((USItype)(bl)) \
992 #if defined (__sparc_v8__)
993 /* Don't match immediate range because, 1) it is not often useful,
994 2) the 'I' flag thinks of the range as a 13 bit signed interval,
995 while we want to match a 13 bit interval, sign extended to 32 bits,
996 but INTERPRETED AS UNSIGNED. */
997 #define umul_ppmm(w1, w0, u, v) \
998 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
999 : "=r" ((USItype)(w1)), \
1000 "=r" ((USItype)(w0)) \
1001 : "r" ((USItype)(u)), \
1004 #ifndef SUPERSPARC /* SuperSPARC's udiv only handles 53 bit dividends */
1005 #define udiv_qrnnd(q, r, n1, n0, d) \
1008 __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \
1009 : "=r" ((USItype)(__q)) \
1010 : "r" ((USItype)(n1)), \
1011 "r" ((USItype)(n0)), \
1012 "r" ((USItype)(d))); \
1013 (r) = (n0) - __q * (d); \
1016 #define UDIV_TIME 25
1017 #endif /* SUPERSPARC */
1018 #else /* ! __sparc_v8__ */
1019 #if defined (__sparclite__)
1020 /* This has hardware multiply but not divide. It also has two additional
1021 instructions scan (ffs from high bit) and divscc. */
1022 #define umul_ppmm(w1, w0, u, v) \
1023 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
1024 : "=r" ((USItype)(w1)), \
1025 "=r" ((USItype)(w0)) \
1026 : "r" ((USItype)(u)), \
1029 #define udiv_qrnnd(q, r, n1, n0, d) \
1030 __asm__ ("! Inlined udiv_qrnnd
1031 wr %%g0,%2,%%y ! Not a delayed write for sparclite
1068 1: ! End of inline udiv_qrnnd" \
1069 : "=r" ((USItype)(q)), \
1070 "=r" ((USItype)(r)) \
1071 : "r" ((USItype)(n1)), \
1072 "r" ((USItype)(n0)), \
1073 "rI" ((USItype)(d)) \
1074 : "%g1" __AND_CLOBBER_CC)
1075 #define UDIV_TIME 37
1076 #define count_leading_zeros(count, x) \
1077 __asm__ ("scan %1,0,%0" \
1078 : "=r" ((USItype)(x)) \
1079 : "r" ((USItype)(count)))
1080 /* Early sparclites return 63 for an argument of 0, but they warn that future
1081 implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
1083 #endif /* __sparclite__ */
1084 #endif /* __sparc_v8__ */
1085 /* Default to sparc v7 versions of umul_ppmm and udiv_qrnnd. */
1087 #define umul_ppmm(w1, w0, u, v) \
1088 __asm__ ("! Inlined umul_ppmm
1089 wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr
1090 sra %3,31,%%g2 ! Don't move this insn
1091 and %2,%%g2,%%g2 ! Don't move this insn
1092 andcc %%g0,0,%%g1 ! Don't move this insn
1128 : "=r" ((USItype)(w1)), \
1129 "=r" ((USItype)(w0)) \
1130 : "%rI" ((USItype)(u)), \
1131 "r" ((USItype)(v)) \
1132 : "%g1", "%g2" __AND_CLOBBER_CC)
1133 #define UMUL_TIME 39 /* 39 instructions */
1136 #ifndef LONGLONG_STANDALONE
1137 #define udiv_qrnnd(q, r, n1, n0, d) \
1139 (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
1142 extern USItype __udiv_qrnnd ();
1143 #define UDIV_TIME 140
1144 #endif /* LONGLONG_STANDALONE */
1145 #endif /* udiv_qrnnd */
1146 #endif /* __sparc__ */
1148 #if defined (__vax__) && W_TYPE_SIZE == 32
1149 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1150 __asm__ ("addl2 %5,%1
1152 : "=g" ((USItype)(sh)), \
1153 "=&g" ((USItype)(sl)) \
1154 : "%0" ((USItype)(ah)), \
1155 "g" ((USItype)(bh)), \
1156 "%1" ((USItype)(al)), \
1157 "g" ((USItype)(bl)))
1158 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1159 __asm__ ("subl2 %5,%1
1161 : "=g" ((USItype)(sh)), \
1162 "=&g" ((USItype)(sl)) \
1163 : "0" ((USItype)(ah)), \
1164 "g" ((USItype)(bh)), \
1165 "1" ((USItype)(al)), \
1166 "g" ((USItype)(bl)))
1167 #define umul_ppmm(xh, xl, m0, m1) \
1169 union {UDItype __ll; \
1170 struct {USItype __l, __h;} __i; \
1172 USItype __m0 = (m0), __m1 = (m1); \
1173 __asm__ ("emul %1,%2,$0,%0" \
1174 : "=g" (__xx.__ll) \
1177 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
1178 (xh) += ((((SItype) __m0 >> 31) & __m1) \
1179 + (((SItype) __m1 >> 31) & __m0)); \
1181 #define sdiv_qrnnd(q, r, n1, n0, d) \
1183 union {DItype __ll; \
1184 struct {SItype __l, __h;} __i; \
1186 __xx.__i.__h = n1; __xx.__i.__l = n0; \
1187 __asm__ ("ediv %3,%2,%0,%1" \
1188 : "=g" (q), "=g" (r) \
1189 : "g" (__xx.ll), "g" (d)); \
1191 #endif /* __vax__ */
1193 #if defined (__z8000__) && W_TYPE_SIZE == 16
1194 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1195 __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
1196 : "=r" ((unsigned int)(sh)), \
1197 "=&r" ((unsigned int)(sl)) \
1198 : "%0" ((unsigned int)(ah)), \
1199 "r" ((unsigned int)(bh)), \
1200 "%1" ((unsigned int)(al)), \
1201 "rQR" ((unsigned int)(bl)))
1202 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1203 __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
1204 : "=r" ((unsigned int)(sh)), \
1205 "=&r" ((unsigned int)(sl)) \
1206 : "0" ((unsigned int)(ah)), \
1207 "r" ((unsigned int)(bh)), \
1208 "1" ((unsigned int)(al)), \
1209 "rQR" ((unsigned int)(bl)))
1210 #define umul_ppmm(xh, xl, m0, m1) \
1212 union {long int __ll; \
1213 struct {unsigned int __h, __l;} __i; \
1215 unsigned int __m0 = (m0), __m1 = (m1); \
1216 __asm__ ("mult %S0,%H3" \
1217 : "=r" (__xx.__i.__h), \
1218 "=r" (__xx.__i.__l) \
1221 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
1222 (xh) += ((((signed int) __m0 >> 15) & __m1) \
1223 + (((signed int) __m1 >> 15) & __m0)); \
1225 #endif /* __z8000__ */
1227 #endif /* __GNUC__ */
1230 #if !defined (umul_ppmm) && defined (__umulsidi3)
1231 #define umul_ppmm(ph, pl, m0, m1) \
1233 UDWtype __ll = __umulsidi3 (m0, m1); \
1234 ph = (UWtype) (__ll >> W_TYPE_SIZE); \
1235 pl = (UWtype) __ll; \
1239 #if !defined (__umulsidi3)
1240 #define __umulsidi3(u, v) \
1241 ({UWtype __hi, __lo; \
1242 umul_ppmm (__hi, __lo, u, v); \
1243 ((UDWtype) __hi << W_TYPE_SIZE) | __lo; })
1246 /* If this machine has no inline assembler, use C macros. */
1248 #if !defined (add_ssaaaa)
1249 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1252 __x = (al) + (bl); \
1253 (sh) = (ah) + (bh) + (__x < (al)); \
1258 #if !defined (sub_ddmmss)
1259 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1262 __x = (al) - (bl); \
1263 (sh) = (ah) - (bh) - (__x > (al)); \
1268 #if !defined (umul_ppmm)
1269 #define umul_ppmm(w1, w0, u, v) \
1271 UWtype __x0, __x1, __x2, __x3; \
1272 UHWtype __ul, __vl, __uh, __vh; \
1273 UWtype __u = (u), __v = (v); \
1275 __ul = __ll_lowpart (__u); \
1276 __uh = __ll_highpart (__u); \
1277 __vl = __ll_lowpart (__v); \
1278 __vh = __ll_highpart (__v); \
1280 __x0 = (UWtype) __ul * __vl; \
1281 __x1 = (UWtype) __ul * __vh; \
1282 __x2 = (UWtype) __uh * __vl; \
1283 __x3 = (UWtype) __uh * __vh; \
1285 __x1 += __ll_highpart (__x0);/* this can't give carry */ \
1286 __x1 += __x2; /* but this indeed can */ \
1287 if (__x1 < __x2) /* did we get it? */ \
1288 __x3 += __ll_B; /* yes, add it in the proper pos. */ \
1290 (w1) = __x3 + __ll_highpart (__x1); \
1291 (w0) = (__ll_lowpart (__x1) << W_TYPE_SIZE/2) + __ll_lowpart (__x0);\
1295 #if !defined (umul_ppmm)
1296 #define smul_ppmm(w1, w0, u, v) \
1299 UWtype __m0 = (u), __m1 = (v); \
1300 umul_ppmm (__w1, w0, __m0, __m1); \
1301 (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1) \
1302 - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0); \
1306 /* Define this unconditionally, so it can be used for debugging. */
1307 #define __udiv_qrnnd_c(q, r, n1, n0, d) \
1309 UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
1310 __d1 = __ll_highpart (d); \
1311 __d0 = __ll_lowpart (d); \
1313 __r1 = (n1) % __d1; \
1314 __q1 = (n1) / __d1; \
1315 __m = (UWtype) __q1 * __d0; \
1316 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
1319 __q1--, __r1 += (d); \
1320 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
1322 __q1--, __r1 += (d); \
1326 __r0 = __r1 % __d1; \
1327 __q0 = __r1 / __d1; \
1328 __m = (UWtype) __q0 * __d0; \
1329 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
1332 __q0--, __r0 += (d); \
1335 __q0--, __r0 += (d); \
1339 (q) = (UWtype) __q1 * __ll_B | __q0; \
1343 /* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
1344 __udiv_w_sdiv (defined in libgcc or elsewhere). */
1345 #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
1346 #define udiv_qrnnd(q, r, nh, nl, d) \
1349 (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \
1354 /* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
1355 #if !defined (udiv_qrnnd)
1356 #define UDIV_NEEDS_NORMALIZATION 1
1357 #define udiv_qrnnd __udiv_qrnnd_c
1360 #if !defined (count_leading_zeros)
1365 unsigned char __clz_tab[];
1366 #define count_leading_zeros(count, x) \
1368 UWtype __xr = (x); \
1371 if (W_TYPE_SIZE <= 32) \
1373 __a = __xr < ((UWtype) 1 << 2*__BITS4) \
1374 ? (__xr < ((UWtype) 1 << __BITS4) ? 0 : __BITS4) \
1375 : (__xr < ((UWtype) 1 << 3*__BITS4) ? 2*__BITS4 : 3*__BITS4);\
1379 for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
1380 if (((__xr >> __a) & 0xff) != 0) \
1384 (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
1386 /* This version gives a well-defined value for zero. */
1387 #define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
1390 #if !defined (count_trailing_zeros)
1391 /* Define count_trailing_zeros using count_leading_zeros. The latter might be
1392 defined in asm, but if it is not, the C version above is good enough. */
1393 #define count_trailing_zeros(count, x) \
1395 UWtype __ctz_x = (x); \
1397 count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
1398 (count) = W_TYPE_SIZE - 1 - __ctz_c; \
1402 #ifndef UDIV_NEEDS_NORMALIZATION
1403 #define UDIV_NEEDS_NORMALIZATION 0