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

284 lines
7.2KB

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