Go to the documentation of this file.
38 #define __BITS4 (W_TYPE_SIZE / 4)
39 #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
40 #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
41 #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
46 #define __MPN(x) __##x
98 #if defined(__GNUC__) && !defined(NO_ASM)
104 #define __AND_CLOBBER_CC
106 #define __CLOBBER_CC : "cc"
107 #define __AND_CLOBBER_CC , "cc"
113 #if (defined(__a29k__) || defined(_AM29K)) && W_TYPE_SIZE == 32
114 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
115 __asm__ ("add %1,%4,%5\n" \
117 : "=r" ((USItype)(sh)), \
118 "=&r" ((USItype)(sl)) \
119 : "%r" ((USItype)(ah)), \
120 "rI" ((USItype)(bh)), \
121 "%r" ((USItype)(al)), \
122 "rI" ((USItype)(bl)))
123 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
124 __asm__ ("sub %1,%4,%5\n" \
126 : "=r" ((USItype)(sh)), \
127 "=&r" ((USItype)(sl)) \
128 : "r" ((USItype)(ah)), \
129 "rI" ((USItype)(bh)), \
130 "r" ((USItype)(al)), \
131 "rI" ((USItype)(bl)))
132 #define umul_ppmm(xh, xl, m0, m1) \
134 USItype __m0 = (m0), __m1 = (m1); \
135 __asm__ ("multiplu %0,%1,%2" \
136 : "=r" ((USItype)(xl)) \
139 __asm__ ("multmu %0,%1,%2" \
140 : "=r" ((USItype)(xh)) \
144 #define udiv_qrnnd(q, r, n1, n0, d) \
145 __asm__ ("dividu %0,%3,%4" \
146 : "=r" ((USItype)(q)), \
147 "=q" ((USItype)(r)) \
148 : "1" ((USItype)(n1)), \
149 "r" ((USItype)(n0)), \
153 #if defined(__alpha) && W_TYPE_SIZE == 64
154 #define umul_ppmm(ph, pl, m0, m1) \
156 UDItype __m0 = (m0), __m1 = (m1); \
157 __asm__ ("umulh %r1,%2,%0" \
158 : "=r" ((UDItype) ph) \
161 (pl) = __m0 * __m1; \
164 #ifndef LONGLONG_STANDALONE
165 #define udiv_qrnnd(q, r, n1, n0, d) \
167 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \
171 #define UDIV_TIME 220
178 #if defined(__arm__) && W_TYPE_SIZE == 32
179 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
180 __asm__ ("adds %1, %4, %5\n" \
182 : "=r" ((USItype)(sh)), \
183 "=&r" ((USItype)(sl)) \
184 : "%r" ((USItype)(ah)), \
185 "rI" ((USItype)(bh)), \
186 "%r" ((USItype)(al)), \
187 "rI" ((USItype)(bl)))
188 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
189 __asm__ ("subs %1, %4, %5\n" \
191 : "=r" ((USItype)(sh)), \
192 "=&r" ((USItype)(sl)) \
193 : "r" ((USItype)(ah)), \
194 "rI" ((USItype)(bh)), \
195 "r" ((USItype)(al)), \
196 "rI" ((USItype)(bl)))
197 #if defined __ARM_ARCH_2__ || defined __ARM_ARCH_3__
198 #define umul_ppmm(xh, xl, a, b) \
199 __asm__ ("%@ Inlined umul_ppmm\n" \
200 "mov %|r0, %2, lsr #16 @ AAAA\n" \
201 "mov %|r2, %3, lsr #16 @ BBBB\n" \
202 "bic %|r1, %2, %|r0, lsl #16 @ aaaa\n" \
203 "bic %0, %3, %|r2, lsl #16 @ bbbb\n" \
204 "mul %1, %|r1, %|r2 @ aaaa * BBBB\n" \
205 "mul %|r2, %|r0, %|r2 @ AAAA * BBBB\n" \
206 "mul %|r1, %0, %|r1 @ aaaa * bbbb\n" \
207 "mul %0, %|r0, %0 @ AAAA * bbbb\n" \
208 "adds %|r0, %1, %0 @ central sum\n" \
209 "addcs %|r2, %|r2, #65536\n" \
210 "adds %1, %|r1, %|r0, lsl #16\n" \
211 "adc %0, %|r2, %|r0, lsr #16" \
212 : "=&r" ((USItype)(xh)), \
213 "=r" ((USItype)(xl)) \
214 : "r" ((USItype)(a)), \
218 #define umul_ppmm(xh, xl, a, b) \
219 __asm__ ("%@ Inlined umul_ppmm\n" \
220 "umull %r1, %r0, %r2, %r3" \
221 : "=&r" ((USItype)(xh)), \
222 "=r" ((USItype)(xl)) \
223 : "r" ((USItype)(a)), \
228 #define UDIV_TIME 100
234 #if defined(__clipper__) && W_TYPE_SIZE == 32
235 #define umul_ppmm(w1, w0, u, v) \
236 ({union {UDItype __ll; \
237 struct {USItype __l, __h; } __i; \
239 __asm__ ("mulwux %2,%0" \
241 : "%0" ((USItype)(u)), \
242 "r" ((USItype)(v))); \
243 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l; })
244 #define smul_ppmm(w1, w0, u, v) \
245 ({union {DItype __ll; \
246 struct {SItype __l, __h; } __i; \
248 __asm__ ("mulwx %2,%0" \
250 : "%0" ((SItype)(u)), \
251 "r" ((SItype)(v))); \
252 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l; })
253 #define __umulsidi3(u, v) \
255 __asm__ ("mulwux %2,%0" \
257 : "%0" ((USItype)(u)), \
258 "r" ((USItype)(v))); \
265 #if defined(__gmicro__) && W_TYPE_SIZE == 32
266 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
267 __asm__ ("add.w %5,%1\n" \
269 : "=g" ((USItype)(sh)), \
270 "=&g" ((USItype)(sl)) \
271 : "%0" ((USItype)(ah)), \
272 "g" ((USItype)(bh)), \
273 "%1" ((USItype)(al)), \
275 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
276 __asm__ ("sub.w %5,%1\n" \
278 : "=g" ((USItype)(sh)), \
279 "=&g" ((USItype)(sl)) \
280 : "0" ((USItype)(ah)), \
281 "g" ((USItype)(bh)), \
282 "1" ((USItype)(al)), \
284 #define umul_ppmm(ph, pl, m0, m1) \
285 __asm__ ("mulx %3,%0,%1" \
286 : "=g" ((USItype)(ph)), \
287 "=r" ((USItype)(pl)) \
288 : "%0" ((USItype)(m0)), \
290 #define udiv_qrnnd(q, r, nh, nl, d) \
291 __asm__ ("divx %4,%0,%1" \
292 : "=g" ((USItype)(q)), \
293 "=r" ((USItype)(r)) \
294 : "1" ((USItype)(nh)), \
295 "0" ((USItype)(nl)), \
302 #if defined(__hppa) && W_TYPE_SIZE == 32
303 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
304 __asm__ ("add %4,%5,%1\n" \
306 : "=r" ((USItype)(sh)), \
307 "=&r" ((USItype)(sl)) \
308 : "%rM" ((USItype)(ah)), \
309 "rM" ((USItype)(bh)), \
310 "%rM" ((USItype)(al)), \
311 "rM" ((USItype)(bl)))
312 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
313 __asm__ ("sub %4,%5,%1\n" \
315 : "=r" ((USItype)(sh)), \
316 "=&r" ((USItype)(sl)) \
317 : "rM" ((USItype)(ah)), \
318 "rM" ((USItype)(bh)), \
319 "rM" ((USItype)(al)), \
320 "rM" ((USItype)(bl)))
321 #if defined(_PA_RISC1_1)
322 #define umul_ppmm(wh, wl, u, v) \
324 union {UDItype __ll; \
325 struct {USItype __h, __l; } __i; \
327 __asm__ ("xmpyu %1,%2,%0" \
328 : "=*f" (__xx.__ll) \
329 : "*f" ((USItype)(u)), \
330 "*f" ((USItype)(v))); \
331 (wh) = __xx.__i.__h; \
332 (wl) = __xx.__i.__l; \
340 #ifndef LONGLONG_STANDALONE
341 #define udiv_qrnnd(q, r, n1, n0, d) \
343 (q) = __udiv_qrnnd(&__r, (n1), (n0), (d)); \
353 #if (defined(__i370__) || defined(__mvs__)) && W_TYPE_SIZE == 32
354 #define umul_ppmm(xh, xl, m0, m1) \
356 union {UDItype __ll; \
357 struct {USItype __h, __l; } __i; \
359 USItype __m0 = (m0), __m1 = (m1); \
360 __asm__ ("mr %0,%3" \
361 : "=r" (__xx.__i.__h), \
362 "=r" (__xx.__i.__l) \
365 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
366 (xh) += ((((SItype) __m0 >> 31) & __m1) \
367 + (((SItype) __m1 >> 31) & __m0)); \
369 #define smul_ppmm(xh, xl, m0, m1) \
371 union {DItype __ll; \
372 struct {USItype __h, __l; } __i; \
374 __asm__ ("mr %0,%3" \
375 : "=r" (__xx.__i.__h), \
376 "=r" (__xx.__i.__l) \
379 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
381 #define sdiv_qrnnd(q, r, n1, n0, d) \
383 union {DItype __ll; \
384 struct {USItype __h, __l; } __i; \
386 __xx.__i.__h = n1; __xx.__i.__l = n0; \
387 __asm__ ("dr %0,%2" \
389 : "0" (__xx.__ll), "r" (d)); \
390 (q) = __xx.__i.__l; (r) = __xx.__i.__h; \
398 #if (defined(__i386__) || defined(__i486__)) && W_TYPE_SIZE == 32
399 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
400 __asm__ ("addl %5,%1\n" \
402 : "=r" ((USItype)(sh)), \
403 "=&r" ((USItype)(sl)) \
404 : "%0" ((USItype)(ah)), \
405 "g" ((USItype)(bh)), \
406 "%1" ((USItype)(al)), \
408 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
409 __asm__ ("subl %5,%1\n" \
411 : "=r" ((USItype)(sh)), \
412 "=&r" ((USItype)(sl)) \
413 : "0" ((USItype)(ah)), \
414 "g" ((USItype)(bh)), \
415 "1" ((USItype)(al)), \
417 #define umul_ppmm(w1, w0, u, v) \
419 : "=a" ((USItype)(w0)), \
420 "=d" ((USItype)(w1)) \
421 : "%0" ((USItype)(u)), \
423 #define udiv_qrnnd(q, r, n1, n0, d) \
425 : "=a" ((USItype)(q)), \
426 "=d" ((USItype)(r)) \
427 : "0" ((USItype)(n0)), \
428 "1" ((USItype)(n1)), \
441 #if defined(__i860__) && W_TYPE_SIZE == 32
442 #define rshift_rhlc(r, h, l, c) \
443 __asm__ ("shr %3,r0,r0\n" \
445 "=r" (r) : "r" (h), "r" (l), "rn" (c))
451 #if defined(__i960__) && W_TYPE_SIZE == 32
452 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
453 __asm__ ("cmpo 1,0\n" \
456 : "=r" ((USItype)(sh)), \
457 "=&r" ((USItype)(sl)) \
458 : "%dI" ((USItype)(ah)), \
459 "dI" ((USItype)(bh)), \
460 "%dI" ((USItype)(al)), \
461 "dI" ((USItype)(bl)))
462 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
463 __asm__ ("cmpo 0,0\n" \
466 : "=r" ((USItype)(sh)), \
467 "=&r" ((USItype)(sl)) \
468 : "dI" ((USItype)(ah)), \
469 "dI" ((USItype)(bh)), \
470 "dI" ((USItype)(al)), \
471 "dI" ((USItype)(bl)))
472 #define umul_ppmm(w1, w0, u, v) \
473 ({union {UDItype __ll; \
474 struct {USItype __l, __h; } __i; \
476 __asm__ ("emul %2,%1,%0" \
478 : "%dI" ((USItype)(u)), \
479 "dI" ((USItype)(v))); \
480 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l; })
481 #define __umulsidi3(u, v) \
483 __asm__ ("emul %2,%1,%0" \
485 : "%dI" ((USItype)(u)), \
486 "dI" ((USItype)(v))); \
488 #define udiv_qrnnd(q, r, nh, nl, d) \
490 union {UDItype __ll; \
491 struct {USItype __l, __h; } __i; \
493 __nn.__i.__h = (nh); __nn.__i.__l = (nl); \
494 __asm__ ("ediv %d,%n,%0" \
496 : "dI" (__nn.__ll), \
497 "dI" ((USItype)(d))); \
498 (r) = __rq.__i.__l; (q) = __rq.__i.__h; \
500 #if defined(__i960mx)
501 #define rshift_rhlc(r, h, l, c) \
503 union {UDItype __ll; \
504 struct {USItype __l, __h; } __i; \
506 __nn.__i.__h = (h); __nn.__i.__l = (l); \
507 __asm__ ("shre %2,%1,%0" \
508 : "=d" (r) : "dI" (__nn.__ll), "dI" (c)); \
516 #if (defined(__mc68000__) || defined(__mc68020__) || defined(__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
517 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
518 __asm__ ("add%.l %5,%1\n" \
520 : "=d" ((USItype)(sh)), \
521 "=&d" ((USItype)(sl)) \
522 : "%0" ((USItype)(ah)), \
523 "d" ((USItype)(bh)), \
524 "%1" ((USItype)(al)), \
526 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
527 __asm__ ("sub%.l %5,%1\n" \
529 : "=d" ((USItype)(sh)), \
530 "=&d" ((USItype)(sl)) \
531 : "0" ((USItype)(ah)), \
532 "d" ((USItype)(bh)), \
533 "1" ((USItype)(al)), \
535 #if (defined(__mc68020__) || defined(__NeXT__) || defined(mc68020))
536 #define umul_ppmm(w1, w0, u, v) \
537 __asm__ ("mulu%.l %3,%1:%0" \
538 : "=d" ((USItype)(w0)), \
539 "=d" ((USItype)(w1)) \
540 : "%0" ((USItype)(u)), \
541 "dmi" ((USItype)(v)))
543 #define udiv_qrnnd(q, r, n1, n0, d) \
544 __asm__ ("divu%.l %4,%1:%0" \
545 : "=d" ((USItype)(q)), \
546 "=d" ((USItype)(r)) \
547 : "0" ((USItype)(n0)), \
548 "1" ((USItype)(n1)), \
549 "dmi" ((USItype)(d)))
551 #define sdiv_qrnnd(q, r, n1, n0, d) \
552 __asm__ ("divs%.l %4,%1:%0" \
553 : "=d" ((USItype)(q)), \
554 "=d" ((USItype)(r)) \
555 : "0" ((USItype)(n0)), \
556 "1" ((USItype)(n1)), \
557 "dmi" ((USItype)(d)))
559 #define umul_ppmm(xh, xl, a, b) \
560 do { USItype __umul_tmp1, __umul_tmp2; \
561 __asm__ ("| Inlined umul_ppmm\n" \
574 "add%.l %#0x10000,%0\n" \
575 "1: move%.l %2,%3\n" \
582 "| End inlined umul_ppmm" \
583 : "=&d" ((USItype)(xh)), "=&d" ((USItype)(xl)), \
584 "=d" (__umul_tmp1), "=&d" (__umul_tmp2) \
585 : "%2" ((USItype)(a)), "d" ((USItype)(b))); \
587 #define UMUL_TIME 100
588 #define UDIV_TIME 400
595 #if defined(__m88000__) && W_TYPE_SIZE == 32
596 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
597 __asm__ ("addu.co %1,%r4,%r5\n" \
598 "addu.ci %0,%r2,%r3" \
599 : "=r" ((USItype)(sh)), \
600 "=&r" ((USItype)(sl)) \
601 : "%rJ" ((USItype)(ah)), \
602 "rJ" ((USItype)(bh)), \
603 "%rJ" ((USItype)(al)), \
604 "rJ" ((USItype)(bl)))
605 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
606 __asm__ ("subu.co %1,%r4,%r5\n" \
607 "subu.ci %0,%r2,%r3" \
608 : "=r" ((USItype)(sh)), \
609 "=&r" ((USItype)(sl)) \
610 : "rJ" ((USItype)(ah)), \
611 "rJ" ((USItype)(bh)), \
612 "rJ" ((USItype)(al)), \
613 "rJ" ((USItype)(bl)))
614 #if defined(__m88110__)
615 #define umul_ppmm(wh, wl, u, v) \
617 union {UDItype __ll; \
618 struct {USItype __h, __l; } __i; \
620 __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v)); \
621 (wh) = __x.__i.__h; \
622 (wl) = __x.__i.__l; \
624 #define udiv_qrnnd(q, r, n1, n0, d) \
625 ({union {UDItype __ll; \
626 struct {USItype __h, __l; } __i; \
628 __x.__i.__h = (n1); __x.__i.__l = (n0); \
629 __asm__ ("divu.d %0,%1,%2" \
630 : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d)); \
631 (r) = (n0) - __q.__l * (d); (q) = __q.__l; })
636 #define UDIV_TIME 150
643 #if defined(__mips__) && W_TYPE_SIZE == 32
644 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
645 #define umul_ppmm(w1, w0, u, v) \
647 UDItype __ll = (UDItype)(u) * (v); \
651 #elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
652 #define umul_ppmm(w1, w0, u, v) \
653 __asm__ ("multu %2,%3" \
654 : "=l" ((USItype)(w0)), \
655 "=h" ((USItype)(w1)) \
656 : "d" ((USItype)(u)), \
659 #define umul_ppmm(w1, w0, u, v) \
660 __asm__ ("multu %2,%3\n" \
663 : "=d" ((USItype)(w0)), \
664 "=d" ((USItype)(w1)) \
665 : "d" ((USItype)(u)), \
669 #define UDIV_TIME 100
675 #if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64
676 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
677 #define umul_ppmm(w1, w0, u, v) \
679 typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \
680 __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \
684 #elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
685 #define umul_ppmm(w1, w0, u, v) \
686 __asm__ ("dmultu %2,%3" \
687 : "=l" ((UDItype)(w0)), \
688 "=h" ((UDItype)(w1)) \
689 : "d" ((UDItype)(u)), \
692 #define umul_ppmm(w1, w0, u, v) \
693 __asm__ ("dmultu %2,%3\n" \
696 : "=d" ((UDItype)(w0)), \
697 "=d" ((UDItype)(w1)) \
698 : "d" ((UDItype)(u)), \
702 #define UDIV_TIME 140
708 #if defined(__ns32000__) && W_TYPE_SIZE == 32
709 #define umul_ppmm(w1, w0, u, v) \
710 ({union {UDItype __ll; \
711 struct {USItype __l, __h; } __i; \
713 __asm__ ("meid %2,%0" \
715 : "%0" ((USItype)(u)), \
716 "g" ((USItype)(v))); \
717 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l; })
718 #define __umulsidi3(u, v) \
720 __asm__ ("meid %2,%0" \
722 : "%0" ((USItype)(u)), \
723 "g" ((USItype)(v))); \
725 #define udiv_qrnnd(q, r, n1, n0, d) \
726 ({union {UDItype __ll; \
727 struct {USItype __l, __h; } __i; \
729 __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
730 __asm__ ("deid %2,%0" \
733 "g" ((USItype)(d))); \
734 (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
740 #if (defined(_ARCH_PPC) || defined(_IBMR2)) && W_TYPE_SIZE == 32
741 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
743 if (__builtin_constant_p(bh) && (bh) == 0) \
744 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
745 : "=r" ((USItype)(sh)), \
746 "=&r" ((USItype)(sl)) \
747 : "%r" ((USItype)(ah)), \
748 "%r" ((USItype)(al)), \
749 "rI" ((USItype)(bl))); \
750 else if (__builtin_constant_p(bh) && (bh) == ~(USItype) 0) \
751 __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
752 : "=r" ((USItype)(sh)), \
753 "=&r" ((USItype)(sl)) \
754 : "%r" ((USItype)(ah)), \
755 "%r" ((USItype)(al)), \
756 "rI" ((USItype)(bl))); \
758 __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
759 : "=r" ((USItype)(sh)), \
760 "=&r" ((USItype)(sl)) \
761 : "%r" ((USItype)(ah)), \
762 "r" ((USItype)(bh)), \
763 "%r" ((USItype)(al)), \
764 "rI" ((USItype)(bl))); \
766 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
768 if (__builtin_constant_p(ah) && (ah) == 0) \
769 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
770 : "=r" ((USItype)(sh)), \
771 "=&r" ((USItype)(sl)) \
772 : "r" ((USItype)(bh)), \
773 "rI" ((USItype)(al)), \
774 "r" ((USItype)(bl))); \
775 else if (__builtin_constant_p(ah) && (ah) == ~(USItype) 0) \
776 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
777 : "=r" ((USItype)(sh)), \
778 "=&r" ((USItype)(sl)) \
779 : "r" ((USItype)(bh)), \
780 "rI" ((USItype)(al)), \
781 "r" ((USItype)(bl))); \
782 else if (__builtin_constant_p(bh) && (bh) == 0) \
783 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
784 : "=r" ((USItype)(sh)), \
785 "=&r" ((USItype)(sl)) \
786 : "r" ((USItype)(ah)), \
787 "rI" ((USItype)(al)), \
788 "r" ((USItype)(bl))); \
789 else if (__builtin_constant_p(bh) && (bh) == ~(USItype) 0) \
790 __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
791 : "=r" ((USItype)(sh)), \
792 "=&r" ((USItype)(sl)) \
793 : "r" ((USItype)(ah)), \
794 "rI" ((USItype)(al)), \
795 "r" ((USItype)(bl))); \
797 __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
798 : "=r" ((USItype)(sh)), \
799 "=&r" ((USItype)(sl)) \
800 : "r" ((USItype)(ah)), \
801 "r" ((USItype)(bh)), \
802 "rI" ((USItype)(al)), \
803 "r" ((USItype)(bl))); \
805 #if defined(_ARCH_PPC)
806 #define umul_ppmm(ph, pl, m0, m1) \
808 USItype __m0 = (m0), __m1 = (m1); \
809 __asm__ ("mulhwu %0,%1,%2" \
810 : "=r" ((USItype) ph) \
813 (pl) = __m0 * __m1; \
816 #define smul_ppmm(ph, pl, m0, m1) \
818 SItype __m0 = (m0), __m1 = (m1); \
819 __asm__ ("mulhw %0,%1,%2" \
820 : "=r" ((SItype) ph) \
823 (pl) = __m0 * __m1; \
826 #define UDIV_TIME 120
828 #define umul_ppmm(xh, xl, m0, m1) \
830 USItype __m0 = (m0), __m1 = (m1); \
831 __asm__ ("mul %0,%2,%3" \
832 : "=r" ((USItype)(xh)), \
833 "=q" ((USItype)(xl)) \
836 (xh) += ((((SItype) __m0 >> 31) & __m1) \
837 + (((SItype) __m1 >> 31) & __m0)); \
840 #define smul_ppmm(xh, xl, m0, m1) \
841 __asm__ ("mul %0,%2,%3" \
842 : "=r" ((SItype)(xh)), \
843 "=q" ((SItype)(xl)) \
847 #define sdiv_qrnnd(q, r, nh, nl, d) \
848 __asm__ ("div %0,%2,%4" \
849 : "=r" ((SItype)(q)), "=q" ((SItype)(r)) \
850 : "r" ((SItype)(nh)), "1" ((SItype)(nl)), "r" ((SItype)(d)))
851 #define UDIV_TIME 100
858 #if defined(__pyr__) && W_TYPE_SIZE == 32
859 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
860 __asm__ ("addw %5,%1\n" \
862 : "=r" ((USItype)(sh)), \
863 "=&r" ((USItype)(sl)) \
864 : "%0" ((USItype)(ah)), \
865 "g" ((USItype)(bh)), \
866 "%1" ((USItype)(al)), \
868 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
869 __asm__ ("subw %5,%1\n" \
871 : "=r" ((USItype)(sh)), \
872 "=&r" ((USItype)(sl)) \
873 : "0" ((USItype)(ah)), \
874 "g" ((USItype)(bh)), \
875 "1" ((USItype)(al)), \
878 #define umul_ppmm(w1, w0, u, v) \
879 ({union {UDItype __ll; \
880 struct {USItype __h, __l; } __i; \
882 __asm__ ("movw %1,%R0\n" \
884 : "=&r" (__xx.__ll) \
885 : "g" ((USItype) (u)), \
886 "g" ((USItype)(v))); \
887 (w1) = __xx.__i.__h; (w0) = __xx.__i.__l; })
893 #if defined(__ibm032__) && W_TYPE_SIZE == 32
894 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
895 __asm__ ("a %1,%5\n" \
897 : "=r" ((USItype)(sh)), \
898 "=&r" ((USItype)(sl)) \
899 : "%0" ((USItype)(ah)), \
900 "r" ((USItype)(bh)), \
901 "%1" ((USItype)(al)), \
903 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
904 __asm__ ("s %1,%5\n" \
906 : "=r" ((USItype)(sh)), \
907 "=&r" ((USItype)(sl)) \
908 : "0" ((USItype)(ah)), \
909 "r" ((USItype)(bh)), \
910 "1" ((USItype)(al)), \
912 #define umul_ppmm(ph, pl, m0, m1) \
914 USItype __m0 = (m0), __m1 = (m1); \
936 : "=r" ((USItype)(ph)), \
937 "=r" ((USItype)(pl)) \
941 (ph) += ((((SItype) __m0 >> 31) & __m1) \
942 + (((SItype) __m1 >> 31) & __m0)); \
945 #define UDIV_TIME 200
951 #if (defined(__sh2__) || defined(__sh3__) || defined(__SH4__)) \
953 #define umul_ppmm(w1, w0, u, v) \
958 : "=r" ((USItype)(w1)), \
959 "=r" ((USItype)(w0)) \
960 : "r" ((USItype)(u)), \
969 #if defined(__sparc__) && W_TYPE_SIZE == 32
970 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
971 __asm__ ("addcc %r4,%5,%1\n" \
973 : "=r" ((USItype)(sh)), \
974 "=&r" ((USItype)(sl)) \
975 : "%rJ" ((USItype)(ah)), \
976 "rI" ((USItype)(bh)), \
977 "%rJ" ((USItype)(al)), \
978 "rI" ((USItype)(bl)) \
980 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
981 __asm__ ("subcc %r4,%5,%1\n" \
983 : "=r" ((USItype)(sh)), \
984 "=&r" ((USItype)(sl)) \
985 : "rJ" ((USItype)(ah)), \
986 "rI" ((USItype)(bh)), \
987 "rJ" ((USItype)(al)), \
988 "rI" ((USItype)(bl)) \
990 #if defined(__sparc_v8__)
995 #define umul_ppmm(w1, w0, u, v) \
996 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
997 : "=r" ((USItype)(w1)), \
998 "=r" ((USItype)(w0)) \
999 : "r" ((USItype)(u)), \
1003 #define udiv_qrnnd(q, r, n1, n0, d) \
1006 __asm__ ("mov %1,%%y;nop;nop;nop;udiv %2,%3,%0" \
1007 : "=r" ((USItype)(__q)) \
1008 : "r" ((USItype)(n1)), \
1009 "r" ((USItype)(n0)), \
1010 "r" ((USItype)(d))); \
1011 (r) = (n0) - __q * (d); \
1014 #define UDIV_TIME 25
1017 #if defined(__sparclite__)
1020 #define umul_ppmm(w1, w0, u, v) \
1021 __asm__ ("umul %2,%3,%1;rd %%y,%0" \
1022 : "=r" ((USItype)(w1)), \
1023 "=r" ((USItype)(w0)) \
1024 : "r" ((USItype)(u)), \
1027 #define udiv_qrnnd(q, r, n1, n0, d) \
1028 __asm__ ("! Inlined udiv_qrnnd\n" \
1029 "wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \
1031 "divscc %3,%4,%%g1\n" \
1032 "divscc %%g1,%4,%%g1\n" \
1033 "divscc %%g1,%4,%%g1\n" \
1034 "divscc %%g1,%4,%%g1\n" \
1035 "divscc %%g1,%4,%%g1\n" \
1036 "divscc %%g1,%4,%%g1\n" \
1037 "divscc %%g1,%4,%%g1\n" \
1038 "divscc %%g1,%4,%%g1\n" \
1039 "divscc %%g1,%4,%%g1\n" \
1040 "divscc %%g1,%4,%%g1\n" \
1041 "divscc %%g1,%4,%%g1\n" \
1042 "divscc %%g1,%4,%%g1\n" \
1043 "divscc %%g1,%4,%%g1\n" \
1044 "divscc %%g1,%4,%%g1\n" \
1045 "divscc %%g1,%4,%%g1\n" \
1046 "divscc %%g1,%4,%%g1\n" \
1047 "divscc %%g1,%4,%%g1\n" \
1048 "divscc %%g1,%4,%%g1\n" \
1049 "divscc %%g1,%4,%%g1\n" \
1050 "divscc %%g1,%4,%%g1\n" \
1051 "divscc %%g1,%4,%%g1\n" \
1052 "divscc %%g1,%4,%%g1\n" \
1053 "divscc %%g1,%4,%%g1\n" \
1054 "divscc %%g1,%4,%%g1\n" \
1055 "divscc %%g1,%4,%%g1\n" \
1056 "divscc %%g1,%4,%%g1\n" \
1057 "divscc %%g1,%4,%%g1\n" \
1058 "divscc %%g1,%4,%%g1\n" \
1059 "divscc %%g1,%4,%%g1\n" \
1060 "divscc %%g1,%4,%%g1\n" \
1061 "divscc %%g1,%4,%%g1\n" \
1062 "divscc %%g1,%4,%0\n" \
1066 "1: ! End of inline udiv_qrnnd" \
1067 : "=r" ((USItype)(q)), \
1068 "=r" ((USItype)(r)) \
1069 : "r" ((USItype)(n1)), \
1070 "r" ((USItype)(n0)), \
1071 "rI" ((USItype)(d)) \
1072 : "%g1" __AND_CLOBBER_CC)
1073 #define UDIV_TIME 37
1078 #define umul_ppmm(w1, w0, u, v) \
1079 __asm__ ("! Inlined umul_ppmm\n" \
1080 "wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n" \
1081 "sra %3,31,%%g2 ! Don't move this insn\n" \
1082 "and %2,%%g2,%%g2 ! Don't move this insn\n" \
1083 "andcc %%g0,0,%%g1 ! Don't move this insn\n" \
1084 "mulscc %%g1,%3,%%g1\n" \
1085 "mulscc %%g1,%3,%%g1\n" \
1086 "mulscc %%g1,%3,%%g1\n" \
1087 "mulscc %%g1,%3,%%g1\n" \
1088 "mulscc %%g1,%3,%%g1\n" \
1089 "mulscc %%g1,%3,%%g1\n" \
1090 "mulscc %%g1,%3,%%g1\n" \
1091 "mulscc %%g1,%3,%%g1\n" \
1092 "mulscc %%g1,%3,%%g1\n" \
1093 "mulscc %%g1,%3,%%g1\n" \
1094 "mulscc %%g1,%3,%%g1\n" \
1095 "mulscc %%g1,%3,%%g1\n" \
1096 "mulscc %%g1,%3,%%g1\n" \
1097 "mulscc %%g1,%3,%%g1\n" \
1098 "mulscc %%g1,%3,%%g1\n" \
1099 "mulscc %%g1,%3,%%g1\n" \
1100 "mulscc %%g1,%3,%%g1\n" \
1101 "mulscc %%g1,%3,%%g1\n" \
1102 "mulscc %%g1,%3,%%g1\n" \
1103 "mulscc %%g1,%3,%%g1\n" \
1104 "mulscc %%g1,%3,%%g1\n" \
1105 "mulscc %%g1,%3,%%g1\n" \
1106 "mulscc %%g1,%3,%%g1\n" \
1107 "mulscc %%g1,%3,%%g1\n" \
1108 "mulscc %%g1,%3,%%g1\n" \
1109 "mulscc %%g1,%3,%%g1\n" \
1110 "mulscc %%g1,%3,%%g1\n" \
1111 "mulscc %%g1,%3,%%g1\n" \
1112 "mulscc %%g1,%3,%%g1\n" \
1113 "mulscc %%g1,%3,%%g1\n" \
1114 "mulscc %%g1,%3,%%g1\n" \
1115 "mulscc %%g1,%3,%%g1\n" \
1116 "mulscc %%g1,0,%%g1\n" \
1117 "add %%g1,%%g2,%0\n" \
1119 : "=r" ((USItype)(w1)), \
1120 "=r" ((USItype)(w0)) \
1121 : "%rI" ((USItype)(u)), \
1122 "r" ((USItype)(v)) \
1123 : "%g1", "%g2" __AND_CLOBBER_CC)
1124 #define UMUL_TIME 39
1127 #define udiv_qrnnd(q, r, n1, n0, d) \
1128 __asm__ ("! Inlined udiv_qrnnd\n\t" \
1130 "subcc %1,%2,%%g0\n\t" \
1132 "addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n\t" \
1133 "sub %1,%2,%1 ! this kills msb of n\n\t" \
1134 "addx %1,%1,%1 ! so this can't give carry\n\t" \
1135 "subcc %%g1,1,%%g1\n\t" \
1137 "subcc %1,%2,%%g0\n\t" \
1139 "addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n\t" \
1141 "sub %1,%2,%1 ! this kills msb of n\n\t" \
1142 "4: sub %1,%2,%1\n\t" \
1143 "5: addxcc %1,%1,%1\n\t" \
1145 "subcc %%g1,1,%%g1\n\t" \
1146 "! Got carry from n. Subtract next step to cancel this carry.\n\t" \
1148 "addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n\t" \
1149 "sub %1,%2,%1\n\t" \
1150 "3: xnor %0,0,%0\n\t" \
1151 "! End of inline udiv_qrnnd\n" \
1152 : "=&r" ((USItype)(q)), \
1153 "=&r" ((USItype)(r)) \
1154 : "r" ((USItype)(d)), \
1155 "1" ((USItype)(n1)), \
1156 "0" ((USItype)(n0)) : "%g1", "cc")
1157 #define UDIV_TIME (3+7*32)
1164 #if defined(__vax__) && W_TYPE_SIZE == 32
1165 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1166 __asm__ ("addl2 %5,%1\n" \
1168 : "=g" ((USItype)(sh)), \
1169 "=&g" ((USItype)(sl)) \
1170 : "%0" ((USItype)(ah)), \
1171 "g" ((USItype)(bh)), \
1172 "%1" ((USItype)(al)), \
1173 "g" ((USItype)(bl)))
1174 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1175 __asm__ ("subl2 %5,%1\n" \
1177 : "=g" ((USItype)(sh)), \
1178 "=&g" ((USItype)(sl)) \
1179 : "0" ((USItype)(ah)), \
1180 "g" ((USItype)(bh)), \
1181 "1" ((USItype)(al)), \
1182 "g" ((USItype)(bl)))
1183 #define umul_ppmm(xh, xl, m0, m1) \
1185 union {UDItype __ll; \
1186 struct {USItype __l, __h; } __i; \
1188 USItype __m0 = (m0), __m1 = (m1); \
1189 __asm__ ("emul %1,%2,$0,%0" \
1190 : "=g" (__xx.__ll) \
1193 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
1194 (xh) += ((((SItype) __m0 >> 31) & __m1) \
1195 + (((SItype) __m1 >> 31) & __m0)); \
1197 #define sdiv_qrnnd(q, r, n1, n0, d) \
1199 union {DItype __ll; \
1200 struct {SItype __l, __h; } __i; \
1202 __xx.__i.__h = n1; __xx.__i.__l = n0; \
1203 __asm__ ("ediv %3,%2,%0,%1" \
1204 : "=g" (q), "=g" (r) \
1205 : "g" (__xx.__ll), "g" (d)); \
1212 #if defined(__z8000__) && W_TYPE_SIZE == 16
1213 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1214 __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
1215 : "=r" ((unsigned int)(sh)), \
1216 "=&r" ((unsigned int)(sl)) \
1217 : "%0" ((unsigned int)(ah)), \
1218 "r" ((unsigned int)(bh)), \
1219 "%1" ((unsigned int)(al)), \
1220 "rQR" ((unsigned int)(bl)))
1221 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1222 __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
1223 : "=r" ((unsigned int)(sh)), \
1224 "=&r" ((unsigned int)(sl)) \
1225 : "0" ((unsigned int)(ah)), \
1226 "r" ((unsigned int)(bh)), \
1227 "1" ((unsigned int)(al)), \
1228 "rQR" ((unsigned int)(bl)))
1229 #define umul_ppmm(xh, xl, m0, m1) \
1231 union {long int __ll; \
1232 struct {unsigned int __h, __l; } __i; \
1234 unsigned int __m0 = (m0), __m1 = (m1); \
1235 __asm__ ("mult %S0,%H3" \
1236 : "=r" (__xx.__i.__h), \
1237 "=r" (__xx.__i.__l) \
1240 (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
1241 (xh) += ((((signed int) __m0 >> 15) & __m1) \
1242 + (((signed int) __m1 >> 15) & __m0)); \
1251 #if !defined(umul_ppmm) && defined(__umulsidi3)
1252 #define umul_ppmm(ph, pl, m0, m1) \
1254 UDWtype __ll = __umulsidi3(m0, m1); \
1255 ph = (UWtype) (__ll >> W_TYPE_SIZE); \
1256 pl = (UWtype) __ll; \
1260 #if !defined(__umulsidi3)
1261 #define __umulsidi3(u, v) \
1262 ({UWtype __hi, __lo; \
1263 umul_ppmm(__hi, __lo, u, v); \
1264 ((UDWtype) __hi << W_TYPE_SIZE) | __lo; })
1269 #if !defined(add_ssaaaa)
1270 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
1273 __x = (al) + (bl); \
1274 (sh) = (ah) + (bh) + (__x < (al)); \
1279 #if !defined(sub_ddmmss)
1280 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
1283 __x = (al) - (bl); \
1284 (sh) = (ah) - (bh) - (__x > (al)); \
1289 #if !defined(umul_ppmm)
1290 #define umul_ppmm(w1, w0, u, v) \
1292 UWtype __x0, __x1, __x2, __x3; \
1293 UHWtype __ul, __vl, __uh, __vh; \
1294 UWtype __u = (u), __v = (v); \
1296 __ul = __ll_lowpart(__u); \
1297 __uh = __ll_highpart(__u); \
1298 __vl = __ll_lowpart(__v); \
1299 __vh = __ll_highpart(__v); \
1301 __x0 = (UWtype) __ul * __vl; \
1302 __x1 = (UWtype) __ul * __vh; \
1303 __x2 = (UWtype) __uh * __vl; \
1304 __x3 = (UWtype) __uh * __vh; \
1306 __x1 += __ll_highpart(__x0); \
1311 (w1) = __x3 + __ll_highpart(__x1); \
1312 (w0) = (__ll_lowpart(__x1) << W_TYPE_SIZE/2) + __ll_lowpart(__x0); \
1316 #if !defined(umul_ppmm)
1317 #define smul_ppmm(w1, w0, u, v) \
1320 UWtype __m0 = (u), __m1 = (v); \
1321 umul_ppmm(__w1, w0, __m0, __m1); \
1322 (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1) \
1323 - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0); \
1328 #define __udiv_qrnnd_c(q, r, n1, n0, d) \
1330 UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
1331 __d1 = __ll_highpart(d); \
1332 __d0 = __ll_lowpart(d); \
1334 __r1 = (n1) % __d1; \
1335 __q1 = (n1) / __d1; \
1336 __m = (UWtype) __q1 * __d0; \
1337 __r1 = __r1 * __ll_B | __ll_highpart(n0); \
1339 __q1--, __r1 += (d); \
1342 __q1--, __r1 += (d); \
1346 __r0 = __r1 % __d1; \
1347 __q0 = __r1 / __d1; \
1348 __m = (UWtype) __q0 * __d0; \
1349 __r0 = __r0 * __ll_B | __ll_lowpart(n0); \
1351 __q0--, __r0 += (d); \
1354 __q0--, __r0 += (d); \
1358 (q) = (UWtype) __q1 * __ll_B | __q0; \
1364 #if !defined(udiv_qrnnd) && defined(sdiv_qrnnd)
1365 #define udiv_qrnnd(q, r, nh, nl, d) \
1368 (q) = __MPN(udiv_w_sdiv) (&__r, nh, nl, d); \
1374 #if !defined(udiv_qrnnd)
1375 #define UDIV_NEEDS_NORMALIZATION 1
1376 #define udiv_qrnnd __udiv_qrnnd_c
1379 #ifndef UDIV_NEEDS_NORMALIZATION
1380 #define UDIV_NEEDS_NORMALIZATION 0