dsputil_alpha_asm.S 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /*
  22. * These functions are scheduled for pca56. They should work
  23. * reasonably on ev6, though.
  24. */
  25. #include "regdef.h"
  26. /* Some nicer register names. */
  27. #define ta t10
  28. #define tb t11
  29. #define tc t12
  30. #define td AT
  31. /* Danger: these overlap with the argument list and the return value */
  32. #define te a5
  33. #define tf a4
  34. #define tg a3
  35. #define th v0
  36. .set noat
  37. .set noreorder
  38. .arch pca56
  39. .text
  40. /************************************************************************
  41. * void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels,
  42. * int line_size, int h)
  43. */
  44. .align 6
  45. .globl put_pixels_axp_asm
  46. .ent put_pixels_axp_asm
  47. put_pixels_axp_asm:
  48. .frame sp, 0, ra
  49. .prologue 0
  50. #if CONFIG_GPROF
  51. lda AT, _mcount
  52. jsr AT, (AT), _mcount
  53. #endif
  54. and a1, 7, t0
  55. beq t0, $aligned
  56. .align 4
  57. $unaligned:
  58. ldq_u t0, 0(a1)
  59. ldq_u t1, 8(a1)
  60. addq a1, a2, a1
  61. nop
  62. ldq_u t2, 0(a1)
  63. ldq_u t3, 8(a1)
  64. addq a1, a2, a1
  65. nop
  66. ldq_u t4, 0(a1)
  67. ldq_u t5, 8(a1)
  68. addq a1, a2, a1
  69. nop
  70. ldq_u t6, 0(a1)
  71. ldq_u t7, 8(a1)
  72. extql t0, a1, t0
  73. addq a1, a2, a1
  74. extqh t1, a1, t1
  75. addq a0, a2, t8
  76. extql t2, a1, t2
  77. addq t8, a2, t9
  78. extqh t3, a1, t3
  79. addq t9, a2, ta
  80. extql t4, a1, t4
  81. or t0, t1, t0
  82. extqh t5, a1, t5
  83. or t2, t3, t2
  84. extql t6, a1, t6
  85. or t4, t5, t4
  86. extqh t7, a1, t7
  87. or t6, t7, t6
  88. stq t0, 0(a0)
  89. stq t2, 0(t8)
  90. stq t4, 0(t9)
  91. subq a3, 4, a3
  92. stq t6, 0(ta)
  93. addq ta, a2, a0
  94. bne a3, $unaligned
  95. ret
  96. .align 4
  97. $aligned:
  98. ldq t0, 0(a1)
  99. addq a1, a2, a1
  100. ldq t1, 0(a1)
  101. addq a1, a2, a1
  102. ldq t2, 0(a1)
  103. addq a1, a2, a1
  104. ldq t3, 0(a1)
  105. addq a0, a2, t4
  106. addq a1, a2, a1
  107. addq t4, a2, t5
  108. subq a3, 4, a3
  109. stq t0, 0(a0)
  110. addq t5, a2, t6
  111. stq t1, 0(t4)
  112. addq t6, a2, a0
  113. stq t2, 0(t5)
  114. stq t3, 0(t6)
  115. bne a3, $aligned
  116. ret
  117. .end put_pixels_axp_asm
  118. /************************************************************************
  119. * void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels,
  120. * int line_size)
  121. */
  122. .align 6
  123. .globl put_pixels_clamped_mvi_asm
  124. .ent put_pixels_clamped_mvi_asm
  125. put_pixels_clamped_mvi_asm:
  126. .frame sp, 0, ra
  127. .prologue 0
  128. #if CONFIG_GPROF
  129. lda AT, _mcount
  130. jsr AT, (AT), _mcount
  131. #endif
  132. lda t8, -1
  133. lda t9, 8 # loop counter
  134. zap t8, 0xaa, t8 # 00ff00ff00ff00ff
  135. .align 4
  136. 1: ldq t0, 0(a0)
  137. ldq t1, 8(a0)
  138. ldq t2, 16(a0)
  139. ldq t3, 24(a0)
  140. maxsw4 t0, zero, t0
  141. subq t9, 2, t9
  142. maxsw4 t1, zero, t1
  143. lda a0, 32(a0)
  144. maxsw4 t2, zero, t2
  145. addq a1, a2, ta
  146. maxsw4 t3, zero, t3
  147. minsw4 t0, t8, t0
  148. minsw4 t1, t8, t1
  149. minsw4 t2, t8, t2
  150. minsw4 t3, t8, t3
  151. pkwb t0, t0
  152. pkwb t1, t1
  153. pkwb t2, t2
  154. pkwb t3, t3
  155. stl t0, 0(a1)
  156. stl t1, 4(a1)
  157. addq ta, a2, a1
  158. stl t2, 0(ta)
  159. stl t3, 4(ta)
  160. bne t9, 1b
  161. ret
  162. .end put_pixels_clamped_mvi_asm
  163. /************************************************************************
  164. * void add_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels,
  165. * int line_size)
  166. */
  167. .align 6
  168. .globl add_pixels_clamped_mvi_asm
  169. .ent add_pixels_clamped_mvi_asm
  170. add_pixels_clamped_mvi_asm:
  171. .frame sp, 0, ra
  172. .prologue 0
  173. #if CONFIG_GPROF
  174. lda AT, _mcount
  175. jsr AT, (AT), _mcount
  176. #endif
  177. lda t1, -1
  178. lda th, 8
  179. zap t1, 0x33, tg
  180. nop
  181. srl tg, 1, t0
  182. xor tg, t0, tg # 0x8000800080008000
  183. zap t1, 0xaa, tf # 0x00ff00ff00ff00ff
  184. .align 4
  185. 1: ldl t1, 0(a1) # pix0 (try to hit cache line soon)
  186. ldl t4, 4(a1) # pix1
  187. addq a1, a2, te # pixels += line_size
  188. ldq t0, 0(a0) # shorts0
  189. ldl t7, 0(te) # pix2 (try to hit cache line soon)
  190. ldl ta, 4(te) # pix3
  191. ldq t3, 8(a0) # shorts1
  192. ldq t6, 16(a0) # shorts2
  193. ldq t9, 24(a0) # shorts3
  194. unpkbw t1, t1 # 0 0 (quarter/op no.)
  195. and t0, tg, t2 # 0 1
  196. unpkbw t4, t4 # 1 0
  197. bic t0, tg, t0 # 0 2
  198. unpkbw t7, t7 # 2 0
  199. and t3, tg, t5 # 1 1
  200. addq t0, t1, t0 # 0 3
  201. xor t0, t2, t0 # 0 4
  202. unpkbw ta, ta # 3 0
  203. and t6, tg, t8 # 2 1
  204. maxsw4 t0, zero, t0 # 0 5
  205. bic t3, tg, t3 # 1 2
  206. bic t6, tg, t6 # 2 2
  207. minsw4 t0, tf, t0 # 0 6
  208. addq t3, t4, t3 # 1 3
  209. pkwb t0, t0 # 0 7
  210. xor t3, t5, t3 # 1 4
  211. maxsw4 t3, zero, t3 # 1 5
  212. addq t6, t7, t6 # 2 3
  213. xor t6, t8, t6 # 2 4
  214. and t9, tg, tb # 3 1
  215. minsw4 t3, tf, t3 # 1 6
  216. bic t9, tg, t9 # 3 2
  217. maxsw4 t6, zero, t6 # 2 5
  218. addq t9, ta, t9 # 3 3
  219. stl t0, 0(a1) # 0 8
  220. minsw4 t6, tf, t6 # 2 6
  221. xor t9, tb, t9 # 3 4
  222. maxsw4 t9, zero, t9 # 3 5
  223. lda a0, 32(a0) # block += 16;
  224. pkwb t3, t3 # 1 7
  225. minsw4 t9, tf, t9 # 3 6
  226. subq th, 2, th
  227. pkwb t6, t6 # 2 7
  228. pkwb t9, t9 # 3 7
  229. stl t3, 4(a1) # 1 8
  230. addq te, a2, a1 # pixels += line_size
  231. stl t6, 0(te) # 2 8
  232. stl t9, 4(te) # 3 8
  233. bne th, 1b
  234. ret
  235. .end add_pixels_clamped_mvi_asm