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.

134 lines
5.1KB

  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. .syntax unified
  23. /*
  24. * VFP is a floating point coprocessor used in some ARM cores. VFP11 has 1 cycle
  25. * throughput for almost all the instructions (except for double precision
  26. * arithmetics), but rather high latency. Latency is 4 cycles for loads and 8 cycles
  27. * for arithmetic operations. Scheduling code to avoid pipeline stalls is very
  28. * important for performance. One more interesting feature is that VFP has
  29. * independent load/store and arithmetics pipelines, so it is possible to make
  30. * them work simultaneously and get more than 1 operation per cycle. Load/store
  31. * pipeline can process 2 single precision floating point values per cycle and
  32. * supports bulk loads and stores for large sets of registers. Arithmetic operations
  33. * can be done on vectors, which allows to keep the arithmetics pipeline busy,
  34. * while the processor may issue and execute other instructions. Detailed
  35. * optimization manuals can be found at http://www.arm.com
  36. */
  37. /**
  38. * ARM VFP optimized implementation of 'vector_fmul_c' function.
  39. * Assume that len is a positive number and is multiple of 8
  40. */
  41. @ void ff_vector_fmul_vfp(float *dst, const float *src0, const float *src1, int len)
  42. function ff_vector_fmul_vfp, export=1
  43. vpush {d8-d15}
  44. fmrx r12, fpscr
  45. orr r12, r12, #(3 << 16) /* set vector size to 4 */
  46. fmxr fpscr, r12
  47. vldmia r1!, {s0-s3}
  48. vldmia r2!, {s8-s11}
  49. vldmia r1!, {s4-s7}
  50. vldmia r2!, {s12-s15}
  51. vmul.f32 s8, s0, s8
  52. 1:
  53. subs r3, r3, #16
  54. vmul.f32 s12, s4, s12
  55. vldmiage r1!, {s16-s19}
  56. vldmiage r2!, {s24-s27}
  57. vldmiage r1!, {s20-s23}
  58. vldmiage r2!, {s28-s31}
  59. vmulge.f32 s24, s16, s24
  60. vstmia r0!, {s8-s11}
  61. vstmia r0!, {s12-s15}
  62. vmulge.f32 s28, s20, s28
  63. vldmiagt r1!, {s0-s3}
  64. vldmiagt r2!, {s8-s11}
  65. vldmiagt r1!, {s4-s7}
  66. vldmiagt r2!, {s12-s15}
  67. vmulge.f32 s8, s0, s8
  68. vstmiage r0!, {s24-s27}
  69. vstmiage r0!, {s28-s31}
  70. bgt 1b
  71. bic r12, r12, #(7 << 16) /* set vector size back to 1 */
  72. fmxr fpscr, r12
  73. vpop {d8-d15}
  74. bx lr
  75. endfunc
  76. /**
  77. * ARM VFP optimized implementation of 'vector_fmul_reverse_c' function.
  78. * Assume that len is a positive number and is multiple of 8
  79. */
  80. @ void ff_vector_fmul_reverse_vfp(float *dst, const float *src0,
  81. @ const float *src1, int len)
  82. function ff_vector_fmul_reverse_vfp, export=1
  83. vpush {d8-d15}
  84. add r2, r2, r3, lsl #2
  85. vldmdb r2!, {s0-s3}
  86. vldmia r1!, {s8-s11}
  87. vldmdb r2!, {s4-s7}
  88. vldmia r1!, {s12-s15}
  89. vmul.f32 s8, s3, s8
  90. vmul.f32 s9, s2, s9
  91. vmul.f32 s10, s1, s10
  92. vmul.f32 s11, s0, s11
  93. 1:
  94. subs r3, r3, #16
  95. vldmdbge r2!, {s16-s19}
  96. vmul.f32 s12, s7, s12
  97. vldmiage r1!, {s24-s27}
  98. vmul.f32 s13, s6, s13
  99. vldmdbge r2!, {s20-s23}
  100. vmul.f32 s14, s5, s14
  101. vldmiage r1!, {s28-s31}
  102. vmul.f32 s15, s4, s15
  103. vmulge.f32 s24, s19, s24
  104. vldmdbgt r2!, {s0-s3}
  105. vmulge.f32 s25, s18, s25
  106. vstmia r0!, {s8-s13}
  107. vmulge.f32 s26, s17, s26
  108. vldmiagt r1!, {s8-s11}
  109. vmulge.f32 s27, s16, s27
  110. vmulge.f32 s28, s23, s28
  111. vldmdbgt r2!, {s4-s7}
  112. vmulge.f32 s29, s22, s29
  113. vstmia r0!, {s14-s15}
  114. vmulge.f32 s30, s21, s30
  115. vmulge.f32 s31, s20, s31
  116. vmulge.f32 s8, s3, s8
  117. vldmiagt r1!, {s12-s15}
  118. vmulge.f32 s9, s2, s9
  119. vmulge.f32 s10, s1, s10
  120. vstmiage r0!, {s24-s27}
  121. vmulge.f32 s11, s0, s11
  122. vstmiage r0!, {s28-s31}
  123. bgt 1b
  124. vpop {d8-d15}
  125. bx lr
  126. endfunc