modf_gen.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 "modf_gen.c"
  38. .text
  39. ..TXTST0:
  40. # -- Begin modf
  41. .text
  42. .align 16,0x90
  43. .globl modf
  44. modf:
  45. # parameter 1: %xmm0
  46. # parameter 2: %rdi
  47. ..B1.1:
  48. .cfi_startproc
  49. ..___tag_value_modf.1:
  50. ..L2:
  51. movsd %xmm0, -8(%rsp)
  52. movl -4(%rsp), %eax
  53. movl %eax, %r8d
  54. andl $2147483647, %r8d
  55. lea -1072693248(%r8), %edx
  56. cmpl $54525952, %edx
  57. jae ..B1.9
  58. ..B1.2:
  59. movl %r8d, %ecx
  60. shrl $20, %ecx
  61. movl -8(%rsp), %esi
  62. cmpl $1094713344, %r8d
  63. jae ..B1.4
  64. ..B1.3:
  65. negl %ecx
  66. movl $-1, %edx
  67. addl $19, %ecx
  68. shll %cl, %edx
  69. movl %edx, %ecx
  70. andl %eax, %edx
  71. notl %ecx
  72. andl %eax, %ecx
  73. movl %edx, 4(%rdi)
  74. orl %esi, %ecx
  75. movl $0, (%rdi)
  76. jmp ..B1.5
  77. ..B1.4:
  78. negl %ecx
  79. movl $-1, %edx
  80. addl $19, %ecx
  81. shll %cl, %edx
  82. movl %edx, %ecx
  83. andl %esi, %edx
  84. notl %ecx
  85. movl %edx, (%rdi)
  86. andl %esi, %ecx
  87. movl %eax, 4(%rdi)
  88. ..B1.5:
  89. testl %ecx, %ecx
  90. je ..B1.7
  91. ..B1.6:
  92. movsd -8(%rsp), %xmm0
  93. subsd (%rdi), %xmm0
  94. ret
  95. ..B1.7:
  96. lea _zeros(%rip), %rdx
  97. shrl $31, %eax
  98. movsd (%rdx,%rax,8), %xmm0
  99. ..B1.8:
  100. ret
  101. ..B1.9:
  102. shrl $31, %eax
  103. cmpl $2146435072, %r8d
  104. jb ..B1.12
  105. ..B1.10:
  106. addl $-2146435072, %r8d
  107. orl -8(%rsp), %r8d
  108. je ..B1.13
  109. ..B1.11:
  110. movsd -8(%rsp), %xmm0
  111. addsd %xmm0, %xmm0
  112. movsd %xmm0, (%rdi)
  113. ret
  114. ..B1.12:
  115. cmpl $1072693248, %r8d
  116. jbe ..B1.14
  117. ..B1.13:
  118. movl %eax, %eax
  119. lea _zeros(%rip), %rcx
  120. movq -8(%rsp), %rdx
  121. movq %rdx, (%rdi)
  122. movsd (%rcx,%rax,8), %xmm0
  123. ret
  124. ..B1.14:
  125. lea _zeros(%rip), %rdx
  126. movsd -8(%rsp), %xmm0
  127. movq (%rdx,%rax,8), %rcx
  128. movq %rcx, (%rdi)
  129. ret
  130. .align 16,0x90
  131. .cfi_endproc
  132. .type modf,@function
  133. .size modf,.-modf
  134. .data
  135. # -- End modf
  136. .section .rodata, "a"
  137. .align 4
  138. .align 4
  139. _zeros:
  140. .long 0
  141. .long 0
  142. .long 0
  143. .long 2147483648
  144. .type _zeros,@object
  145. .size _zeros,16
  146. .data
  147. .section .note.GNU-stack, ""
  148. // -- Begin DWARF2 SEGMENT .eh_frame
  149. .section .eh_frame,"a",@progbits
  150. .eh_frame_seg:
  151. .align 1
  152. # End