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.

184 lines
6.1KB

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