lrintl.S 7.3 KB

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