remainderl.S 7.6 KB

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