truncl.S 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 "truncl.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin truncl
  41. .text
  42. .align 16,0x90
  43. .globl truncl
  44. truncl:
  45. # parameter 1: 48 + %rsp
  46. ..B1.1:
  47. .cfi_startproc
  48. ..___tag_value_truncl.1:
  49. ..L2:
  50. subq $40, %rsp
  51. .cfi_def_cfa_offset 48
  52. ..B1.2:
  53. fnstcw 26(%rsp)
  54. ..B1.3:
  55. movzwl 56(%rsp), %ecx
  56. andl $32767, %ecx
  57. cmpl $16446, %ecx
  58. jge ..B1.14
  59. ..B1.4:
  60. cmpl $16383, %ecx
  61. jl ..B1.9
  62. ..B1.5:
  63. cmpl $16415, %ecx
  64. jge ..B1.7
  65. ..B1.6:
  66. negl %ecx
  67. addl $30, %ecx
  68. movl 52(%rsp), %eax
  69. shrl %cl, %eax
  70. shll %cl, %eax
  71. movl %eax, 52(%rsp)
  72. xorl %eax, %eax
  73. jmp ..B1.8
  74. ..B1.7:
  75. negl %ecx
  76. addl $30, %ecx
  77. movl 48(%rsp), %eax
  78. shrl %cl, %eax
  79. shll %cl, %eax
  80. ..B1.8:
  81. movl %eax, 48(%rsp)
  82. fldt 48(%rsp)
  83. addq $40, %rsp
  84. .cfi_def_cfa_offset 8
  85. ret
  86. .cfi_def_cfa_offset 48
  87. ..B1.9:
  88. testl %ecx, %ecx
  89. jne ..B1.13
  90. ..B1.10:
  91. cmpl $0, 52(%rsp)
  92. jne ..B1.12
  93. ..B1.11:
  94. cmpl $0, 48(%rsp)
  95. je ..B1.13
  96. ..B1.12:
  97. lea _smallest_value_64(%rip), %rax
  98. movq (%rax), %rdx
  99. movq %rdx, (%rsp)
  100. ..B1.13:
  101. movb 57(%rsp), %al
  102. lea _zeros(%rip), %rdx
  103. andb $-128, %al
  104. shrb $7, %al
  105. movzbl %al, %ecx
  106. fldl (%rdx,%rcx,8)
  107. addq $40, %rsp
  108. .cfi_def_cfa_offset 8
  109. ret
  110. .cfi_def_cfa_offset 48
  111. ..B1.14:
  112. movzwl 26(%rsp), %edx
  113. movl %edx, %eax
  114. andl $768, %eax
  115. cmpl $768, %eax
  116. je ..B1.20
  117. ..B1.15:
  118. orl $-64768, %edx
  119. movw %dx, 24(%rsp)
  120. ..B1.16:
  121. fldcw 24(%rsp)
  122. ..B1.17:
  123. fldt 48(%rsp)
  124. lea _ones(%rip), %rax
  125. fmull (%rax)
  126. fstpt 8(%rsp)
  127. ..B1.18:
  128. fldcw 26(%rsp)
  129. ..B1.19:
  130. fldt 8(%rsp)
  131. addq $40, %rsp
  132. .cfi_def_cfa_offset 8
  133. ret
  134. .cfi_def_cfa_offset 48
  135. ..B1.20:
  136. fldt 48(%rsp)
  137. lea _ones(%rip), %rax
  138. fmull (%rax)
  139. fstpt 8(%rsp)
  140. jmp ..B1.19
  141. .align 16,0x90
  142. .cfi_endproc
  143. .type truncl,@function
  144. .size truncl,.-truncl
  145. .data
  146. # -- End truncl
  147. .section .rodata, "a"
  148. .align 4
  149. .align 4
  150. _smallest_value_64:
  151. .long 1
  152. .long 0
  153. .long 1
  154. .long 2147483648
  155. .type _smallest_value_64,@object
  156. .size _smallest_value_64,16
  157. .align 4
  158. _zeros:
  159. .long 0
  160. .long 0
  161. .long 0
  162. .long 2147483648
  163. .type _zeros,@object
  164. .size _zeros,16
  165. .align 4
  166. _ones:
  167. .long 0
  168. .long 1072693248
  169. .long 0
  170. .long 3220176896
  171. .type _ones,@object
  172. .size _ones,16
  173. .data
  174. .section .note.GNU-stack, ""
  175. // -- Begin DWARF2 SEGMENT .eh_frame
  176. .section .eh_frame,"a",@progbits
  177. .eh_frame_seg:
  178. .align 1
  179. # End