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.

cdot_vfp.S 6.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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/11 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 N r0
  38. #define X r1
  39. #define INC_X r2
  40. /******************************************************
  41. * [fp, #-128] - [fp, #-64] is reserved
  42. * for store and restore of floating point
  43. * registers
  44. *******************************************************/
  45. #if !defined(__ARM_PCS_VFP)
  46. #define OLD_RETURN_ADDR r0
  47. #define OLD_N r1
  48. #define OLD_X r2
  49. #define OLD_INC_X r3
  50. #define OLD_Y [fp, #0 ]
  51. #define OLD_INC_Y [fp, #4 ]
  52. #define RETURN_ADDR r8
  53. #else
  54. #define OLD_Y r3
  55. #define OLD_INC_Y [fp, #0 ]
  56. #endif
  57. #define I r5
  58. #define Y r6
  59. #define INC_Y r7
  60. #define X_PRE 512
  61. /**************************************************************************************
  62. * Macro definitions
  63. **************************************************************************************/
  64. .macro KERNEL_F4
  65. pld [ X, #X_PRE ]
  66. pld [ Y, #X_PRE ]
  67. vldmia.f32 X!, { s4 - s5 }
  68. vldmia.f32 Y!, { s8 - s9 }
  69. fmacs s0 , s4, s8
  70. fmacs s1 , s4, s9
  71. vldmia.f32 X!, { s6 - s7 }
  72. fmacs s2 , s5, s9
  73. fmacs s3 , s5, s8
  74. vldmia.f32 Y!, { s10 - s11 }
  75. fmacs s0 , s6, s10
  76. fmacs s1 , s6, s11
  77. fmacs s2 , s7, s11
  78. fmacs s3 , s7, s10
  79. vldmia.f32 X!, { s4 - s5 }
  80. vldmia.f32 Y!, { s8 - s9 }
  81. fmacs s0 , s4, s8
  82. fmacs s1 , s4, s9
  83. vldmia.f32 X!, { s6 - s7 }
  84. fmacs s2 , s5, s9
  85. fmacs s3 , s5, s8
  86. vldmia.f32 Y!, { s10 - s11 }
  87. fmacs s0 , s6, s10
  88. fmacs s1 , s6, s11
  89. fmacs s2 , s7, s11
  90. fmacs s3 , s7, s10
  91. .endm
  92. .macro KERNEL_F1
  93. vldmia.f32 X!, { s4 - s5 }
  94. vldmia.f32 Y!, { s8 - s9 }
  95. fmacs s0 , s4, s8
  96. fmacs s1 , s4, s9
  97. fmacs s2 , s5, s9
  98. fmacs s3 , s5, s8
  99. .endm
  100. /*************************************************************************************************************************/
  101. .macro KERNEL_S4
  102. nop
  103. vldmia.f32 X, { s4 - s5 }
  104. vldmia.f32 Y, { s8 - s9 }
  105. fmacs s0 , s4, s8
  106. fmacs s1 , s4, s9
  107. fmacs s2 , s5, s9
  108. fmacs s3 , s5, s8
  109. add X, X, INC_X
  110. add Y, Y, INC_Y
  111. vldmia.f32 X, { s4 - s5 }
  112. vldmia.f32 Y, { s8 - s9 }
  113. fmacs s0 , s4, s8
  114. fmacs s1 , s4, s9
  115. fmacs s2 , s5, s9
  116. fmacs s3 , s5, s8
  117. add X, X, INC_X
  118. add Y, Y, INC_Y
  119. vldmia.f32 X, { s4 - s5 }
  120. vldmia.f32 Y, { s8 - s9 }
  121. fmacs s0 , s4, s8
  122. fmacs s1 , s4, s9
  123. fmacs s2 , s5, s9
  124. fmacs s3 , s5, s8
  125. add X, X, INC_X
  126. add Y, Y, INC_Y
  127. vldmia.f32 X, { s4 - s5 }
  128. vldmia.f32 Y, { s8 - s9 }
  129. fmacs s0 , s4, s8
  130. fmacs s1 , s4, s9
  131. fmacs s2 , s5, s9
  132. fmacs s3 , s5, s8
  133. add X, X, INC_X
  134. add Y, Y, INC_Y
  135. .endm
  136. .macro KERNEL_S1
  137. vldmia.f32 X, { s4 - s5 }
  138. vldmia.f32 Y, { s8 - s9 }
  139. fmacs s0 , s4, s8
  140. fmacs s1 , s4, s9
  141. fmacs s2 , s5, s9
  142. fmacs s3 , s5, s8
  143. add X, X, INC_X
  144. add Y, Y, INC_Y
  145. .endm
  146. /**************************************************************************************
  147. * End of macro definitions
  148. **************************************************************************************/
  149. PROLOGUE
  150. .align 5
  151. push {r4 - r9, fp}
  152. add fp, sp, #28
  153. sub sp, sp, #STACKSIZE // reserve stack
  154. sub r4, fp, #128
  155. vstm r4, { s8 - s15} // store floating point registers
  156. movs r4, #0 // clear floating point register
  157. vmov s0, r4
  158. vmov s1, s0
  159. vmov s2, s0
  160. vmov s3, s0
  161. #if !defined(__ARM_PCS_VFP)
  162. mov RETURN_ADDR, OLD_RETURN_ADDR
  163. mov N, OLD_N
  164. mov X, OLD_X
  165. mov INC_X, OLD_INC_X
  166. ldr Y, OLD_Y
  167. ldr INC_Y, OLD_INC_Y
  168. #else
  169. mov Y, OLD_Y
  170. ldr INC_Y, OLD_INC_Y
  171. #endif
  172. cmp N, #0
  173. ble cdot_kernel_L999
  174. # cmp INC_X, #0
  175. # beq cdot_kernel_L999
  176. # cmp INC_Y, #0
  177. # beq cdot_kernel_L999
  178. cmp INC_X, #1
  179. bne cdot_kernel_S_BEGIN
  180. cmp INC_Y, #1
  181. bne cdot_kernel_S_BEGIN
  182. cdot_kernel_F_BEGIN:
  183. asrs I, N, #2 // I = N / 4
  184. ble cdot_kernel_F1
  185. cdot_kernel_F4:
  186. KERNEL_F4
  187. subs I, I, #1
  188. bne cdot_kernel_F4
  189. cdot_kernel_F1:
  190. ands I, N, #3
  191. ble cdot_kernel_L999
  192. cdot_kernel_F10:
  193. KERNEL_F1
  194. subs I, I, #1
  195. bne cdot_kernel_F10
  196. b cdot_kernel_L999
  197. cdot_kernel_S_BEGIN:
  198. lsl INC_X, INC_X, #3 // INC_X * SIZE * 2
  199. lsl INC_Y, INC_Y, #3 // INC_Y * SIZE * 2
  200. asrs I, N, #2 // I = N / 4
  201. ble cdot_kernel_S1
  202. cdot_kernel_S4:
  203. KERNEL_S4
  204. subs I, I, #1
  205. bne cdot_kernel_S4
  206. cdot_kernel_S1:
  207. ands I, N, #3
  208. ble cdot_kernel_L999
  209. cdot_kernel_S10:
  210. KERNEL_S1
  211. subs I, I, #1
  212. bne cdot_kernel_S10
  213. cdot_kernel_L999:
  214. sub r3, fp, #128
  215. vldm r3, { s8 - s15} // restore floating point registers
  216. #if !defined(CONJ)
  217. vsub.f32 s0 , s0, s2
  218. vadd.f32 s1 , s1, s3
  219. #else
  220. vadd.f32 s0 , s0, s2
  221. vsub.f32 s1 , s1, s3
  222. #endif
  223. #if !defined(__ARM_PCS_VFP)
  224. vstm RETURN_ADDR, {s0 - s1}
  225. #endif
  226. sub sp, fp, #28
  227. pop {r4 - r9, fp}
  228. bx lr
  229. EPILOGUE