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.

133 lines
5.1KB

  1. /*
  2. * Copyright (c) 2008 Siarhei Siamashka <ssvb@users.sourceforge.net>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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. vldmiage r1!, {s16-s19}
  55. vldmiage r2!, {s24-s27}
  56. vldmiage r1!, {s20-s23}
  57. vldmiage r2!, {s28-s31}
  58. vmulge.f32 s24, s16, s24
  59. vstmia r0!, {s8-s11}
  60. vstmia r0!, {s12-s15}
  61. vmulge.f32 s28, s20, s28
  62. vldmiagt r1!, {s0-s3}
  63. vldmiagt r2!, {s8-s11}
  64. vldmiagt r1!, {s4-s7}
  65. vldmiagt r2!, {s12-s15}
  66. vmulge.f32 s8, s0, s8
  67. vstmiage r0!, {s24-s27}
  68. vstmiage r0!, {s28-s31}
  69. bgt 1b
  70. bic r12, r12, #(7 << 16) /* set vector size back to 1 */
  71. fmxr fpscr, r12
  72. vpop {d8-d15}
  73. bx lr
  74. endfunc
  75. /**
  76. * ARM VFP optimized implementation of 'vector_fmul_reverse_c' function.
  77. * Assume that len is a positive number and is multiple of 8
  78. */
  79. @ void ff_vector_fmul_reverse_vfp(float *dst, const float *src0,
  80. @ const float *src1, int len)
  81. function ff_vector_fmul_reverse_vfp, export=1
  82. vpush {d8-d15}
  83. add r2, r2, r3, lsl #2
  84. vldmdb r2!, {s0-s3}
  85. vldmia r1!, {s8-s11}
  86. vldmdb r2!, {s4-s7}
  87. vldmia r1!, {s12-s15}
  88. vmul.f32 s8, s3, s8
  89. vmul.f32 s9, s2, s9
  90. vmul.f32 s10, s1, s10
  91. vmul.f32 s11, s0, s11
  92. 1:
  93. subs r3, r3, #16
  94. vldmdbge r2!, {s16-s19}
  95. vmul.f32 s12, s7, s12
  96. vldmiage r1!, {s24-s27}
  97. vmul.f32 s13, s6, s13
  98. vldmdbge r2!, {s20-s23}
  99. vmul.f32 s14, s5, s14
  100. vldmiage r1!, {s28-s31}
  101. vmul.f32 s15, s4, s15
  102. vmulge.f32 s24, s19, s24
  103. vldmdbgt r2!, {s0-s3}
  104. vmulge.f32 s25, s18, s25
  105. vstmia r0!, {s8-s13}
  106. vmulge.f32 s26, s17, s26
  107. vldmiagt r1!, {s8-s11}
  108. vmulge.f32 s27, s16, s27
  109. vmulge.f32 s28, s23, s28
  110. vldmdbgt r2!, {s4-s7}
  111. vmulge.f32 s29, s22, s29
  112. vstmia r0!, {s14-s15}
  113. vmulge.f32 s30, s21, s30
  114. vmulge.f32 s31, s20, s31
  115. vmulge.f32 s8, s3, s8
  116. vldmiagt r1!, {s12-s15}
  117. vmulge.f32 s9, s2, s9
  118. vmulge.f32 s10, s1, s10
  119. vstmiage r0!, {s24-s27}
  120. vmulge.f32 s11, s0, s11
  121. vstmiage r0!, {s28-s31}
  122. bgt 1b
  123. vpop {d8-d15}
  124. bx lr
  125. endfunc