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.

154 lines
5.6KB

  1. /*
  2. * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #include "asm.S"
  22. /*
  23. * VFP is a floating point coprocessor used in some ARM cores. VFP11 has 1 cycle
  24. * throughput for almost all the instructions (except for double precision
  25. * arithmetics), but rather high latency. Latency is 4 cycles for loads and 8 cycles
  26. * for arithmetic operations. Scheduling code to avoid pipeline stalls is very
  27. * important for performance. One more interesting feature is that VFP has
  28. * independent load/store and arithmetics pipelines, so it is possible to make
  29. * them work simultaneously and get more than 1 operation per cycle. Load/store
  30. * pipeline can process 2 single precision floating point values per cycle and
  31. * supports bulk loads and stores for large sets of registers. Arithmetic operations
  32. * can be done on vectors, which allows to keep the arithmetics pipeline busy,
  33. * while the processor may issue and execute other instructions. Detailed
  34. * optimization manuals can be found at http://www.arm.com
  35. */
  36. /**
  37. * ARM VFP optimized implementation of 'vector_fmul_c' function.
  38. * Assume that len is a positive number and is multiple of 8
  39. */
  40. @ void ff_vector_fmul_vfp(float *dst, const float *src0, const float *src1, int len)
  41. function ff_vector_fmul_vfp, export=1
  42. vpush {d8-d15}
  43. fmrx r12, fpscr
  44. orr r12, r12, #(3 << 16) /* set vector size to 4 */
  45. fmxr fpscr, r12
  46. vldmia r1!, {s0-s3}
  47. vldmia r2!, {s8-s11}
  48. vldmia r1!, {s4-s7}
  49. vldmia r2!, {s12-s15}
  50. vmul.f32 s8, s0, s8
  51. 1:
  52. subs r3, r3, #16
  53. vmul.f32 s12, s4, s12
  54. itttt ge
  55. vldmiage r1!, {s16-s19}
  56. vldmiage r2!, {s24-s27}
  57. vldmiage r1!, {s20-s23}
  58. vldmiage r2!, {s28-s31}
  59. it ge
  60. vmulge.f32 s24, s16, s24
  61. vstmia r0!, {s8-s11}
  62. vstmia r0!, {s12-s15}
  63. it ge
  64. vmulge.f32 s28, s20, s28
  65. itttt gt
  66. vldmiagt r1!, {s0-s3}
  67. vldmiagt r2!, {s8-s11}
  68. vldmiagt r1!, {s4-s7}
  69. vldmiagt r2!, {s12-s15}
  70. ittt ge
  71. vmulge.f32 s8, s0, s8
  72. vstmiage r0!, {s24-s27}
  73. vstmiage r0!, {s28-s31}
  74. bgt 1b
  75. bic r12, r12, #(7 << 16) /* set vector size back to 1 */
  76. fmxr fpscr, r12
  77. vpop {d8-d15}
  78. bx lr
  79. endfunc
  80. /**
  81. * ARM VFP optimized implementation of 'vector_fmul_reverse_c' function.
  82. * Assume that len is a positive number and is multiple of 8
  83. */
  84. @ void ff_vector_fmul_reverse_vfp(float *dst, const float *src0,
  85. @ const float *src1, int len)
  86. function ff_vector_fmul_reverse_vfp, export=1
  87. vpush {d8-d15}
  88. add r2, r2, r3, lsl #2
  89. vldmdb r2!, {s0-s3}
  90. vldmia r1!, {s8-s11}
  91. vldmdb r2!, {s4-s7}
  92. vldmia r1!, {s12-s15}
  93. vmul.f32 s8, s3, s8
  94. vmul.f32 s9, s2, s9
  95. vmul.f32 s10, s1, s10
  96. vmul.f32 s11, s0, s11
  97. 1:
  98. subs r3, r3, #16
  99. it ge
  100. vldmdbge r2!, {s16-s19}
  101. vmul.f32 s12, s7, s12
  102. it ge
  103. vldmiage r1!, {s24-s27}
  104. vmul.f32 s13, s6, s13
  105. it ge
  106. vldmdbge r2!, {s20-s23}
  107. vmul.f32 s14, s5, s14
  108. it ge
  109. vldmiage r1!, {s28-s31}
  110. vmul.f32 s15, s4, s15
  111. it ge
  112. vmulge.f32 s24, s19, s24
  113. it gt
  114. vldmdbgt r2!, {s0-s3}
  115. it ge
  116. vmulge.f32 s25, s18, s25
  117. vstmia r0!, {s8-s13}
  118. it ge
  119. vmulge.f32 s26, s17, s26
  120. it gt
  121. vldmiagt r1!, {s8-s11}
  122. itt ge
  123. vmulge.f32 s27, s16, s27
  124. vmulge.f32 s28, s23, s28
  125. it gt
  126. vldmdbgt r2!, {s4-s7}
  127. it ge
  128. vmulge.f32 s29, s22, s29
  129. vstmia r0!, {s14-s15}
  130. ittt ge
  131. vmulge.f32 s30, s21, s30
  132. vmulge.f32 s31, s20, s31
  133. vmulge.f32 s8, s3, s8
  134. it gt
  135. vldmiagt r1!, {s12-s15}
  136. itttt ge
  137. vmulge.f32 s9, s2, s9
  138. vmulge.f32 s10, s1, s10
  139. vstmiage r0!, {s24-s27}
  140. vmulge.f32 s11, s0, s11
  141. it ge
  142. vstmiage r0!, {s28-s31}
  143. bgt 1b
  144. vpop {d8-d15}
  145. bx lr
  146. endfunc