llroundl.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 "llroundl.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin llroundl
  41. .text
  42. .align 16,0x90
  43. .globl llroundl
  44. llroundl:
  45. # parameter 1: 48 + %rsp
  46. ..B1.1:
  47. .cfi_startproc
  48. ..___tag_value_llroundl.1:
  49. ..L2:
  50. subq $40, %rsp
  51. .cfi_def_cfa_offset 48
  52. xorb %dl, %dl
  53. ..B1.2:
  54. fnstcw 34(%rsp)
  55. ..B1.3:
  56. movb 57(%rsp), %r8b
  57. lea _range(%rip), %rdi
  58. andb $-128, %r8b
  59. shrb $7, %r8b
  60. movzbl %r8b, %eax
  61. movq %rax, %rsi
  62. shlq $4, %rsi
  63. movzwl 56(%rsp), %r9d
  64. andl $32767, %r9d
  65. movzwl 8(%rsi,%rdi), %ecx
  66. andl $32767, %ecx
  67. cmpl %ecx, %r9d
  68. jl ..B1.8
  69. ..B1.4:
  70. jne ..B1.16
  71. ..B1.5:
  72. movl 52(%rsp), %ecx
  73. cmpl 4(%rsi,%rdi), %ecx
  74. jb ..B1.8
  75. ..B1.6:
  76. jne ..B1.16
  77. ..B1.7:
  78. movl 48(%rsp), %ecx
  79. cmpl (%rsi,%rdi), %ecx
  80. ja ..B1.16
  81. ..B1.8:
  82. cmpl $16383, %r9d
  83. jl ..B1.10
  84. ..B1.9:
  85. movl %r9d, %edi
  86. negl %edi
  87. movl 52(%rsp), %r10d
  88. movl %r10d, %eax
  89. movl 48(%rsp), %edx
  90. movl %edx, %esi
  91. shlq $32, %r10
  92. lea 29(%rdi), %ecx
  93. shrl %cl, %eax
  94. addl $62, %edi
  95. shrl %cl, %esi
  96. cmpl $16414, %r9d
  97. movl %edi, %ecx
  98. cmovl %eax, %esi
  99. orq %rdx, %r10
  100. andl $1, %esi
  101. shrq %cl, %r10
  102. addq %rsi, %r10
  103. movq %r10, %r9
  104. negq %r9
  105. testb %r8b, %r8b
  106. cmovne %r9, %r10
  107. movq %r10, %rax
  108. addq $40, %rsp
  109. .cfi_def_cfa_offset 8
  110. ret
  111. .cfi_def_cfa_offset 48
  112. ..B1.10:
  113. cmpl $16382, %r9d
  114. je ..B1.23
  115. ..B1.11:
  116. testl %r9d, %r9d
  117. jne ..B1.15
  118. ..B1.12:
  119. cmpl $0, 52(%rsp)
  120. jne ..B1.14
  121. ..B1.13:
  122. cmpl $0, 48(%rsp)
  123. je ..B1.15
  124. ..B1.14:
  125. lea _smallest_value_64(%rip), %rax
  126. movq (%rax), %rdx
  127. movq %rdx, (%rsp)
  128. ..B1.15:
  129. xorl %eax, %eax
  130. addq $40, %rsp
  131. .cfi_def_cfa_offset 8
  132. ret
  133. .cfi_def_cfa_offset 48
  134. ..B1.16:
  135. movzwl 34(%rsp), %ecx
  136. movl %ecx, %eax
  137. andl $768, %eax
  138. cmpl $768, %eax
  139. je ..B1.20
  140. ..B1.17:
  141. orl $-64768, %ecx
  142. movw %cx, 32(%rsp)
  143. ..B1.18:
  144. fldcw 32(%rsp)
  145. ..B1.19:
  146. movb $1, %dl
  147. ..B1.20:
  148. lea _infs(%rip), %rax
  149. lea _zeros(%rip), %rcx
  150. testb %dl, %dl
  151. movsd (%rax), %xmm0
  152. mulsd (%rcx), %xmm0
  153. movsd %xmm0, 8(%rsp)
  154. fldl 8(%rsp)
  155. fstpt 16(%rsp)
  156. je ..B1.22
  157. ..B1.21:
  158. fldcw 34(%rsp)
  159. ..B1.22:
  160. movq $0x8000000000000000, %rax
  161. addq $40, %rsp
  162. .cfi_def_cfa_offset 8
  163. ret
  164. .cfi_def_cfa_offset 48
  165. ..B1.23:
  166. lea iones(%rip), %rdx
  167. movslq (%rdx,%rax,4), %rax
  168. addq $40, %rsp
  169. .cfi_def_cfa_offset 8
  170. ret
  171. .align 16,0x90
  172. .cfi_endproc
  173. .type llroundl,@function
  174. .size llroundl,.-llroundl
  175. .data
  176. # -- End llroundl
  177. .section .rodata, "a"
  178. .align 4
  179. .align 4
  180. _smallest_value_64:
  181. .long 1
  182. .long 0
  183. .long 1
  184. .long 2147483648
  185. .type _smallest_value_64,@object
  186. .size _smallest_value_64,16
  187. .align 4
  188. _infs:
  189. .long 0
  190. .long 2146435072
  191. .long 0
  192. .long 4293918720
  193. .type _infs,@object
  194. .size _infs,16
  195. .align 4
  196. _zeros:
  197. .long 0
  198. .long 0
  199. .long 0
  200. .long 2147483648
  201. .type _zeros,@object
  202. .size _zeros,16
  203. .align 4
  204. iones:
  205. .long 1
  206. .long -1
  207. .type iones,@object
  208. .size iones,8
  209. .align 2
  210. _range:
  211. .word 65534
  212. .word 65535
  213. .word 65535
  214. .word 65535
  215. .word 16445
  216. .word 0
  217. .word 0
  218. .word 0
  219. .word 0
  220. .word 0
  221. .word 0
  222. .word 32768
  223. .word 49214
  224. .word 0
  225. .word 0
  226. .word 0
  227. .type _range,@object
  228. .size _range,32
  229. .data
  230. .section .note.GNU-stack, ""
  231. // -- Begin DWARF2 SEGMENT .eh_frame
  232. .section .eh_frame,"a",@progbits
  233. .eh_frame_seg:
  234. .align 1
  235. # End