modfl.S 6.6 KB

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