llrintl.S 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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: 80 + %rsp
  46. ..B1.1:
  47. .cfi_startproc
  48. ..___tag_value_llrintl.1:
  49. ..L2:
  50. pushq %rbx
  51. .cfi_def_cfa_offset 16
  52. .cfi_offset 3, -16
  53. pushq %rbp
  54. .cfi_def_cfa_offset 24
  55. .cfi_offset 6, -24
  56. subq $56, %rsp
  57. .cfi_def_cfa_offset 80
  58. fldt 80(%rsp)
  59. movzbl 89(%rsp), %edi
  60. movzwl 88(%rsp), %r8d
  61. andl $128, %edi
  62. andl $32767, %r8d
  63. shrl $7, %edi
  64. fstpt 32(%rsp)
  65. cmpl $16445, %r8d
  66. jge ..B1.8
  67. ..B1.2:
  68. testl %r8d, %r8d
  69. jne ..B1.6
  70. ..B1.3:
  71. cmpl $0, 84(%rsp)
  72. jne ..B1.5
  73. ..B1.4:
  74. cmpl $0, 80(%rsp)
  75. je ..B1.6
  76. ..B1.5:
  77. lea _smallest_value_64(%rip), %rax
  78. movq (%rax), %rdx
  79. movq %rdx, 8(%rsp)
  80. ..B1.6:
  81. fldt 32(%rsp)
  82. fistpq 16(%rsp)
  83. ..B1.7:
  84. movq 16(%rsp), %rax
  85. addq $56, %rsp
  86. .cfi_def_cfa_offset 24
  87. .cfi_restore 6
  88. popq %rbp
  89. .cfi_def_cfa_offset 16
  90. .cfi_restore 3
  91. popq %rbx
  92. .cfi_def_cfa_offset 8
  93. ret
  94. .cfi_def_cfa_offset 80
  95. .cfi_offset 3, -16
  96. .cfi_offset 6, -24
  97. ..B1.8:
  98. cmpl $16447, %r8d
  99. jge ..B1.21
  100. ..B1.9:
  101. movl %edi, %esi
  102. movq $0x7fffffffffffffff, %rax
  103. addq %rax, %rsi
  104. cmpl $16446, %r8d
  105. jge ..B1.16
  106. ..B1.10:
  107. fnstcw 4(%rsp)
  108. ..B1.11:
  109. movl 80(%rsp), %ebx
  110. movl %ebx, %ebp
  111. movzwl 4(%rsp), %r11d
  112. andl $1, %ebp
  113. movl 84(%rsp), %ecx
  114. andl $3072, %r11d
  115. jne ..B1.13
  116. ..B1.12:
  117. movl %ebx, %eax
  118. andl $3, %ebx
  119. movl %ecx, %edx
  120. movl $1, %r9d
  121. cmpl $3, %ebx
  122. movl $0, %ebx
  123. cmovne %ebx, %r9d
  124. shrl $1, %edx
  125. shll $31, %ecx
  126. shrl $1, %eax
  127. orl %eax, %ecx
  128. shlq $32, %rdx
  129. orq %rcx, %rdx
  130. addq %r9, %rdx
  131. jmp ..B1.17
  132. ..B1.13:
  133. movl $1, %eax
  134. xorl %edx, %edx
  135. cmpl $3072, %r11d
  136. cmove %eax, %edx
  137. xorl %r10d, %r10d
  138. cmpl $2048, %r11d
  139. movl %eax, %r9d
  140. cmove %eax, %r10d
  141. testl %edi, %edi
  142. cmove %edi, %r9d
  143. andl %r9d, %r10d
  144. xorl %r9d, %r9d
  145. cmpl $1024, %r11d
  146. cmove %eax, %r9d
  147. xorl %r11d, %r11d
  148. testl %edi, %edi
  149. cmovne %r11d, %eax
  150. orl %r10d, %edx
  151. andl %eax, %r9d
  152. orl %r9d, %edx
  153. je ..B1.15
  154. ..B1.14:
  155. movl %ecx, %edx
  156. shrl $1, %edx
  157. shll $31, %ecx
  158. shrl $1, %ebx
  159. orl %ebx, %ecx
  160. shlq $32, %rdx
  161. orq %rcx, %rdx
  162. jmp ..B1.17
  163. ..B1.15:
  164. movl %ecx, %edx
  165. movl %ebx, %eax
  166. shrl $1, %edx
  167. shll $31, %ecx
  168. shrl $1, %eax
  169. orl %eax, %ecx
  170. shlq $32, %rdx
  171. orq %rcx, %rdx
  172. andq $1, %rbx
  173. addq %rbx, %rdx
  174. jmp ..B1.17
  175. ..B1.16:
  176. movl 84(%rsp), %edx
  177. xorl %ebp, %ebp
  178. shlq $32, %rdx
  179. movl 80(%rsp), %eax
  180. orq %rax, %rdx
  181. ..B1.17:
  182. movq %rdx, %rax
  183. xorl %ecx, %ecx
  184. negq %rax
  185. testl %edi, %edi
  186. cmove %rdx, %rax
  187. cmpq %rdx, %rax
  188. setae %cl
  189. cmpq %rsi, %rdx
  190. movl $0, %edx
  191. setbe %dl
  192. testl %edx, %ecx
  193. je ..B1.21
  194. ..B1.18:
  195. testl %ebp, %ebp
  196. je ..B1.20
  197. ..B1.19:
  198. lea _ones(%rip), %rdx
  199. lea _small_value_64(%rip), %rcx
  200. movq %rax, 16(%rsp)
  201. movsd (%rdx), %xmm0
  202. addsd (%rcx), %xmm0
  203. movsd %xmm0, 8(%rsp)
  204. ..B1.20:
  205. addq $56, %rsp
  206. .cfi_def_cfa_offset 24
  207. .cfi_restore 6
  208. popq %rbp
  209. .cfi_def_cfa_offset 16
  210. .cfi_restore 3
  211. popq %rbx
  212. .cfi_def_cfa_offset 8
  213. ret
  214. .cfi_def_cfa_offset 80
  215. .cfi_offset 3, -16
  216. .cfi_offset 6, -24
  217. ..B1.21:
  218. lea _infs(%rip), %rax
  219. lea _zeros(%rip), %rdx
  220. movq $0x8000000000000000, %rcx
  221. cmpl $32767, %r8d
  222. movq %rcx, 16(%rsp)
  223. movsd (%rax), %xmm0
  224. mulsd (%rdx), %xmm0
  225. movsd %xmm0, 8(%rsp)
  226. jne ..B1.24
  227. ..B1.22:
  228. cmpl $-2147483648, 84(%rsp)
  229. jne ..B1.29
  230. ..B1.23:
  231. cmpl $0, 80(%rsp)
  232. jne ..B1.29
  233. ..B1.24:
  234. fnstcw 2(%rsp)
  235. ..B1.25:
  236. movzwl 2(%rsp), %edx
  237. movl %edx, %eax
  238. andl $768, %eax
  239. cmpl $768, %eax
  240. je ..B1.29
  241. ..B1.26:
  242. orl $-64768, %edx
  243. movw %dx, (%rsp)
  244. ..B1.27:
  245. fldcw (%rsp)
  246. ..B1.28:
  247. fldcw 2(%rsp)
  248. ..B1.29:
  249. movq 16(%rsp), %rax
  250. addq $56, %rsp
  251. .cfi_def_cfa_offset 24
  252. .cfi_restore 6
  253. popq %rbp
  254. .cfi_def_cfa_offset 16
  255. .cfi_restore 3
  256. popq %rbx
  257. .cfi_def_cfa_offset 8
  258. ret
  259. .align 16,0x90
  260. .cfi_endproc
  261. .type llrintl,@function
  262. .size llrintl,.-llrintl
  263. .data
  264. # -- End llrintl
  265. .section .rodata, "a"
  266. .align 4
  267. .align 4
  268. _smallest_value_64:
  269. .long 1
  270. .long 0
  271. .long 1
  272. .long 2147483648
  273. .type _smallest_value_64,@object
  274. .size _smallest_value_64,16
  275. .align 4
  276. _ones:
  277. .long 0
  278. .long 1072693248
  279. .long 0
  280. .long 3220176896
  281. .type _ones,@object
  282. .size _ones,16
  283. .align 4
  284. _small_value_64:
  285. .long 0
  286. .long 24117248
  287. .long 0
  288. .long 2171600896
  289. .type _small_value_64,@object
  290. .size _small_value_64,16
  291. .align 4
  292. _infs:
  293. .long 0
  294. .long 2146435072
  295. .long 0
  296. .long 4293918720
  297. .type _infs,@object
  298. .size _infs,16
  299. .align 4
  300. _zeros:
  301. .long 0
  302. .long 0
  303. .long 0
  304. .long 2147483648
  305. .type _zeros,@object
  306. .size _zeros,16
  307. .data
  308. .section .note.GNU-stack, ""
  309. // -- Begin DWARF2 SEGMENT .eh_frame
  310. .section .eh_frame,"a",@progbits
  311. .eh_frame_seg:
  312. .align 1
  313. # End