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.

swap_vfp.S 6.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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/14 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 [fp, #0 ]
  38. #define OLD_Y [fp, #4 ]
  39. #define OLD_INC_Y [fp, #8 ]
  40. #define N r0
  41. #define Y r1
  42. #define INC_X r2
  43. #define X r3
  44. #define INC_Y r4
  45. #define I r12
  46. #define X_PRE 512
  47. /**************************************************************************************
  48. * Macro definitions
  49. **************************************************************************************/
  50. /*****************************************************************************************/
  51. #if !defined(COMPLEX)
  52. #if defined(DOUBLE)
  53. .macro KERNEL_F4
  54. pld [ X, #X_PRE ]
  55. pld [ Y, #X_PRE ]
  56. fldmiad X, { d0 - d3 }
  57. fldmiad Y, { d4 - d7 }
  58. fstmiad Y!, { d0 - d3 }
  59. fstmiad X!, { d4 - d7}
  60. .endm
  61. .macro KERNEL_F1
  62. fldmiad X, { d0 }
  63. fldmiad Y, { d4 }
  64. fstmiad Y!, { d0 }
  65. fstmiad X!, { d4 }
  66. .endm
  67. .macro KERNEL_S1
  68. fldmiad X, { d0 }
  69. fldmiad Y, { d4 }
  70. fstmiad Y, { d0 }
  71. fstmiad X, { d4 }
  72. add X, X, INC_X
  73. add Y, Y, INC_Y
  74. .endm
  75. #else
  76. .macro KERNEL_F4
  77. fldmias X, { s0 - s3 }
  78. fldmias Y, { s4 - s7 }
  79. fstmias Y!, { s0 - s3 }
  80. fstmias X!, { s4 - s7}
  81. .endm
  82. .macro KERNEL_F1
  83. fldmias X, { s0 }
  84. fldmias Y, { s4 }
  85. fstmias Y!, { s0 }
  86. fstmias X!, { s4 }
  87. .endm
  88. .macro KERNEL_S1
  89. fldmias X, { s0 }
  90. fldmias Y, { s4 }
  91. fstmias Y, { s0 }
  92. fstmias X, { s4 }
  93. add X, X, INC_X
  94. add Y, Y, INC_Y
  95. .endm
  96. #endif
  97. #else
  98. #if defined(DOUBLE)
  99. .macro KERNEL_F4
  100. pld [ X, #X_PRE ]
  101. pld [ Y, #X_PRE ]
  102. fldmiad X, { d0 - d3 }
  103. fldmiad Y, { d4 - d7 }
  104. fstmiad Y!, { d0 - d3 }
  105. fstmiad X!, { d4 - d7}
  106. pld [ X, #X_PRE ]
  107. pld [ Y, #X_PRE ]
  108. fldmiad X, { d0 - d3 }
  109. fldmiad Y, { d4 - d7 }
  110. fstmiad Y!, { d0 - d3 }
  111. fstmiad X!, { d4 - d7}
  112. .endm
  113. .macro KERNEL_F1
  114. fldmiad X, { d0 - d1 }
  115. fldmiad Y, { d4 - d5 }
  116. fstmiad Y!, { d0 - d1 }
  117. fstmiad X!, { d4 - d5 }
  118. .endm
  119. .macro KERNEL_S1
  120. fldmiad X, { d0 - d1 }
  121. fldmiad Y, { d4 - d5 }
  122. fstmiad Y, { d0 - d1 }
  123. fstmiad X, { d4 - d5 }
  124. add X, X, INC_X
  125. add Y, Y, INC_Y
  126. .endm
  127. #else
  128. .macro KERNEL_F4
  129. pld [ X, #X_PRE ]
  130. pld [ Y, #X_PRE ]
  131. fldmias X, { s0 - s3 }
  132. fldmias Y, { s4 - s7 }
  133. fstmias Y!, { s0 - s3 }
  134. fstmias X!, { s4 - s7}
  135. fldmias X, { s0 - s3 }
  136. fldmias Y, { s4 - s7 }
  137. fstmias Y!, { s0 - s3 }
  138. fstmias X!, { s4 - s7}
  139. .endm
  140. .macro KERNEL_F1
  141. fldmias X, { s0 - s1 }
  142. fldmias Y, { s4 - s5 }
  143. fstmias Y!, { s0 - s1 }
  144. fstmias X!, { s4 - s5 }
  145. .endm
  146. .macro KERNEL_S1
  147. fldmias X, { s0 - s1 }
  148. fldmias Y, { s4 - s5 }
  149. fstmias Y, { s0 - s1 }
  150. fstmias X, { s4 - s5 }
  151. add X, X, INC_X
  152. add Y, Y, INC_Y
  153. .endm
  154. #endif
  155. #endif
  156. /**************************************************************************************
  157. * End of macro definitions
  158. **************************************************************************************/
  159. PROLOGUE
  160. .align 5
  161. push {r4 , fp}
  162. add fp, sp, #8
  163. ldr INC_X , OLD_INC_X
  164. ldr Y, OLD_Y
  165. ldr INC_Y , OLD_INC_Y
  166. cmp N, #0
  167. ble swap_kernel_L999
  168. cmp INC_X, #0
  169. beq swap_kernel_L999
  170. cmp INC_Y, #0
  171. beq swap_kernel_L999
  172. cmp INC_X, #1
  173. bne swap_kernel_S_BEGIN
  174. cmp INC_Y, #1
  175. bne swap_kernel_S_BEGIN
  176. swap_kernel_F_BEGIN:
  177. asrs I, N, #2 // I = N / 4
  178. ble swap_kernel_F1
  179. .align 5
  180. swap_kernel_F4:
  181. #if !defined(COMPLEX) && !defined(DOUBLE)
  182. pld [ X, #X_PRE ]
  183. pld [ Y, #X_PRE ]
  184. #endif
  185. KERNEL_F4
  186. subs I, I, #1
  187. ble swap_kernel_F1
  188. KERNEL_F4
  189. subs I, I, #1
  190. bne swap_kernel_F4
  191. swap_kernel_F1:
  192. ands I, N, #3
  193. ble swap_kernel_L999
  194. swap_kernel_F10:
  195. KERNEL_F1
  196. subs I, I, #1
  197. bne swap_kernel_F10
  198. b swap_kernel_L999
  199. swap_kernel_S_BEGIN:
  200. #if defined(COMPLEX)
  201. #if defined(DOUBLE)
  202. lsl INC_X, INC_X, #4 // INC_X * SIZE * 2
  203. lsl INC_Y, INC_Y, #4 // INC_Y * SIZE * 2
  204. #else
  205. lsl INC_X, INC_X, #3 // INC_X * SIZE * 2
  206. lsl INC_Y, INC_Y, #3 // INC_Y * SIZE * 2
  207. #endif
  208. #else
  209. #if defined(DOUBLE)
  210. lsl INC_X, INC_X, #3 // INC_X * SIZE
  211. lsl INC_Y, INC_Y, #3 // INC_Y * SIZE
  212. #else
  213. lsl INC_X, INC_X, #2 // INC_X * SIZE
  214. lsl INC_Y, INC_Y, #2 // INC_Y * SIZE
  215. #endif
  216. #endif
  217. asrs I, N, #2 // I = N / 4
  218. ble swap_kernel_S1
  219. .align 5
  220. swap_kernel_S4:
  221. KERNEL_S1
  222. KERNEL_S1
  223. KERNEL_S1
  224. KERNEL_S1
  225. subs I, I, #1
  226. bne swap_kernel_S4
  227. swap_kernel_S1:
  228. ands I, N, #3
  229. ble swap_kernel_L999
  230. swap_kernel_S10:
  231. KERNEL_S1
  232. subs I, I, #1
  233. bne swap_kernel_S10
  234. swap_kernel_L999:
  235. mov r0, #0 // set return value
  236. sub sp, fp, #8
  237. pop {r4,fp}
  238. bx lr
  239. EPILOGUE