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.7KB

  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. #define POWERPC_NUM_PMC_ENABLED 4
  34. /* if you add to the enum below, also add to the perfname array
  35. in dsputil_ppc.c */
  36. enum powerpc_perf_index {
  37. altivec_fft_num = 0,
  38. altivec_gmc1_num,
  39. altivec_dct_unquantize_h263_num,
  40. altivec_fdct,
  41. altivec_idct_add_num,
  42. altivec_idct_put_num,
  43. altivec_put_pixels16_num,
  44. altivec_avg_pixels16_num,
  45. altivec_avg_pixels8_num,
  46. altivec_put_pixels8_xy2_num,
  47. altivec_put_no_rnd_pixels8_xy2_num,
  48. altivec_put_pixels16_xy2_num,
  49. altivec_put_no_rnd_pixels16_xy2_num,
  50. altivec_hadamard8_diff8x8_num,
  51. altivec_hadamard8_diff16_num,
  52. altivec_avg_pixels8_xy2_num,
  53. powerpc_clear_blocks_dcbz32,
  54. powerpc_clear_blocks_dcbz128,
  55. powerpc_perf_total
  56. };
  57. enum powerpc_data_index {
  58. powerpc_data_min = 0,
  59. powerpc_data_max,
  60. powerpc_data_sum,
  61. powerpc_data_num,
  62. powerpc_data_total
  63. };
  64. extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
  65. #ifndef POWERPC_MODE_64BITS
  66. #define POWERP_PMC_DATATYPE unsigned long
  67. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
  68. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
  69. #if (POWERPC_NUM_PMC_ENABLED > 2)
  70. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
  71. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
  72. #else
  73. #define POWERPC_GET_PMC3(a) do {} while (0)
  74. #define POWERPC_GET_PMC4(a) do {} while (0)
  75. #endif
  76. #if (POWERPC_NUM_PMC_ENABLED > 4)
  77. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
  78. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
  79. #else
  80. #define POWERPC_GET_PMC5(a) do {} while (0)
  81. #define POWERPC_GET_PMC6(a) do {} while (0)
  82. #endif
  83. #else /* POWERPC_MODE_64BITS */
  84. #define POWERP_PMC_DATATYPE unsigned long long
  85. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 771" : "=r" (a))
  86. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 772" : "=r" (a))
  87. #if (POWERPC_NUM_PMC_ENABLED > 2)
  88. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 773" : "=r" (a))
  89. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 774" : "=r" (a))
  90. #else
  91. #define POWERPC_GET_PMC3(a) do {} while (0)
  92. #define POWERPC_GET_PMC4(a) do {} while (0)
  93. #endif
  94. #if (POWERPC_NUM_PMC_ENABLED > 4)
  95. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 775" : "=r" (a))
  96. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 776" : "=r" (a))
  97. #else
  98. #define POWERPC_GET_PMC5(a) do {} while (0)
  99. #define POWERPC_GET_PMC6(a) do {} while (0)
  100. #endif
  101. #endif /* POWERPC_MODE_64BITS */
  102. #define POWERPC_PERF_DECLARE(a, cond) \
  103. POWERP_PMC_DATATYPE \
  104. pmc_start[POWERPC_NUM_PMC_ENABLED], \
  105. pmc_stop[POWERPC_NUM_PMC_ENABLED], \
  106. pmc_loop_index;
  107. #define POWERPC_PERF_START_COUNT(a, cond) do { \
  108. POWERPC_GET_PMC6(pmc_start[5]); \
  109. POWERPC_GET_PMC5(pmc_start[4]); \
  110. POWERPC_GET_PMC4(pmc_start[3]); \
  111. POWERPC_GET_PMC3(pmc_start[2]); \
  112. POWERPC_GET_PMC2(pmc_start[1]); \
  113. POWERPC_GET_PMC1(pmc_start[0]); \
  114. } while (0)
  115. #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
  116. POWERPC_GET_PMC1(pmc_stop[0]); \
  117. POWERPC_GET_PMC2(pmc_stop[1]); \
  118. POWERPC_GET_PMC3(pmc_stop[2]); \
  119. POWERPC_GET_PMC4(pmc_stop[3]); \
  120. POWERPC_GET_PMC5(pmc_stop[4]); \
  121. POWERPC_GET_PMC6(pmc_stop[5]); \
  122. if (cond) \
  123. { \
  124. for(pmc_loop_index = 0; \
  125. pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
  126. pmc_loop_index++) \
  127. { \
  128. if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
  129. { \
  130. POWERP_PMC_DATATYPE diff = \
  131. pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
  132. if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
  133. perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
  134. if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
  135. perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
  136. perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
  137. perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
  138. } \
  139. } \
  140. } \
  141. } while (0)
  142. #else /* POWERPC_PERFORMANCE_REPORT */
  143. // those are needed to avoid empty statements.
  144. #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
  145. #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
  146. #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
  147. #endif /* POWERPC_PERFORMANCE_REPORT */
  148. #endif /* _DSPUTIL_PPC_ */