Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
6.2 KiB

  1. .file "ceilf.s"
  2. // Copyright (c) 2000, Intel Corporation
  3. // All rights reserved.
  4. //
  5. // Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
  6. // and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation.
  7. //
  8. // WARRANTY DISCLAIMER
  9. //
  10. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  11. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  12. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  13. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
  14. // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  15. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17. // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  18. // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
  19. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. //
  22. // Intel Corporation is the author of this code, and requests that all
  23. // problem reports or change requests be submitted to it directly at
  24. // http://developer.intel.com/opensource.
  25. //
  26. .align 32
  27. .global ceilf#
  28. .section .text
  29. .proc ceilf#
  30. .align 32
  31. // History
  32. //==============================================================
  33. // 2/02/00: Initial version
  34. // 6/13/00: Improved speed
  35. // 6/27/00: Eliminated incorrect invalid flag setting
  36. // API
  37. //==============================================================
  38. // float ceilf(float x)
  39. // general input registers:
  40. ceil_GR_FFFF = r14
  41. ceil_GR_signexp = r15
  42. ceil_GR_exponent = r16
  43. ceil_GR_expmask = r17
  44. ceil_GR_bigexp = r18
  45. // predicate registers used:
  46. // p6 ==> Input is NaN, infinity, zero
  47. // p7 ==> Input is denormal
  48. // p8 ==> Input is <0
  49. // p9 ==> Input is >=0
  50. // p10 ==> Input is already an integer (bigger than largest integer)
  51. // p11 ==> Input is not a large integer
  52. // p12 ==> Input is a smaller integer
  53. // p13 ==> Input is not an even integer, so inexact must be set
  54. // p14 ==> Input is between -1 and 0, so result will be -0 and inexact
  55. // floating-point registers used:
  56. CEIL_SIGNED_ZERO = f7
  57. CEIL_NORM_f8 = f9
  58. CEIL_FFFF = f10
  59. CEIL_INEXACT = f11
  60. CEIL_FLOAT_INT_f8 = f12
  61. CEIL_INT_f8 = f13
  62. CEIL_adj = f14
  63. CEIL_MINUS_ONE = f15
  64. // Overview of operation
  65. //==============================================================
  66. // float ceilf(float x)
  67. // Return an integer value (represented as a float) that is the smallest
  68. // value not less than x
  69. // This is x rounded toward +infinity to an integral value.
  70. // Inexact is set if x != ceilf(x)
  71. // **************************************************************************
  72. // Set denormal flag for denormal input and
  73. // and take denormal fault if necessary.
  74. // Is the input an integer value already?
  75. // double_extended
  76. // if the exponent is > 1003e => 3F(true) = 63(decimal)
  77. // we have a significand of 64 bits 1.63-bits.
  78. // If we multiply by 2^63, we no longer have a fractional part
  79. // So input is an integer value already.
  80. // double
  81. // if the exponent is >= 10033 => 34(true) = 52(decimal)
  82. // 34 + 3ff = 433
  83. // we have a significand of 53 bits 1.52-bits. (implicit 1)
  84. // If we multiply by 2^52, we no longer have a fractional part
  85. // So input is an integer value already.
  86. // single
  87. // if the exponent is > 10016 => 17(true) = 23(decimal)
  88. // we have a significand of 24 bits 1.23-bits. (implicit 1)
  89. // If we multiply by 2^23, we no longer have a fractional part
  90. // So input is an integer value already.
  91. // If x is NAN, ZERO, or INFINITY, then return
  92. // qnan snan inf norm unorm 0 -+
  93. // 1 1 1 0 0 1 11 0xe7
  94. ceilf:
  95. { .mfi
  96. getf.exp ceil_GR_signexp = f8
  97. fcvt.fx.trunc.s1 CEIL_INT_f8 = f8
  98. addl ceil_GR_bigexp = 0x10016, r0
  99. }
  100. { .mfi
  101. addl ceil_GR_FFFF = -1,r0
  102. fcmp.lt.s1 p8,p9 = f8,f0
  103. mov ceil_GR_expmask = 0x1FFFF ;;
  104. }
  105. // p7 ==> denorm
  106. { .mfi
  107. setf.sig CEIL_FFFF = ceil_GR_FFFF
  108. fclass.m p7,p0 = f8, 0x0b
  109. nop.i 999
  110. }
  111. { .mfi
  112. nop.m 999
  113. fnorm CEIL_NORM_f8 = f8
  114. nop.i 999 ;;
  115. }
  116. // Form 0 with sign of input in case negative zero is needed
  117. { .mfi
  118. nop.m 999
  119. fmerge.s CEIL_SIGNED_ZERO = f8, f0
  120. nop.i 999
  121. }
  122. { .mfi
  123. nop.m 999
  124. fsub.s1 CEIL_MINUS_ONE = f0, f1
  125. nop.i 999 ;;
  126. }
  127. // p6 ==> NAN, INF, ZERO
  128. { .mfb
  129. nop.m 999
  130. fclass.m p6,p10 = f8, 0xe7
  131. (p7) br.cond.spnt CEIL_DENORM ;;
  132. }
  133. .pred.rel "mutex",p8,p9
  134. CEIL_COMMON:
  135. // Set adjustment to add to trunc(x) for result
  136. // If x>0, adjustment is 1.0
  137. // If x<=0, adjustment is 0.0
  138. { .mfi
  139. and ceil_GR_exponent = ceil_GR_signexp, ceil_GR_expmask
  140. (p9) fadd.s1 CEIL_adj = f1,f0
  141. nop.i 999
  142. }
  143. { .mfi
  144. nop.m 999
  145. (p8) fadd.s1 CEIL_adj = f0,f0
  146. nop.i 999 ;;
  147. }
  148. { .mfi
  149. (p10) cmp.ge.unc p10,p11 = ceil_GR_exponent, ceil_GR_bigexp
  150. (p6) fnorm.s f8 = f8
  151. nop.i 999 ;;
  152. }
  153. { .mfi
  154. nop.m 999
  155. (p11) fcvt.xf CEIL_FLOAT_INT_f8 = CEIL_INT_f8
  156. nop.i 999 ;;
  157. }
  158. { .mfi
  159. nop.m 999
  160. (p10) fnorm.s f8 = CEIL_NORM_f8
  161. nop.i 999 ;;
  162. }
  163. // Is -1 < x < 0? If so, result will be -0. Special case it with p14 set.
  164. { .mfi
  165. nop.m 999
  166. (p8) fcmp.gt.unc.s1 p14,p0 = CEIL_NORM_f8, CEIL_MINUS_ONE
  167. nop.i 999 ;;
  168. }
  169. { .mfi
  170. (p14) cmp.ne p11,p0 = r0,r0
  171. (p14) fnorm.s f8 = CEIL_SIGNED_ZERO
  172. nop.i 999
  173. }
  174. { .mfi
  175. nop.m 999
  176. (p14) fmpy.s0 CEIL_INEXACT = CEIL_FFFF,CEIL_FFFF
  177. nop.i 999 ;;
  178. }
  179. { .mfi
  180. nop.m 999
  181. (p11) fadd.s f8 = CEIL_FLOAT_INT_f8,CEIL_adj
  182. nop.i 999 ;;
  183. }
  184. { .mfi
  185. nop.m 999
  186. (p11) fcmp.eq.unc.s1 p12,p13 = CEIL_FLOAT_INT_f8, CEIL_NORM_f8
  187. nop.i 999 ;;
  188. }
  189. // Set inexact if result not equal to input
  190. { .mfi
  191. nop.m 999
  192. (p13) fmpy.s0 CEIL_INEXACT = CEIL_FFFF,CEIL_FFFF
  193. nop.i 999
  194. }
  195. // Set result to input if integer
  196. { .mfb
  197. nop.m 999
  198. (p12) fnorm.s f8 = CEIL_NORM_f8
  199. br.ret.sptk b0 ;;
  200. }
  201. // Here if input denorm
  202. CEIL_DENORM:
  203. { .mfb
  204. getf.exp ceil_GR_signexp = CEIL_NORM_f8
  205. fcvt.fx.trunc.s1 CEIL_INT_f8 = CEIL_NORM_f8
  206. br.cond.sptk CEIL_COMMON ;;
  207. }
  208. .endp ceilf