lroundl.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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: 48 + %rsp
  46. ..B1.1:
  47. .cfi_startproc
  48. ..___tag_value_lroundl.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. lea lres_maxmin(%rip), %rcx
  136. movq (%rcx,%rax,8), %rax
  137. movzwl 34(%rsp), %ecx
  138. movl %ecx, %esi
  139. andl $768, %esi
  140. cmpl $768, %esi
  141. je ..B1.20
  142. ..B1.17:
  143. orl $-64768, %ecx
  144. movw %cx, 32(%rsp)
  145. ..B1.18:
  146. fldcw 32(%rsp)
  147. ..B1.19:
  148. movb $1, %dl
  149. ..B1.20:
  150. lea _infs(%rip), %rcx
  151. lea _zeros(%rip), %rsi
  152. testb %dl, %dl
  153. movsd (%rcx), %xmm0
  154. mulsd (%rsi), %xmm0
  155. movsd %xmm0, 8(%rsp)
  156. fldl 8(%rsp)
  157. fstpt 16(%rsp)
  158. je ..B1.22
  159. ..B1.21:
  160. fldcw 34(%rsp)
  161. ..B1.22:
  162. addq $40, %rsp
  163. .cfi_def_cfa_offset 8
  164. ret
  165. .cfi_def_cfa_offset 48
  166. ..B1.23:
  167. lea iones(%rip), %rdx
  168. movslq (%rdx,%rax,4), %rax
  169. addq $40, %rsp
  170. .cfi_def_cfa_offset 8
  171. ret
  172. .align 16,0x90
  173. .cfi_endproc
  174. .type lroundl,@function
  175. .size lroundl,.-lroundl
  176. .data
  177. # -- End lroundl
  178. .section .rodata, "a"
  179. .align 8
  180. .align 8
  181. lres_maxmin:
  182. .long 0xffffffff,0x7fffffff
  183. .long 0x00000000,0x80000000
  184. .type lres_maxmin,@object
  185. .size lres_maxmin,16
  186. .align 4
  187. _smallest_value_64:
  188. .long 1
  189. .long 0
  190. .long 1
  191. .long 2147483648
  192. .type _smallest_value_64,@object
  193. .size _smallest_value_64,16
  194. .align 4
  195. _infs:
  196. .long 0
  197. .long 2146435072
  198. .long 0
  199. .long 4293918720
  200. .type _infs,@object
  201. .size _infs,16
  202. .align 4
  203. _zeros:
  204. .long 0
  205. .long 0
  206. .long 0
  207. .long 2147483648
  208. .type _zeros,@object
  209. .size _zeros,16
  210. .align 4
  211. iones:
  212. .long 1
  213. .long -1
  214. .type iones,@object
  215. .size iones,8
  216. .align 2
  217. _range:
  218. .word 65534
  219. .word 65535
  220. .word 65535
  221. .word 65535
  222. .word 16445
  223. .word 0
  224. .word 0
  225. .word 0
  226. .word 0
  227. .word 0
  228. .word 0
  229. .word 32768
  230. .word 49214
  231. .word 0
  232. .word 0
  233. .word 0
  234. .type _range,@object
  235. .size _range,32
  236. .data
  237. .section .note.GNU-stack, ""
  238. // -- Begin DWARF2 SEGMENT .eh_frame
  239. .section .eh_frame,"a",@progbits
  240. .eh_frame_seg:
  241. .align 1
  242. # End