Statistics
| Branch: | Revision:

ffmpeg / libavcodec / ppc / dsputil_ppc.h @ 68ca24e6

History | View | Annotate | Download (4.76 KB)

1 35e5fb06 Romain Dolbeau
/*
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
19
#ifndef _DSPUTIL_PPC_
20
#define _DSPUTIL_PPC_
21
22 3efd4952 Romain Dolbeau
#ifdef CONFIG_DARWIN
23
/* The Apple assembler shipped w/ gcc-3.3 knows about DCBZL, previous assemblers don't
24
   We assume here that the Darwin GCC is from Apple.... */
25
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
26
#define NO_DCBZL
27
#endif
28
#else /* CONFIG_DARWIN */
29
/* I don't think any non-Apple assembler knows about DCBZL */
30
#define NO_DCBZL
31
#endif /* CONFIG_DARWIN */
32
33 e45a2872 Romain Dolbeau
#ifdef POWERPC_PERFORMANCE_REPORT
34 35e5fb06 Romain Dolbeau
void powerpc_display_perf_report(void);
35 e45a2872 Romain Dolbeau
/* the 604* have 2, the G3* have 4, the G4s have 6 */
36
#define POWERPC_NUM_PMC_ENABLED 4
37 35e5fb06 Romain Dolbeau
/* if you add to the enum below, also add to the perfname array
38
   in dsputil_ppc.c */
39
enum powerpc_perf_index {
40
  altivec_fft_num = 0,
41
  altivec_gmc1_num,
42
  altivec_dct_unquantize_h263_num,
43 14cabd40 James Klicman
  altivec_fdct,
44 35e5fb06 Romain Dolbeau
  altivec_idct_add_num,
45
  altivec_idct_put_num,
46
  altivec_put_pixels16_num,
47
  altivec_avg_pixels16_num,
48
  altivec_avg_pixels8_num,
49
  altivec_put_pixels8_xy2_num,
50 fe50f385 Romain Dolbeau
  altivec_put_no_rnd_pixels8_xy2_num,
51
  altivec_put_pixels16_xy2_num,
52
  altivec_put_no_rnd_pixels16_xy2_num,
53 35e5fb06 Romain Dolbeau
  powerpc_clear_blocks_dcbz32,
54 a4adb608 Michael Niedermayer
  powerpc_clear_blocks_dcbz128,
55 35e5fb06 Romain Dolbeau
  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 e45a2872 Romain Dolbeau
extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
65 35e5fb06 Romain Dolbeau
66 e45a2872 Romain Dolbeau
#define POWERPC_GET_PMC1(a) asm volatile("mfspr %0, 937" : "=r" (a))
67 3efd4952 Romain Dolbeau
#define POWERPC_GET_PMC2(a) asm volatile("mfspr %0, 938" : "=r" (a))
68 e45a2872 Romain Dolbeau
#if (POWERPC_NUM_PMC_ENABLED > 2)
69 3efd4952 Romain Dolbeau
#define POWERPC_GET_PMC3(a) asm volatile("mfspr %0, 941" : "=r" (a))
70 e45a2872 Romain Dolbeau
#define POWERPC_GET_PMC4(a) asm volatile("mfspr %0, 942" : "=r" (a))
71
#else
72
#define POWERPC_GET_PMC3(a) do {} while (0)
73
#define POWERPC_GET_PMC4(a) do {} while (0)
74
#endif
75
#if (POWERPC_NUM_PMC_ENABLED > 4)
76
#define POWERPC_GET_PMC5(a) asm volatile("mfspr %0, 929" : "=r" (a))
77
#define POWERPC_GET_PMC6(a) asm volatile("mfspr %0, 930" : "=r" (a))
78
#else
79
#define POWERPC_GET_PMC5(a) do {} while (0)
80
#define POWERPC_GET_PMC6(a) do {} while (0)
81
#endif
82
#define POWERPC_PERF_DECLARE(a, cond) unsigned long pmc_start[POWERPC_NUM_PMC_ENABLED], pmc_stop[POWERPC_NUM_PMC_ENABLED], pmc_loop_index;
83
#define POWERPC_PERF_START_COUNT(a, cond) do { \
84
  POWERPC_GET_PMC6(pmc_start[5]); \
85
  POWERPC_GET_PMC5(pmc_start[4]); \
86
  POWERPC_GET_PMC4(pmc_start[3]); \
87
  POWERPC_GET_PMC3(pmc_start[2]); \
88
  POWERPC_GET_PMC2(pmc_start[1]); \
89
  POWERPC_GET_PMC1(pmc_start[0]); \
90
  } while (0)
91
#define POWERPC_PERF_STOP_COUNT(a, cond) do { \
92
  POWERPC_GET_PMC1(pmc_stop[0]); \
93
  POWERPC_GET_PMC2(pmc_stop[1]); \
94
  POWERPC_GET_PMC3(pmc_stop[2]); \
95
  POWERPC_GET_PMC4(pmc_stop[3]); \
96
  POWERPC_GET_PMC5(pmc_stop[4]); \
97
  POWERPC_GET_PMC6(pmc_stop[5]); \
98
  if (cond)                       \
99
  {                               \
100
    for(pmc_loop_index = 0;       \
101
        pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
102
        pmc_loop_index++)         \
103
    {                             \
104
      if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) \
105
      {                           \
106
        unsigned long diff =      \
107
          pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index];   \
108
        if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
109
          perfdata[pmc_loop_index][a][powerpc_data_min] = diff;   \
110
        if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
111
          perfdata[pmc_loop_index][a][powerpc_data_max] = diff;   \
112
        perfdata[pmc_loop_index][a][powerpc_data_sum] += diff;    \
113
        perfdata[pmc_loop_index][a][powerpc_data_num] ++;         \
114
      }                           \
115
    }                             \
116
  }                               \
117 35e5fb06 Romain Dolbeau
} while (0)
118 e45a2872 Romain Dolbeau
#else /* POWERPC_PERFORMANCE_REPORT */
119 475b46da Michael Niedermayer
// those are needed to avoid empty statements.
120 e45a2872 Romain Dolbeau
#define POWERPC_PERF_DECLARE(a, cond)        int altivec_placeholder __attribute__ ((unused))
121
#define POWERPC_PERF_START_COUNT(a, cond)    do {} while (0)
122
#define POWERPC_PERF_STOP_COUNT(a, cond)     do {} while (0)
123
#endif /* POWERPC_PERFORMANCE_REPORT */
124 35e5fb06 Romain Dolbeau
125
#endif /*  _DSPUTIL_PPC_ */