sfp-util_64.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * arch/sparc64/math-emu/sfp-util.h
  3. *
  4. * Copyright (C) 1999 Jakub Jelinek (jj@ultra.linux.cz)
  5. * Copyright (C) 1999 David S. Miller (davem@redhat.com)
  6. *
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/sched.h>
  10. #include <linux/types.h>
  11. #include <asm/byteorder.h>
  12. #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  13. __asm__ ("addcc %4,%5,%1\n\t" \
  14. "add %2,%3,%0\n\t" \
  15. "bcs,a,pn %%xcc, 1f\n\t" \
  16. "add %0, 1, %0\n" \
  17. "1:" \
  18. : "=r" (sh), \
  19. "=&r" (sl) \
  20. : "r" ((UDItype)(ah)), \
  21. "r" ((UDItype)(bh)), \
  22. "r" ((UDItype)(al)), \
  23. "r" ((UDItype)(bl)) \
  24. : "cc")
  25. #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  26. __asm__ ("subcc %4,%5,%1\n\t" \
  27. "sub %2,%3,%0\n\t" \
  28. "bcs,a,pn %%xcc, 1f\n\t" \
  29. "sub %0, 1, %0\n" \
  30. "1:" \
  31. : "=r" (sh), \
  32. "=&r" (sl) \
  33. : "r" ((UDItype)(ah)), \
  34. "r" ((UDItype)(bh)), \
  35. "r" ((UDItype)(al)), \
  36. "r" ((UDItype)(bl)) \
  37. : "cc")
  38. #define umul_ppmm(wh, wl, u, v) \
  39. do { \
  40. UDItype tmp1, tmp2, tmp3, tmp4; \
  41. __asm__ __volatile__ ( \
  42. "srl %7,0,%3\n\t" \
  43. "mulx %3,%6,%1\n\t" \
  44. "srlx %6,32,%2\n\t" \
  45. "mulx %2,%3,%4\n\t" \
  46. "sllx %4,32,%5\n\t" \
  47. "srl %6,0,%3\n\t" \
  48. "sub %1,%5,%5\n\t" \
  49. "srlx %5,32,%5\n\t" \
  50. "addcc %4,%5,%4\n\t" \
  51. "srlx %7,32,%5\n\t" \
  52. "mulx %3,%5,%3\n\t" \
  53. "mulx %2,%5,%5\n\t" \
  54. "sethi %%hi(0x80000000),%2\n\t" \
  55. "addcc %4,%3,%4\n\t" \
  56. "srlx %4,32,%4\n\t" \
  57. "add %2,%2,%2\n\t" \
  58. "movcc %%xcc,%%g0,%2\n\t" \
  59. "addcc %5,%4,%5\n\t" \
  60. "sllx %3,32,%3\n\t" \
  61. "add %1,%3,%1\n\t" \
  62. "add %5,%2,%0" \
  63. : "=r" (wh), \
  64. "=&r" (wl), \
  65. "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
  66. : "r" ((UDItype)(u)), \
  67. "r" ((UDItype)(v)) \
  68. : "cc"); \
  69. } while (0)
  70. #define udiv_qrnnd(q, r, n1, n0, d) \
  71. do { \
  72. UWtype __d1, __d0, __q1, __q0, __r1, __r0, __m; \
  73. __d1 = (d >> 32); \
  74. __d0 = (USItype)d; \
  75. \
  76. __r1 = (n1) % __d1; \
  77. __q1 = (n1) / __d1; \
  78. __m = (UWtype) __q1 * __d0; \
  79. __r1 = (__r1 << 32) | (n0 >> 32); \
  80. if (__r1 < __m) \
  81. { \
  82. __q1--, __r1 += (d); \
  83. if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */ \
  84. if (__r1 < __m) \
  85. __q1--, __r1 += (d); \
  86. } \
  87. __r1 -= __m; \
  88. \
  89. __r0 = __r1 % __d1; \
  90. __q0 = __r1 / __d1; \
  91. __m = (UWtype) __q0 * __d0; \
  92. __r0 = (__r0 << 32) | ((USItype)n0); \
  93. if (__r0 < __m) \
  94. { \
  95. __q0--, __r0 += (d); \
  96. if (__r0 >= (d)) \
  97. if (__r0 < __m) \
  98. __q0--, __r0 += (d); \
  99. } \
  100. __r0 -= __m; \
  101. \
  102. (q) = (UWtype) (__q1 << 32) | __q0; \
  103. (r) = __r0; \
  104. } while (0)
  105. #define UDIV_NEEDS_NORMALIZATION 1
  106. #define abort() \
  107. return 0
  108. #ifdef __BIG_ENDIAN
  109. #define __BYTE_ORDER __BIG_ENDIAN
  110. #else
  111. #define __BYTE_ORDER __LITTLE_ENDIAN
  112. #endif