00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _DSPUTIL_PPC_
00020 #define _DSPUTIL_PPC_
00021
00022 #ifdef CONFIG_DARWIN
00023
00024
00025 #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
00026 #define NO_DCBZL
00027 #endif
00028 #else
00029
00030 #define NO_DCBZL
00031 #endif
00032
00033 #ifdef POWERPC_PERFORMANCE_REPORT
00034 void powerpc_display_perf_report(void);
00035
00036
00037
00038
00039 #define POWERPC_NUM_PMC_ENABLED 6
00040
00041
00042 enum powerpc_perf_index {
00043 altivec_fft_num = 0,
00044 altivec_gmc1_num,
00045 altivec_dct_unquantize_h263_num,
00046 altivec_fdct,
00047 altivec_idct_add_num,
00048 altivec_idct_put_num,
00049 altivec_put_pixels16_num,
00050 altivec_avg_pixels16_num,
00051 altivec_avg_pixels8_num,
00052 altivec_put_pixels8_xy2_num,
00053 altivec_put_no_rnd_pixels8_xy2_num,
00054 altivec_put_pixels16_xy2_num,
00055 altivec_put_no_rnd_pixels16_xy2_num,
00056 altivec_hadamard8_diff8x8_num,
00057 altivec_hadamard8_diff16_num,
00058 altivec_avg_pixels8_xy2_num,
00059 powerpc_clear_blocks_dcbz32,
00060 powerpc_clear_blocks_dcbz128,
00061 altivec_put_h264_chroma_mc8_num,
00062 altivec_avg_h264_chroma_mc8_num,
00063 altivec_put_h264_qpel16_h_lowpass_num,
00064 altivec_avg_h264_qpel16_h_lowpass_num,
00065 altivec_put_h264_qpel16_v_lowpass_num,
00066 altivec_avg_h264_qpel16_v_lowpass_num,
00067 altivec_put_h264_qpel16_hv_lowpass_num,
00068 altivec_avg_h264_qpel16_hv_lowpass_num,
00069 powerpc_perf_total
00070 };
00071 enum powerpc_data_index {
00072 powerpc_data_min = 0,
00073 powerpc_data_max,
00074 powerpc_data_sum,
00075 powerpc_data_num,
00076 powerpc_data_total
00077 };
00078 extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
00079
00080 #ifndef POWERPC_MODE_64BITS
00081 #define POWERP_PMC_DATATYPE unsigned long
00082 #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
00083 #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
00084 #if (POWERPC_NUM_PMC_ENABLED > 2)
00085 #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
00086 #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
00087 #else
00088 #define POWERPC_GET_PMC3(a) do {} while (0)
00089 #define POWERPC_GET_PMC4(a) do {} while (0)
00090 #endif
00091 #if (POWERPC_NUM_PMC_ENABLED > 4)
00092 #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
00093 #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
00094 #else
00095 #define POWERPC_GET_PMC5(a) do {} while (0)
00096 #define POWERPC_GET_PMC6(a) do {} while (0)
00097 #endif
00098 #else
00099 #define POWERP_PMC_DATATYPE unsigned long long
00100 #define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 771" : "=r" (a))
00101 #define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 772" : "=r" (a))
00102 #if (POWERPC_NUM_PMC_ENABLED > 2)
00103 #define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 773" : "=r" (a))
00104 #define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 774" : "=r" (a))
00105 #else
00106 #define POWERPC_GET_PMC3(a) do {} while (0)
00107 #define POWERPC_GET_PMC4(a) do {} while (0)
00108 #endif
00109 #if (POWERPC_NUM_PMC_ENABLED > 4)
00110 #define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 775" : "=r" (a))
00111 #define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 776" : "=r" (a))
00112 #else
00113 #define POWERPC_GET_PMC5(a) do {} while (0)
00114 #define POWERPC_GET_PMC6(a) do {} while (0)
00115 #endif
00116 #endif
00117 #define POWERPC_PERF_DECLARE(a, cond) \
00118 POWERP_PMC_DATATYPE \
00119 pmc_start[POWERPC_NUM_PMC_ENABLED], \
00120 pmc_stop[POWERPC_NUM_PMC_ENABLED], \
00121 pmc_loop_index;
00122 #define POWERPC_PERF_START_COUNT(a, cond) do { \
00123 POWERPC_GET_PMC6(pmc_start[5]); \
00124 POWERPC_GET_PMC5(pmc_start[4]); \
00125 POWERPC_GET_PMC4(pmc_start[3]); \
00126 POWERPC_GET_PMC3(pmc_start[2]); \
00127 POWERPC_GET_PMC2(pmc_start[1]); \
00128 POWERPC_GET_PMC1(pmc_start[0]); \
00129 } while (0)
00130 #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
00131 POWERPC_GET_PMC1(pmc_stop[0]); \
00132 POWERPC_GET_PMC2(pmc_stop[1]); \
00133 POWERPC_GET_PMC3(pmc_stop[2]); \
00134 POWERPC_GET_PMC4(pmc_stop[3]); \
00135 POWERPC_GET_PMC5(pmc_stop[4]); \
00136 POWERPC_GET_PMC6(pmc_stop[5]); \
00137 if (cond) \
00138 { \
00139 for(pmc_loop_index = 0; \
00140 pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
00141 pmc_loop_index++) \
00142 { \
00143 if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
00144 { \
00145 POWERP_PMC_DATATYPE diff = \
00146 pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
00147 if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
00148 perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
00149 if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
00150 perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
00151 perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
00152 perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
00153 } \
00154 } \
00155 } \
00156 } while (0)
00157 #else
00158
00159 #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
00160 #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
00161 #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
00162 #endif
00163
00164 #endif