2 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
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.
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.
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
22 #ifdef POWERPC_TBL_PERFORMANCE_REPORT
23 void powerpc_display_perf_report(void);
24 /* if you add to the enum below, also add to the perfname array
26 enum powerpc_perf_index {
29 altivec_dct_unquantize_h263_num,
32 altivec_put_pixels16_num,
33 altivec_avg_pixels16_num,
34 altivec_avg_pixels8_num,
35 altivec_put_pixels8_xy2_num,
36 altivec_put_no_rnd_pixels8_xy2_num,
37 altivec_put_pixels16_xy2_num,
38 altivec_put_no_rnd_pixels16_xy2_num,
39 powerpc_clear_blocks_dcbz32,
42 enum powerpc_data_index {
49 extern unsigned long long perfdata[powerpc_perf_total][powerpc_data_total];
50 #ifdef POWERPC_PERF_USE_PMC
51 extern unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total];
54 #ifndef POWERPC_PERF_USE_PMC
55 #define POWERPC_GET_CYCLES(a) asm volatile("mftb %0" : "=r" (a))
56 #define POWERPC_TBL_DECLARE(a, cond) register unsigned long tbl_start, tbl_stop
57 #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_CYCLES(tbl_start); } while (0)
58 #define POWERPC_TBL_STOP_COUNT(a, cond) do { \
59 POWERPC_GET_CYCLES(tbl_stop); \
60 if (tbl_stop > tbl_start) \
62 unsigned long diff = tbl_stop - tbl_start; \
65 if (diff < perfdata[a][powerpc_data_min]) \
66 perfdata[a][powerpc_data_min] = diff; \
67 if (diff > perfdata[a][powerpc_data_max]) \
68 perfdata[a][powerpc_data_max] = diff; \
69 perfdata[a][powerpc_data_sum] += diff; \
70 perfdata[a][powerpc_data_num] ++; \
75 #else /* POWERPC_PERF_USE_PMC */
76 #define POWERPC_GET_CYCLES(a) asm volatile("mfspr %0, 937" : "=r" (a))
77 #define POWERPC_GET_MISS(a) asm volatile("mfspr %0, 938" : "=r" (a))
78 #define POWERPC_TBL_DECLARE(a, cond) register unsigned long cycles_start, cycles_stop, miss_start, miss_stop;
79 #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_MISS(miss_start); POWERPC_GET_CYCLES(cycles_start); } while (0)
80 #define POWERPC_TBL_STOP_COUNT(a, cond) do { \
81 POWERPC_GET_CYCLES(cycles_stop); \
82 POWERPC_GET_MISS(miss_stop); \
83 if (cycles_stop >= cycles_start) \
85 unsigned long diff = \
86 cycles_stop - cycles_start; \
89 if (diff < perfdata[a][powerpc_data_min]) \
90 perfdata[a][powerpc_data_min] = diff; \
91 if (diff > perfdata[a][powerpc_data_max]) \
92 perfdata[a][powerpc_data_max] = diff; \
93 perfdata[a][powerpc_data_sum] += diff; \
94 perfdata[a][powerpc_data_num] ++; \
97 if (miss_stop >= miss_start) \
99 unsigned long diff = \
100 miss_stop - miss_start; \
103 if (diff < perfdata_miss[a][powerpc_data_min]) \
104 perfdata_miss[a][powerpc_data_min] = diff; \
105 if (diff > perfdata_miss[a][powerpc_data_max]) \
106 perfdata_miss[a][powerpc_data_max] = diff; \
107 perfdata_miss[a][powerpc_data_sum] += diff; \
108 perfdata_miss[a][powerpc_data_num] ++; \
113 #endif /* POWERPC_PERF_USE_PMC */
116 #else /* POWERPC_TBL_PERFORMANCE_REPORT */
117 #define POWERPC_TBL_DECLARE(a, cond)
118 #define POWERPC_TBL_START_COUNT(a, cond)
119 #define POWERPC_TBL_STOP_COUNT(a, cond)
120 #endif /* POWERPC_TBL_PERFORMANCE_REPORT */
122 #endif /* _DSPUTIL_PPC_ */