nexttoward_wmt.S 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Math library
  3. *
  4. * Copyright (C) 2016 Intel Corporation. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Intel Corporation nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *
  33. * Author Name <jingwei.zhang@intel.com>
  34. * History:
  35. * 03-14-2016 Initial version. numerics svn rev. 12864
  36. */
  37. .file "nexttoward_wmt.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin nexttoward
  41. .text
  42. .align 16,0x90
  43. .globl nexttoward
  44. nexttoward:
  45. # parameter 1: 8 + %ebp
  46. # parameter 2: 16 + %ebp
  47. ..B1.1:
  48. ..L1:
  49. pushl %ebp
  50. movl %esp, %ebp
  51. andl $-16, %esp
  52. pushl %esi
  53. pushl %edi
  54. pushl %ebx
  55. subl $20, %esp
  56. movzwl 14(%ebp), %eax
  57. andl $32752, %eax
  58. cmpl $32752, %eax
  59. je ..B1.23
  60. ..B1.2:
  61. movzwl 24(%ebp), %ebx
  62. andl $32767, %ebx
  63. cmpl $32767, %ebx
  64. je ..B1.20
  65. ..B1.3:
  66. fldl 8(%ebp)
  67. fldt 16(%ebp)
  68. fucom %st(1)
  69. fnstsw %ax
  70. sahf
  71. jp ..B1.4
  72. je ..B1.25
  73. ..B1.4:
  74. fstp %st(0)
  75. movl 12(%ebp), %ecx
  76. movl %ecx, %eax
  77. andl $2147483647, %eax
  78. call ..L2
  79. ..L2:
  80. popl %edx
  81. lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%edx), %edx
  82. orl 8(%ebp), %eax
  83. je ..B1.19
  84. ..B1.5:
  85. fstpt 8(%esp)
  86. movzbl 17(%esp), %edi
  87. movzbl 25(%ebp), %esi
  88. andl $128, %edi
  89. andl $128, %esi
  90. shrl $7, %edi
  91. shrl $7, %esi
  92. movl 8(%ebp), %eax
  93. cmpl %edi, %esi
  94. jne ..B1.11
  95. ..B1.6:
  96. movzwl 16(%esp), %esi
  97. andl $32767, %esi
  98. cmpl %ebx, %esi
  99. jg ..B1.11
  100. ..B1.7:
  101. jne ..B1.12
  102. ..B1.8:
  103. movl 12(%esp), %ebx
  104. movl 20(%ebp), %esi
  105. cmpl %esi, %ebx
  106. ja ..B1.11
  107. ..B1.9:
  108. jne ..B1.12
  109. ..B1.10:
  110. movl 8(%esp), %ebx
  111. cmpl 16(%ebp), %ebx
  112. jbe ..B1.12
  113. ..B1.11:
  114. addl $-1, %eax
  115. movl %eax, 8(%esp)
  116. adcl $-1, %ecx
  117. movl %ecx, 12(%esp)
  118. jmp ..B1.13
  119. ..B1.12:
  120. addl $1, %eax
  121. movl %eax, 8(%esp)
  122. adcl $0, %ecx
  123. movl %ecx, 12(%esp)
  124. ..B1.13:
  125. movl 12(%esp), %ecx
  126. andl $2147483647, %ecx
  127. lea -1048576(%ecx), %eax
  128. cmpl $2145386496, %eax
  129. jb ..B1.18
  130. ..B1.14:
  131. cmpl $1048576, %ecx
  132. jae ..B1.16
  133. ..B1.15:
  134. fldl _small_value_64@GOTOFF(%edx)
  135. fmul %st(0), %st
  136. fstpl (%esp)
  137. fldl 8(%esp)
  138. addl $20, %esp
  139. popl %ebx
  140. popl %edi
  141. popl %esi
  142. movl %ebp, %esp
  143. popl %ebp
  144. ret
  145. ..B1.16:
  146. fldl _large_value_64@GOTOFF(%edx)
  147. fmul %st(0), %st
  148. fstpl (%esp)
  149. fldl 8(%esp)
  150. ..B1.17:
  151. addl $20, %esp
  152. popl %ebx
  153. popl %edi
  154. popl %esi
  155. movl %ebp, %esp
  156. popl %ebp
  157. ret
  158. ..B1.18:
  159. fldl 8(%esp)
  160. addl $20, %esp
  161. popl %ebx
  162. popl %edi
  163. popl %esi
  164. movl %ebp, %esp
  165. popl %ebp
  166. ret
  167. ..B1.19:
  168. fstp %st(0)
  169. movzbl 25(%ebp), %eax
  170. fldl _small_value_64@GOTOFF(%edx)
  171. andl $128, %eax
  172. shrl $7, %eax
  173. fmul %st(0), %st
  174. movl _smallest_value_64@GOTOFF(%edx,%eax,8), %ecx
  175. movl 4+_smallest_value_64@GOTOFF(%edx,%eax,8), %ebx
  176. movl %ecx, 8(%esp)
  177. movl %ebx, 12(%esp)
  178. fstpl (%esp)
  179. jmp ..B1.18
  180. ..B1.20:
  181. cmpl $-2147483648, 20(%ebp)
  182. jne ..B1.22
  183. ..B1.21:
  184. cmpl $0, 16(%ebp)
  185. je ..B1.3
  186. ..B1.22:
  187. fldt 16(%ebp)
  188. fmull 8(%ebp)
  189. addl $20, %esp
  190. popl %ebx
  191. popl %edi
  192. popl %esi
  193. movl %ebp, %esp
  194. popl %ebp
  195. ret
  196. ..B1.23:
  197. testl $1048575, 12(%ebp)
  198. jne ..B1.22
  199. ..B1.24:
  200. cmpl $0, 8(%ebp)
  201. jne ..B1.22
  202. jmp ..B1.2
  203. ..B1.25:
  204. fstp %st(1)
  205. addl $20, %esp
  206. popl %ebx
  207. popl %edi
  208. popl %esi
  209. movl %ebp, %esp
  210. popl %ebp
  211. ret
  212. .align 16,0x90
  213. .type nexttoward,@function
  214. .size nexttoward,.-nexttoward
  215. .data
  216. # -- End nexttoward
  217. .section .rodata, "a"
  218. .align 4
  219. .align 4
  220. _small_value_64:
  221. .long 0
  222. .long 24117248
  223. .long 0
  224. .long 2171600896
  225. .type _small_value_64,@object
  226. .size _small_value_64,16
  227. .align 4
  228. _large_value_64:
  229. .long 0
  230. .long 2121269248
  231. .long 0
  232. .long 4268752896
  233. .type _large_value_64,@object
  234. .size _large_value_64,16
  235. .align 4
  236. _smallest_value_64:
  237. .long 1
  238. .long 0
  239. .long 1
  240. .long 2147483648
  241. .type _smallest_value_64,@object
  242. .size _smallest_value_64,16
  243. .data
  244. .section .note.GNU-stack, ""
  245. # End