roundl.S 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 "roundl.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin roundl
  41. .text
  42. .align 16,0x90
  43. .globl roundl
  44. roundl:
  45. # parameter 1: 8 + %ebp
  46. ..B1.1:
  47. ..L1:
  48. pushl %ebp
  49. movl %esp, %ebp
  50. andl $-16, %esp
  51. pushl %esi
  52. pushl %edi
  53. subl $24, %esp
  54. ..B1.2:
  55. fnstcw 14(%esp)
  56. ..B1.3:
  57. movzwl 16(%ebp), %eax
  58. andl $32767, %eax
  59. call ..L2
  60. ..L2:
  61. popl %esi
  62. lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%esi), %esi
  63. cmpl $16446, %eax
  64. jge ..B1.25
  65. ..B1.4:
  66. cmpl $16383, %eax
  67. jl ..B1.19
  68. ..B1.5:
  69. cmpl $16414, %eax
  70. jge ..B1.7
  71. ..B1.6:
  72. movl 12(%ebp), %edi
  73. lea 2(%eax), %ecx
  74. negl %eax
  75. movl %edi, %edx
  76. addl $30, %eax
  77. shll %cl, %edx
  78. movl %eax, %ecx
  79. shrl %cl, %edi
  80. shll %cl, %edi
  81. movl %edi, 12(%ebp)
  82. movl $0, 8(%ebp)
  83. jmp ..B1.10
  84. ..B1.7:
  85. jle ..B1.9
  86. ..B1.8:
  87. movl 8(%ebp), %edi
  88. lea 2(%eax), %ecx
  89. negl %eax
  90. movl %edi, %edx
  91. addl $30, %eax
  92. shll %cl, %edx
  93. movl %eax, %ecx
  94. shrl %cl, %edi
  95. shll %cl, %edi
  96. movl %edi, 8(%ebp)
  97. jmp ..B1.10
  98. ..B1.9:
  99. movl 8(%ebp), %edx
  100. movl $0, 8(%ebp)
  101. ..B1.10:
  102. testl %edx, %edx
  103. jge ..B1.18
  104. ..B1.11:
  105. movzwl 14(%esp), %edx
  106. movl %edx, %eax
  107. andl $768, %eax
  108. cmpl $768, %eax
  109. je ..B1.31
  110. ..B1.12:
  111. orl $-64768, %edx
  112. movw %dx, 12(%esp)
  113. ..B1.13:
  114. fldcw 12(%esp)
  115. ..B1.14:
  116. movl $1, %edx
  117. ..B1.15:
  118. fldt 8(%ebp)
  119. movzbl 17(%ebp), %eax
  120. andl $128, %eax
  121. shrl $7, %eax
  122. testl %edx, %edx
  123. faddl _ones@GOTOFF(%esi,%eax,8)
  124. fstpt (%esp)
  125. je ..B1.17
  126. ..B1.16:
  127. fldcw 14(%esp)
  128. ..B1.17:
  129. fldt (%esp)
  130. addl $24, %esp
  131. popl %edi
  132. popl %esi
  133. movl %ebp, %esp
  134. popl %ebp
  135. ret
  136. ..B1.18:
  137. fldt 8(%ebp)
  138. addl $24, %esp
  139. popl %edi
  140. popl %esi
  141. movl %ebp, %esp
  142. popl %ebp
  143. ret
  144. ..B1.19:
  145. cmpl $16382, %eax
  146. je ..B1.33
  147. ..B1.20:
  148. testl %eax, %eax
  149. jne ..B1.24
  150. ..B1.21:
  151. cmpl $0, 12(%ebp)
  152. jne ..B1.23
  153. ..B1.22:
  154. cmpl $0, 8(%ebp)
  155. je ..B1.24
  156. ..B1.23:
  157. fldl _smallest_value_64@GOTOFF(%esi)
  158. fstpl 16(%esp)
  159. ..B1.24:
  160. movzbl 17(%ebp), %eax
  161. andl $128, %eax
  162. shrl $7, %eax
  163. fldl _zeros@GOTOFF(%esi,%eax,8)
  164. addl $24, %esp
  165. popl %edi
  166. popl %esi
  167. movl %ebp, %esp
  168. popl %ebp
  169. ret
  170. ..B1.25:
  171. movzwl 14(%esp), %edx
  172. movl %edx, %eax
  173. andl $768, %eax
  174. cmpl $768, %eax
  175. je ..B1.32
  176. ..B1.26:
  177. orl $-64768, %edx
  178. movw %dx, 12(%esp)
  179. ..B1.27:
  180. fldcw 12(%esp)
  181. ..B1.28:
  182. fldt 8(%ebp)
  183. fmull _ones@GOTOFF(%esi)
  184. fstpt (%esp)
  185. ..B1.29:
  186. fldcw 14(%esp)
  187. ..B1.30:
  188. fldt (%esp)
  189. addl $24, %esp
  190. popl %edi
  191. popl %esi
  192. movl %ebp, %esp
  193. popl %ebp
  194. ret
  195. ..B1.31:
  196. xorl %edx, %edx
  197. jmp ..B1.15
  198. ..B1.32:
  199. fldt 8(%ebp)
  200. fmull _ones@GOTOFF(%esi)
  201. fstpt (%esp)
  202. jmp ..B1.30
  203. ..B1.33:
  204. movzbl 17(%ebp), %eax
  205. andl $128, %eax
  206. shrl $7, %eax
  207. fldl _ones@GOTOFF(%esi,%eax,8)
  208. addl $24, %esp
  209. popl %edi
  210. popl %esi
  211. movl %ebp, %esp
  212. popl %ebp
  213. ret
  214. .align 16,0x90
  215. .type roundl,@function
  216. .size roundl,.-roundl
  217. .data
  218. # -- End roundl
  219. .section .rodata, "a"
  220. .align 4
  221. .align 4
  222. _ones:
  223. .long 0
  224. .long 1072693248
  225. .long 0
  226. .long 3220176896
  227. .type _ones,@object
  228. .size _ones,16
  229. .align 4
  230. _smallest_value_64:
  231. .long 1
  232. .long 0
  233. .long 1
  234. .long 2147483648
  235. .type _smallest_value_64,@object
  236. .size _smallest_value_64,16
  237. .align 4
  238. _zeros:
  239. .long 0
  240. .long 0
  241. .long 0
  242. .long 2147483648
  243. .type _zeros,@object
  244. .size _zeros,16
  245. .data
  246. .section .note.GNU-stack, ""
  247. # End