roundl.S 6.2 KB

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