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.

156 lines
5.9KB

  1. /*
  2. * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
  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. #ifndef _DSPUTIL_PPC_
  21. #define _DSPUTIL_PPC_
  22. #ifdef CONFIG_POWERPC_PERF
  23. void powerpc_display_perf_report(void);
  24. /* the 604* have 2, the G3* have 4, the G4s have 6,
  25. and the G5 are completely different (they MUST use
  26. POWERPC_MODE_64BITS, and let's hope all future 64 bis PPC
  27. will use the same PMCs... */
  28. #define POWERPC_NUM_PMC_ENABLED 6
  29. /* if you add to the enum below, also add to the perfname array
  30. in dsputil_ppc.c */
  31. enum powerpc_perf_index {
  32. altivec_fft_num = 0,
  33. altivec_gmc1_num,
  34. altivec_dct_unquantize_h263_num,
  35. altivec_fdct,
  36. altivec_idct_add_num,
  37. altivec_idct_put_num,
  38. altivec_put_pixels16_num,
  39. altivec_avg_pixels16_num,
  40. altivec_avg_pixels8_num,
  41. altivec_put_pixels8_xy2_num,
  42. altivec_put_no_rnd_pixels8_xy2_num,
  43. altivec_put_pixels16_xy2_num,
  44. altivec_put_no_rnd_pixels16_xy2_num,
  45. altivec_hadamard8_diff8x8_num,
  46. altivec_hadamard8_diff16_num,
  47. altivec_avg_pixels8_xy2_num,
  48. powerpc_clear_blocks_dcbz32,
  49. powerpc_clear_blocks_dcbz128,
  50. altivec_put_h264_chroma_mc8_num,
  51. altivec_avg_h264_chroma_mc8_num,
  52. altivec_put_h264_qpel16_h_lowpass_num,
  53. altivec_avg_h264_qpel16_h_lowpass_num,
  54. altivec_put_h264_qpel16_v_lowpass_num,
  55. altivec_avg_h264_qpel16_v_lowpass_num,
  56. altivec_put_h264_qpel16_hv_lowpass_num,
  57. altivec_avg_h264_qpel16_hv_lowpass_num,
  58. powerpc_perf_total
  59. };
  60. enum powerpc_data_index {
  61. powerpc_data_min = 0,
  62. powerpc_data_max,
  63. powerpc_data_sum,
  64. powerpc_data_num,
  65. powerpc_data_total
  66. };
  67. extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
  68. #ifndef POWERPC_MODE_64BITS
  69. #define POWERP_PMC_DATATYPE unsigned long
  70. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
  71. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
  72. #if (POWERPC_NUM_PMC_ENABLED > 2)
  73. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
  74. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
  75. #else
  76. #define POWERPC_GET_PMC3(a) do {} while (0)
  77. #define POWERPC_GET_PMC4(a) do {} while (0)
  78. #endif
  79. #if (POWERPC_NUM_PMC_ENABLED > 4)
  80. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
  81. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
  82. #else
  83. #define POWERPC_GET_PMC5(a) do {} while (0)
  84. #define POWERPC_GET_PMC6(a) do {} while (0)
  85. #endif
  86. #else /* POWERPC_MODE_64BITS */
  87. #define POWERP_PMC_DATATYPE unsigned long long
  88. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 771" : "=r" (a))
  89. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 772" : "=r" (a))
  90. #if (POWERPC_NUM_PMC_ENABLED > 2)
  91. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 773" : "=r" (a))
  92. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 774" : "=r" (a))
  93. #else
  94. #define POWERPC_GET_PMC3(a) do {} while (0)
  95. #define POWERPC_GET_PMC4(a) do {} while (0)
  96. #endif
  97. #if (POWERPC_NUM_PMC_ENABLED > 4)
  98. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 775" : "=r" (a))
  99. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 776" : "=r" (a))
  100. #else
  101. #define POWERPC_GET_PMC5(a) do {} while (0)
  102. #define POWERPC_GET_PMC6(a) do {} while (0)
  103. #endif
  104. #endif /* POWERPC_MODE_64BITS */
  105. #define POWERPC_PERF_DECLARE(a, cond) \
  106. POWERP_PMC_DATATYPE \
  107. pmc_start[POWERPC_NUM_PMC_ENABLED], \
  108. pmc_stop[POWERPC_NUM_PMC_ENABLED], \
  109. pmc_loop_index;
  110. #define POWERPC_PERF_START_COUNT(a, cond) do { \
  111. POWERPC_GET_PMC6(pmc_start[5]); \
  112. POWERPC_GET_PMC5(pmc_start[4]); \
  113. POWERPC_GET_PMC4(pmc_start[3]); \
  114. POWERPC_GET_PMC3(pmc_start[2]); \
  115. POWERPC_GET_PMC2(pmc_start[1]); \
  116. POWERPC_GET_PMC1(pmc_start[0]); \
  117. } while (0)
  118. #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
  119. POWERPC_GET_PMC1(pmc_stop[0]); \
  120. POWERPC_GET_PMC2(pmc_stop[1]); \
  121. POWERPC_GET_PMC3(pmc_stop[2]); \
  122. POWERPC_GET_PMC4(pmc_stop[3]); \
  123. POWERPC_GET_PMC5(pmc_stop[4]); \
  124. POWERPC_GET_PMC6(pmc_stop[5]); \
  125. if (cond) \
  126. { \
  127. for(pmc_loop_index = 0; \
  128. pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
  129. pmc_loop_index++) \
  130. { \
  131. if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
  132. { \
  133. POWERP_PMC_DATATYPE diff = \
  134. pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
  135. if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
  136. perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
  137. if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
  138. perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
  139. perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
  140. perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
  141. } \
  142. } \
  143. } \
  144. } while (0)
  145. #else /* CONFIG_POWERPC_PERF */
  146. // those are needed to avoid empty statements.
  147. #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
  148. #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
  149. #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
  150. #endif /* CONFIG_POWERPC_PERF */
  151. #endif /* _DSPUTIL_PPC_ */