lroundl.S 6.4 KB

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