You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zrot.S 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*******************************************************************************
  2. Copyright (c) 2015, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *******************************************************************************/
  27. #define ASSEMBLER
  28. #include "common.h"
  29. #define N x0 /* vector length */
  30. #define X x1 /* X vector address */
  31. #define INC_X x2 /* X stride */
  32. #define Y x3 /* Y vector address */
  33. #define INC_Y x4 /* Y stride */
  34. #define I x5 /* loop variable */
  35. /*******************************************************************************
  36. * Macro definitions
  37. *******************************************************************************/
  38. #if !defined(DOUBLE)
  39. #define C s0 /* scale input value */
  40. #define S s1 /* scale input value */
  41. #else
  42. #define C d0 /* scale input value */
  43. #define S d1 /* scale input value */
  44. #endif
  45. /******************************************************************************/
  46. .macro INIT
  47. #if !defined(DOUBLE)
  48. ins v0.s[1], v0.s[0] // [C, C]
  49. ins v1.s[1], v1.s[0] // [S, S]
  50. #else
  51. ins v0.d[1], v0.d[0] // [C, C]
  52. ins v1.d[1], v1.d[0] // [S, S]
  53. #endif
  54. .endm
  55. .macro KERNEL_F1
  56. #if !defined(DOUBLE)
  57. ld1 {v2.2s}, [X]
  58. ld1 {v3.2s}, [Y]
  59. fmul v4.2s, v0.2s, v2.2s // [C*X1, C*X0]
  60. fmla v4.2s, v1.2s, v3.2s // [C*X1 + S*Y1, C*X0 + S*Y0]
  61. fmul v5.2s, v0.2s, v3.2s // [C*Y1, C*Y0]
  62. fmls v5.2s, v1.2s, v2.2s // [C*Y1 - S*X1, C*Y0 - S*X0]
  63. st1 {v4.2s}, [X], #8
  64. st1 {v5.2s}, [Y], #8
  65. #else
  66. ld1 {v2.2d}, [X]
  67. ld1 {v3.2d}, [Y]
  68. fmul v4.2d, v0.2d, v2.2d // [C*X1, C*X0]
  69. fmla v4.2d, v1.2d, v3.2d // [C*X1 + S*Y1, C*X0 + S*Y0]
  70. fmul v5.2d, v0.2d, v3.2d // [C*Y1, C*Y0]
  71. fmls v5.2d, v1.2d, v2.2d // [C*Y1 - S*X1, C*Y0 - S*X0]
  72. st1 {v4.2d}, [X], #16
  73. st1 {v5.2d}, [Y], #16
  74. #endif
  75. .endm
  76. .macro KERNEL_INIT_F4
  77. #if !defined(DOUBLE)
  78. ins v0.d[1], v0.d[0] // [C, C, C, C]
  79. ins v1.d[1], v1.d[0] // [S, S, S, S]
  80. #endif
  81. .endm
  82. .macro KERNEL_F4
  83. #if !defined(DOUBLE)
  84. ld1 {v2.4s, v3.4s}, [X]
  85. ld1 {v4.4s, v5.4s}, [Y]
  86. fmul v6.4s, v0.4s, v2.4s // C*X3, C*X2, C*X1, C*X0
  87. fmul v7.4s, v0.4s, v3.4s // C*X7, C*X6, C*X5, C*X4
  88. fmla v6.4s, v1.4s, v4.4s // C*X3+S*Y3, ..., C*X0+S*Y0
  89. fmla v7.4s, v1.4s, v5.4s // C*X7+S*Y7, ..., C*X4+S*Y4
  90. fmul v16.4s, v0.4s, v4.4s // C*Y3, C*Y2, C*Y1, C*Y0
  91. fmul v17.4s, v0.4s, v5.4s // C*Y7, C*Y6, C*Y5, C*Y4
  92. fmls v16.4s, v1.4s, v2.4s // C*Y3-S*X3, ..., C*Y0-S*X0
  93. fmls v17.4s, v1.4s, v3.4s // C*Y7-S*X7, ..., C*Y4-S*X4
  94. st1 {v6.4s,v7.4s}, [X], #32
  95. st1 {v16.4s,v17.4s}, [Y], #32
  96. #else // DOUBLE
  97. ld1 {v2.2d, v3.2d}, [X]
  98. ld1 {v4.2d, v5.2d}, [Y]
  99. fmul v6.2d, v0.2d, v2.2d // C*X3, C*X2, C*X1, C*X0
  100. fmul v7.2d, v0.2d, v3.2d // C*X7, C*X6, C*X5, C*X4
  101. fmla v6.2d, v1.2d, v4.2d // C*X3+S*Y3, ..., C*X0+S*Y0
  102. fmla v7.2d, v1.2d, v5.2d // C*X7+S*Y7, ..., C*X4+S*Y4
  103. fmul v16.2d, v0.2d, v4.2d // C*Y3, C*Y2, C*Y1, C*Y0
  104. fmul v17.2d, v0.2d, v5.2d // C*Y7, C*Y6, C*Y5, C*Y4
  105. fmls v16.2d, v1.2d, v2.2d // C*Y3-S*X3, ..., C*Y0-S*X0
  106. fmls v17.2d, v1.2d, v3.2d // C*Y7-S*X7, ..., C*Y4-S*X4
  107. st1 {v6.2d,v7.2d}, [X], #32
  108. st1 {v16.2d,v17.2d}, [Y], #32
  109. ld1 {v2.2d, v3.2d}, [X]
  110. ld1 {v4.2d, v5.2d}, [Y]
  111. fmul v6.2d, v0.2d, v2.2d // C*X3, C*X2, C*X1, C*X0
  112. fmul v7.2d, v0.2d, v3.2d // C*X7, C*X6, C*X5, C*X4
  113. fmla v6.2d, v1.2d, v4.2d // C*X3+S*Y3, ..., C*X0+S*Y0
  114. fmla v7.2d, v1.2d, v5.2d // C*X7+S*Y7, ..., C*X4+S*Y4
  115. fmul v16.2d, v0.2d, v4.2d // C*Y3, C*Y2, C*Y1, C*Y0
  116. fmul v17.2d, v0.2d, v5.2d // C*Y7, C*Y6, C*Y5, C*Y4
  117. fmls v16.2d, v1.2d, v2.2d // C*Y3-S*X3, ..., C*Y0-S*X0
  118. fmls v17.2d, v1.2d, v3.2d // C*Y7-S*X7, ..., C*Y4-S*X4
  119. st1 {v6.2d,v7.2d}, [X], #32
  120. st1 {v16.2d,v17.2d}, [Y], #32
  121. #endif
  122. .endm
  123. .macro INIT_S
  124. #if !defined(DOUBLE)
  125. lsl INC_X, INC_X, #3
  126. lsl INC_Y, INC_Y, #3
  127. #else
  128. lsl INC_X, INC_X, #4
  129. lsl INC_Y, INC_Y, #4
  130. #endif
  131. .endm
  132. .macro KERNEL_S1
  133. #if !defined(DOUBLE)
  134. ld1 {v2.2s}, [X]
  135. ld1 {v3.2s}, [Y]
  136. fmul v4.2s, v0.2s, v2.2s // [C*X1, C*X0]
  137. fmla v4.2s, v1.2s, v3.2s // [C*X1 + S*Y1, C*X0 + S*Y0]
  138. fmul v5.2s, v0.2s, v3.2s // [C*Y1, C*Y0]
  139. fmls v5.2s, v1.2s, v2.2s // [C*Y1 - S*X1, C*Y0 - S*X0]
  140. st1 {v4.2s}, [X], INC_X
  141. st1 {v5.2s}, [Y], INC_Y
  142. #else
  143. ld1 {v2.2d}, [X]
  144. ld1 {v3.2d}, [Y]
  145. fmul v4.2d, v0.2d, v2.2d // [C*X1, C*X0]
  146. fmla v4.2d, v1.2d, v3.2d // [C*X1 + S*Y1, C*X0 + S*Y0]
  147. fmul v5.2d, v0.2d, v3.2d // [C*Y1, C*Y0]
  148. fmls v5.2d, v1.2d, v2.2d // [C*Y1 - S*X1, C*Y0 - S*X0]
  149. st1 {v4.2d}, [X], INC_X
  150. st1 {v5.2d}, [Y], INC_Y
  151. #endif
  152. .endm
  153. /*******************************************************************************
  154. * End of macro definitions
  155. *******************************************************************************/
  156. PROLOGUE
  157. cmp N, xzr
  158. ble .Lzrot_kernel_L999
  159. INIT
  160. cmp INC_X, #1
  161. bne .Lzrot_kernel_S_BEGIN
  162. cmp INC_Y, #1
  163. bne .Lzrot_kernel_S_BEGIN
  164. .Lzrot_kernel_F_BEGIN:
  165. asr I, N, #2
  166. cmp I, xzr
  167. beq .Lzrot_kernel_F1
  168. KERNEL_INIT_F4
  169. .Lzrot_kernel_F4:
  170. KERNEL_F4
  171. subs I, I, #1
  172. bne .Lzrot_kernel_F4
  173. .Lzrot_kernel_F1:
  174. ands I, N, #3
  175. ble .Lzrot_kernel_L999
  176. .Lzrot_kernel_F10:
  177. KERNEL_F1
  178. subs I, I, #1
  179. bne .Lzrot_kernel_F10
  180. mov w0, wzr
  181. ret
  182. .Lzrot_kernel_S_BEGIN:
  183. INIT_S
  184. asr I, N, #2
  185. cmp I, xzr
  186. ble .Lzrot_kernel_S1
  187. .Lzrot_kernel_S4:
  188. KERNEL_S1
  189. KERNEL_S1
  190. KERNEL_S1
  191. KERNEL_S1
  192. subs I, I, #1
  193. bne .Lzrot_kernel_S4
  194. .Lzrot_kernel_S1:
  195. ands I, N, #3
  196. ble .Lzrot_kernel_L999
  197. .Lzrot_kernel_S10:
  198. KERNEL_S1
  199. subs I, I, #1
  200. bne .Lzrot_kernel_S10
  201. .Lzrot_kernel_L999:
  202. mov w0, wzr
  203. ret