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.

126 lines
4.8KB

  1. /*
  2. * Copyright (c) 2003 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. powerpc_clear_blocks_dcbz32,
  51. powerpc_clear_blocks_dcbz128,
  52. powerpc_perf_total
  53. };
  54. enum powerpc_data_index {
  55. powerpc_data_min = 0,
  56. powerpc_data_max,
  57. powerpc_data_sum,
  58. powerpc_data_num,
  59. powerpc_data_total
  60. };
  61. extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
  62. #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
  63. #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
  64. #if (POWERPC_NUM_PMC_ENABLED > 2)
  65. #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
  66. #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
  67. #else
  68. #define POWERPC_GET_PMC3(a) do {} while (0)
  69. #define POWERPC_GET_PMC4(a) do {} while (0)
  70. #endif
  71. #if (POWERPC_NUM_PMC_ENABLED > 4)
  72. #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
  73. #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
  74. #else
  75. #define POWERPC_GET_PMC5(a) do {} while (0)
  76. #define POWERPC_GET_PMC6(a) do {} while (0)
  77. #endif
  78. #define POWERPC_PERF_DECLARE(a, cond) unsigned long pmc_start[POWERPC_NUM_PMC_ENABLED], pmc_stop[POWERPC_NUM_PMC_ENABLED], pmc_loop_index;
  79. #define POWERPC_PERF_START_COUNT(a, cond) do { \
  80. POWERPC_GET_PMC6(pmc_start[5]); \
  81. POWERPC_GET_PMC5(pmc_start[4]); \
  82. POWERPC_GET_PMC4(pmc_start[3]); \
  83. POWERPC_GET_PMC3(pmc_start[2]); \
  84. POWERPC_GET_PMC2(pmc_start[1]); \
  85. POWERPC_GET_PMC1(pmc_start[0]); \
  86. } while (0)
  87. #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
  88. POWERPC_GET_PMC1(pmc_stop[0]); \
  89. POWERPC_GET_PMC2(pmc_stop[1]); \
  90. POWERPC_GET_PMC3(pmc_stop[2]); \
  91. POWERPC_GET_PMC4(pmc_stop[3]); \
  92. POWERPC_GET_PMC5(pmc_stop[4]); \
  93. POWERPC_GET_PMC6(pmc_stop[5]); \
  94. if (cond) \
  95. { \
  96. for(pmc_loop_index = 0; \
  97. pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
  98. pmc_loop_index++) \
  99. { \
  100. if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
  101. { \
  102. unsigned long diff = \
  103. pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
  104. if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
  105. perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
  106. if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
  107. perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
  108. perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
  109. perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
  110. } \
  111. } \
  112. } \
  113. } while (0)
  114. #else /* POWERPC_PERFORMANCE_REPORT */
  115. // those are needed to avoid empty statements.
  116. #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
  117. #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
  118. #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
  119. #endif /* POWERPC_PERFORMANCE_REPORT */
  120. #endif /* _DSPUTIL_PPC_ */