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.

scal_vfp.S 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /***************************************************************************
  2. Copyright (c) 2013, 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. /**************************************************************************************
  28. * 2013/11/15 Saar
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. *
  33. **************************************************************************************/
  34. #define ASSEMBLER
  35. #include "common.h"
  36. #define STACKSIZE 256
  37. #define OLD_INC_X [sp, #0 ]
  38. #define N r0
  39. #define INC_X r1
  40. #define X r3
  41. #define I r12
  42. #define X_PRE 512
  43. /**************************************************************************************
  44. * Macro definitions
  45. **************************************************************************************/
  46. /*****************************************************************************************/
  47. #if !defined(COMPLEX)
  48. #if defined(DOUBLE)
  49. .macro KERNEL_F4
  50. pld [ X, #X_PRE ]
  51. vldmia.f64 X, { d4 - d7 }
  52. vmul.f64 d4, d4, d0
  53. vmul.f64 d5, d5, d0
  54. vmul.f64 d6, d6, d0
  55. vstmia.f64 X!, { d4 - d5 }
  56. vmul.f64 d7, d7, d0
  57. vstmia.f64 X!, { d6 - d7 }
  58. .endm
  59. .macro KERNEL_F1
  60. vldmia.f64 X, { d4 }
  61. vmul.f64 d4, d4, d0
  62. vstmia.f64 X!, { d4 }
  63. .endm
  64. .macro KERNEL_S1
  65. vldmia.f64 X, { d4 }
  66. vmul.f64 d4, d4, d0
  67. vstmia.f64 X, { d4 }
  68. add X, X, INC_X
  69. .endm
  70. #else
  71. .macro KERNEL_F4
  72. vldmia.f32 X, { s4 - s7 }
  73. vmul.f32 s4, s4, s0
  74. vmul.f32 s5, s5, s0
  75. vmul.f32 s6, s6, s0
  76. vstmia.f32 X!, { s4 - s5 }
  77. vmul.f32 s7, s7, s0
  78. vstmia.f32 X!, { s6 - s7 }
  79. .endm
  80. .macro KERNEL_F1
  81. vldmia.f32 X, { s4 }
  82. vmul.f32 s4, s4, s0
  83. vstmia.f32 X!, { s4 }
  84. .endm
  85. .macro KERNEL_S1
  86. vldmia.f32 X, { s4 }
  87. vmul.f32 s4, s4, s0
  88. vstmia.f32 X, { s4 }
  89. add X, X, INC_X
  90. .endm
  91. #endif
  92. #else
  93. #if defined(DOUBLE)
  94. .macro KERNEL_F4
  95. pld [ X, #X_PRE ]
  96. vldmia.f64 X, { d4 - d5 }
  97. vmul.f64 d2, d0, d4
  98. vmls.f64 d2, d1, d5
  99. vmul.f64 d3, d0, d5
  100. fmacd d3, d1, d4
  101. vstmia.f64 X!, { d2 - d3 }
  102. vldmia.f64 X, { d4 - d5 }
  103. vmul.f64 d2, d0, d4
  104. vmls.f64 d2, d1, d5
  105. vmul.f64 d3, d0, d5
  106. fmacd d3, d1, d4
  107. vstmia.f64 X!, { d2 - d3 }
  108. pld [ X, #X_PRE ]
  109. vldmia.f64 X, { d4 - d5 }
  110. vmul.f64 d2, d0, d4
  111. vmls.f64 d2, d1, d5
  112. vmul.f64 d3, d0, d5
  113. fmacd d3, d1, d4
  114. vstmia.f64 X!, { d2 - d3 }
  115. vldmia.f64 X, { d4 - d5 }
  116. vmul.f64 d2, d0, d4
  117. vmls.f64 d2, d1, d5
  118. vmul.f64 d3, d0, d5
  119. fmacd d3, d1, d4
  120. vstmia.f64 X!, { d2 - d3 }
  121. .endm
  122. .macro KERNEL_F1
  123. vldmia.f64 X, { d4 - d5 }
  124. vmul.f64 d2, d0, d4
  125. vmls.f64 d2, d1, d5
  126. vmul.f64 d3, d0, d5
  127. fmacd d3, d1, d4
  128. vstmia.f64 X!, { d2 - d3 }
  129. .endm
  130. .macro KERNEL_S1
  131. vldmia.f64 X, { d4 - d5 }
  132. vmul.f64 d2, d0, d4
  133. vmls.f64 d2, d1, d5
  134. vmul.f64 d3, d0, d5
  135. fmacd d3, d1, d4
  136. vstmia.f64 X, { d2 - d3 }
  137. add X, X, INC_X
  138. .endm
  139. #else
  140. .macro KERNEL_F4
  141. pld [ X, #X_PRE ]
  142. vldmia.f32 X, { s4 - s5 }
  143. vmul.f32 s2, s0, s4
  144. vmls.f32 s2, s1, s5
  145. vmul.f32 s3, s0, s5
  146. fmacs s3, s1, s4
  147. vstmia.f32 X!, { s2 - s3 }
  148. vldmia.f32 X, { s4 - s5 }
  149. vmul.f32 s2, s0, s4
  150. vmls.f32 s2, s1, s5
  151. vmul.f32 s3, s0, s5
  152. fmacs s3, s1, s4
  153. vstmia.f32 X!, { s2 - s3 }
  154. vldmia.f32 X, { s4 - s5 }
  155. vmul.f32 s2, s0, s4
  156. vmls.f32 s2, s1, s5
  157. vmul.f32 s3, s0, s5
  158. fmacs s3, s1, s4
  159. vstmia.f32 X!, { s2 - s3 }
  160. vldmia.f32 X, { s4 - s5 }
  161. vmul.f32 s2, s0, s4
  162. vmls.f32 s2, s1, s5
  163. vmul.f32 s3, s0, s5
  164. fmacs s3, s1, s4
  165. vstmia.f32 X!, { s2 - s3 }
  166. .endm
  167. .macro KERNEL_F1
  168. vldmia.f32 X, { s4 - s5 }
  169. vmul.f32 s2, s0, s4
  170. vmls.f32 s2, s1, s5
  171. vmul.f32 s3, s0, s5
  172. fmacs s3, s1, s4
  173. vstmia.f32 X!, { s2 - s3 }
  174. .endm
  175. .macro KERNEL_S1
  176. vldmia.f32 X, { s4 - s5 }
  177. vmul.f32 s2, s0, s4
  178. vmls.f32 s2, s1, s5
  179. vmul.f32 s3, s0, s5
  180. fmacs s3, s1, s4
  181. vstmia.f32 X, { s2 - s3 }
  182. add X, X, INC_X
  183. .endm
  184. #endif
  185. #endif
  186. /**************************************************************************************
  187. * End of macro definitions
  188. **************************************************************************************/
  189. PROLOGUE
  190. .align 5
  191. ldr INC_X , OLD_INC_X
  192. cmp N, #0
  193. ble scal_kernel_L999
  194. cmp INC_X, #0
  195. ble scal_kernel_L999
  196. cmp INC_X, #1
  197. bne scal_kernel_S_BEGIN
  198. scal_kernel_F_BEGIN:
  199. asrs I, N, #2 // I = N / 4
  200. ble scal_kernel_F1
  201. .align 5
  202. scal_kernel_F4:
  203. #if !defined(COMPLEX) && !defined(DOUBLE)
  204. pld [ X, #X_PRE ]
  205. #endif
  206. KERNEL_F4
  207. subs I, I, #1
  208. ble scal_kernel_F1
  209. KERNEL_F4
  210. subs I, I, #1
  211. bne scal_kernel_F4
  212. scal_kernel_F1:
  213. ands I, N, #3
  214. ble scal_kernel_L999
  215. scal_kernel_F10:
  216. KERNEL_F1
  217. subs I, I, #1
  218. bne scal_kernel_F10
  219. b scal_kernel_L999
  220. scal_kernel_S_BEGIN:
  221. #if defined(COMPLEX)
  222. #if defined(DOUBLE)
  223. lsl INC_X, INC_X, #4 // INC_X * SIZE * 2
  224. #else
  225. lsl INC_X, INC_X, #3 // INC_X * SIZE * 2
  226. #endif
  227. #else
  228. #if defined(DOUBLE)
  229. lsl INC_X, INC_X, #3 // INC_X * SIZE
  230. #else
  231. lsl INC_X, INC_X, #2 // INC_X * SIZE
  232. #endif
  233. #endif
  234. asrs I, N, #2 // I = N / 4
  235. ble scal_kernel_S1
  236. .align 5
  237. scal_kernel_S4:
  238. KERNEL_S1
  239. KERNEL_S1
  240. KERNEL_S1
  241. KERNEL_S1
  242. subs I, I, #1
  243. bne scal_kernel_S4
  244. scal_kernel_S1:
  245. ands I, N, #3
  246. ble scal_kernel_L999
  247. scal_kernel_S10:
  248. KERNEL_S1
  249. subs I, I, #1
  250. bne scal_kernel_S10
  251. scal_kernel_L999:
  252. mov r0, #0 // set return value
  253. bx lr
  254. EPILOGUE