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.

165 lines
6.2KB

  1. /*
  2. * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _DSPUTIL_PPC_
  19. #define _DSPUTIL_PPC_
  20. #ifdef CONFIG_DARWIN
  21. /* The Apple assembler shipped w/ gcc-3.3 knows about DCBZL, previous assemblers don't
  22. We assume here that the Darwin GCC is from Apple.... */
  23. #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
  24. #define NO_DCBZL
  25. #endif
  26. #else /* CONFIG_DARWIN */
  27. /* I don't think any non-Apple assembler knows about DCBZL */
  28. #define NO_DCBZL
  29. #endif /* CONFIG_DARWIN */
  30. #ifdef POWERPC_PERFORMANCE_REPORT
  31. void powerpc_display_perf_report(void);
  32. /* the 604* have 2, the G3* have 4, the G4s have 6,
  33. and the G5 are completely different (they MUST use
  34. POWERPC_MODE_64BITS, and let's hope all future 64 bis PPC
  35. will use the same PMCs... */
  36. #define POWERPC_NUM_PMC_ENABLED 6
  37. /* if you add to the enum below, also add to the perfname array
  38. in dsputil_ppc.c */
  39. enum powerpc_perf_index {
  40. altivec_fft_num = 0,
  41. altivec_gmc1_num,
  42. altivec_dct_unquantize_h263_num,
  43. altivec_fdct,
  44. altivec_idct_add_num,
  45. altivec_idct_put_num,
  46. altivec_put_pixels16_num,
  47. altivec_avg_pixels16_num,
  48. altivec_avg_pixels8_num,
  49. altivec_put_pixels8_xy2_num,
  50. altivec_put_no_rnd_pixels8_xy2_num,
  51. altivec_put_pixels16_xy2_num,
  52. altivec_put_no_rnd_pixels16_xy2_num,
  53. altivec_hadamard8_diff8x8_num,
  54. altivec_hadamard8_diff16_num,
  55. altivec_avg_pixels8_xy2_num,
  56. powerpc_clear_blocks_dcbz32,
  57. powerpc_clear_blocks_dcbz128,
  58. altivec_put_h264_chroma_mc8_num,
  59. altivec_avg_h264_chroma_mc8_num,
  60. altivec_put_h264_qpel16_h_lowpass_num,
  61. altivec_avg_h264_qpel16_h_lowpass_num,
  62. altivec_put_h264_qpel16_v_lowpass_num,
  63. altivec_avg_h264_qpel16_v_lowpass_num,
  64. altivec_put_h264_qpel16_hv_lowpass_num,
  65. altivec_avg_h264_qpel16_hv_lowpass_num,
  66. powerpc_perf_total
  67. };
  68. enum powerpc_data_index {
  69. powerpc_data_min = 0,
  70. powerpc_data_max,
  71. powerpc_data_sum,
  72. powerpc_data_num,
  73. powerpc_data_total
  74. };
  75. extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
  76. #ifndef POWERPC_MODE_64BITS
  77. #define POWERP_PMC_DATATYPE unsigned long
  78. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
  79. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
  80. #if (POWERPC_NUM_PMC_ENABLED > 2)
  81. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
  82. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
  83. #else
  84. #define POWERPC_GET_PMC3(a) do {} while (0)
  85. #define POWERPC_GET_PMC4(a) do {} while (0)
  86. #endif
  87. #if (POWERPC_NUM_PMC_ENABLED > 4)
  88. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
  89. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
  90. #else
  91. #define POWERPC_GET_PMC5(a) do {} while (0)
  92. #define POWERPC_GET_PMC6(a) do {} while (0)
  93. #endif
  94. #else /* POWERPC_MODE_64BITS */
  95. #define POWERP_PMC_DATATYPE unsigned long long
  96. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 771" : "=r" (a))
  97. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 772" : "=r" (a))
  98. #if (POWERPC_NUM_PMC_ENABLED > 2)
  99. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 773" : "=r" (a))
  100. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 774" : "=r" (a))
  101. #else
  102. #define POWERPC_GET_PMC3(a) do {} while (0)
  103. #define POWERPC_GET_PMC4(a) do {} while (0)
  104. #endif
  105. #if (POWERPC_NUM_PMC_ENABLED > 4)
  106. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 775" : "=r" (a))
  107. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 776" : "=r" (a))
  108. #else
  109. #define POWERPC_GET_PMC5(a) do {} while (0)
  110. #define POWERPC_GET_PMC6(a) do {} while (0)
  111. #endif
  112. #endif /* POWERPC_MODE_64BITS */
  113. #define POWERPC_PERF_DECLARE(a, cond) \
  114. POWERP_PMC_DATATYPE \
  115. pmc_start[POWERPC_NUM_PMC_ENABLED], \
  116. pmc_stop[POWERPC_NUM_PMC_ENABLED], \
  117. pmc_loop_index;
  118. #define POWERPC_PERF_START_COUNT(a, cond) do { \
  119. POWERPC_GET_PMC6(pmc_start[5]); \
  120. POWERPC_GET_PMC5(pmc_start[4]); \
  121. POWERPC_GET_PMC4(pmc_start[3]); \
  122. POWERPC_GET_PMC3(pmc_start[2]); \
  123. POWERPC_GET_PMC2(pmc_start[1]); \
  124. POWERPC_GET_PMC1(pmc_start[0]); \
  125. } while (0)
  126. #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
  127. POWERPC_GET_PMC1(pmc_stop[0]); \
  128. POWERPC_GET_PMC2(pmc_stop[1]); \
  129. POWERPC_GET_PMC3(pmc_stop[2]); \
  130. POWERPC_GET_PMC4(pmc_stop[3]); \
  131. POWERPC_GET_PMC5(pmc_stop[4]); \
  132. POWERPC_GET_PMC6(pmc_stop[5]); \
  133. if (cond) \
  134. { \
  135. for(pmc_loop_index = 0; \
  136. pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
  137. pmc_loop_index++) \
  138. { \
  139. if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
  140. { \
  141. POWERP_PMC_DATATYPE diff = \
  142. pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
  143. if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
  144. perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
  145. if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
  146. perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
  147. perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
  148. perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
  149. } \
  150. } \
  151. } \
  152. } while (0)
  153. #else /* POWERPC_PERFORMANCE_REPORT */
  154. // those are needed to avoid empty statements.
  155. #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
  156. #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
  157. #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
  158. #endif /* POWERPC_PERFORMANCE_REPORT */
  159. #endif /* _DSPUTIL_PPC_ */