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.

187 lines
6.2KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program 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
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. #include "regdef.h"
  20. #ifdef HAVE_AV_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. /* Some nicer register names. */
  24. #define ta t10
  25. #define tb t11
  26. #define tc t12
  27. #define td AT
  28. /* Danger: these overlap with the argument list and the return value */
  29. #define te a5
  30. #define tf a4
  31. #define tg a3
  32. #define th v0
  33. .set noat
  34. .set noreorder
  35. .arch pca56
  36. .text
  37. /*****************************************************************************
  38. * int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size)
  39. *
  40. * This code is written with a pca56 in mind. For ev6, one should
  41. * really take the increased latency of 3 cycles for MVI instructions
  42. * into account.
  43. *
  44. * It is important to keep the loading and first use of a register as
  45. * far apart as possible, because if a register is accessed before it
  46. * has been fetched from memory, the CPU will stall.
  47. */
  48. .align 4
  49. .globl pix_abs16x16_mvi_asm
  50. .ent pix_abs16x16_mvi_asm
  51. pix_abs16x16_mvi_asm:
  52. .frame sp, 0, ra, 0
  53. .prologue 0
  54. #ifdef HAVE_GPROF
  55. lda AT, _mcount
  56. jsr AT, (AT), _mcount
  57. #endif
  58. and a1, 7, t0
  59. clr v0
  60. lda a3, 16
  61. beq t0, $aligned
  62. .align 4
  63. $unaligned:
  64. /* Registers:
  65. line 0:
  66. t0: left_u -> left lo -> left
  67. t1: mid
  68. t2: right_u -> right hi -> right
  69. t3: ref left
  70. t4: ref right
  71. line 1:
  72. t5: left_u -> left lo -> left
  73. t6: mid
  74. t7: right_u -> right hi -> right
  75. t8: ref left
  76. t9: ref right
  77. temp:
  78. ta: left hi
  79. tb: right lo
  80. tc: error left
  81. td: error right */
  82. /* load line 0 */
  83. ldq_u t0, 0(a1) # left_u
  84. ldq_u t1, 8(a1) # mid
  85. ldq_u t2, 16(a1) # right_u
  86. ldq t3, 0(a0) # ref left
  87. ldq t4, 8(a0) # ref right
  88. addq a0, a2, a0 # pix1
  89. addq a1, a2, a1 # pix2
  90. /* load line 1 */
  91. ldq_u t5, 0(a1) # left_u
  92. ldq_u t6, 8(a1) # mid
  93. ldq_u t7, 16(a1) # right_u
  94. ldq t8, 0(a0) # ref left
  95. ldq t9, 8(a0) # ref right
  96. addq a0, a2, a0 # pix1
  97. addq a1, a2, a1 # pix2
  98. /* calc line 0 */
  99. extql t0, a1, t0 # left lo
  100. extqh t1, a1, ta # left hi
  101. extql t1, a1, tb # right lo
  102. or t0, ta, t0 # left
  103. extqh t2, a1, t2 # right hi
  104. perr t3, t0, tc # error left
  105. or t2, tb, t2 # right
  106. perr t4, t2, td # error right
  107. addq v0, tc, v0 # add error left
  108. addq v0, td, v0 # add error left
  109. /* calc line 1 */
  110. extql t5, a1, t5 # left lo
  111. extqh t6, a1, ta # left hi
  112. extql t6, a1, tb # right lo
  113. or t5, ta, t5 # left
  114. extqh t7, a1, t7 # right hi
  115. perr t8, t5, tc # error left
  116. or t7, tb, t7 # right
  117. perr t9, t7, td # error right
  118. addq v0, tc, v0 # add error left
  119. addq v0, td, v0 # add error left
  120. /* loop */
  121. subq a3, 2, a3 # h -= 2
  122. bne a3, $unaligned
  123. ret
  124. .align 4
  125. $aligned:
  126. /* load line 0 */
  127. ldq t0, 0(a1) # left
  128. ldq t1, 8(a1) # right
  129. addq a1, a2, a1 # pix2
  130. ldq t2, 0(a0) # ref left
  131. ldq t3, 8(a0) # ref right
  132. addq a0, a2, a0 # pix1
  133. /* load line 1 */
  134. ldq t4, 0(a1) # left
  135. ldq t5, 8(a1) # right
  136. addq a1, a2, a1 # pix2
  137. ldq t6, 0(a0) # ref left
  138. ldq t7, 8(a0) # ref right
  139. addq a0, a2, a0 # pix1
  140. /* load line 2 */
  141. ldq t8, 0(a1) # left
  142. ldq t9, 8(a1) # right
  143. addq a1, a2, a1 # pix2
  144. ldq ta, 0(a0) # ref left
  145. ldq tb, 8(a0) # ref right
  146. addq a0, a2, a0 # pix1
  147. /* load line 3 */
  148. ldq tc, 0(a1) # left
  149. ldq td, 8(a1) # right
  150. addq a1, a2, a1 # pix2
  151. ldq te, 0(a0) # ref left
  152. ldq tf, 8(a0) # ref right
  153. /* calc line 0 */
  154. perr t0, t2, t0 # error left
  155. addq a0, a2, a0 # pix1
  156. perr t1, t3, t1 # error right
  157. addq v0, t0, v0 # add error left
  158. /* calc line 1 */
  159. perr t4, t6, t0 # error left
  160. addq v0, t1, v0 # add error right
  161. perr t5, t7, t1 # error right
  162. addq v0, t0, v0 # add error left
  163. /* calc line 2 */
  164. perr t8, ta, t0 # error left
  165. addq v0, t1, v0 # add error right
  166. perr t9, tb, t1 # error right
  167. addq v0, t0, v0 # add error left
  168. /* calc line 3 */
  169. perr tc, te, t0 # error left
  170. addq v0, t1, v0 # add error right
  171. perr td, tf, t1 # error right
  172. addq v0, t0, v0 # add error left
  173. addq v0, t1, v0 # add error right
  174. /* loop */
  175. subq a3, 4, a3 # h -= 4
  176. bne a3, $aligned
  177. ret
  178. .end pix_abs16x16_mvi_asm