Import SDL 1.2
[yari.git] / testcases / perfmon.c
blobbafe52b578a0fb2e29239d199a8fd3f19bebf919
1 #include <stdio.h>
2 #include "perfcounters.h"
4 static unsigned __perf_counter[PERF_COUNTERS];
6 static inline int __builtin_mfcp2(int k)
8 int r;
10 asm(".set push;"
11 ".set mips32r2;"
12 "mfc2 %0,$%1;"
13 ".set pop" : "=r" (r) : "i" (k));
15 return r;
18 void perfmon_start(void)
20 int i;
23 * We have to use the macro construct as mfc2 requires a constant
24 * argument and this is simpler than generating code on the fly.
27 #define X(H) __perf_counter[H] = -__builtin_mfcp2(H);
28 __FORALL_PERF_COUNTERS(X);
29 #undef X
32 void perfmon_report(void)
34 int i;
36 #define X(H) __perf_counter[H] += __builtin_mfcp2(H);
37 __FORALL_PERF_COUNTERS(X);
38 #undef X
40 for (i = 0; i < PERF_COUNTERS; ++i)
41 printf("%s = %d\n", __perf_counter_names[i], __perf_counter[i]);