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.

125 lines
4.7KB

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