llrintl.S 8.5 KB

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