]>
Commit | Line | Data |
---|---|---|
d81602c4 | 1 | /* Definitions for transformations based on profile information for values. |
c429745f | 2 | Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
d81602c4 | 3 | |
4 | This file is part of GCC. | |
5 | ||
6 | GCC is free software; you can redistribute it and/or modify it under | |
7 | the terms of the GNU General Public License as published by the Free | |
8 | Software Foundation; either version 2, or (at your option) any later | |
9 | version. | |
10 | ||
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GCC; see the file COPYING. If not, write to the Free | |
67ce556b | 18 | Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA |
19 | 02110-1301, USA. */ | |
d81602c4 | 20 | |
4ee9c684 | 21 | #ifndef GCC_VALUE_PROF_H |
22 | #define GCC_VALUE_PROF_H | |
23 | ||
d81602c4 | 24 | /* Supported histogram types. */ |
25 | enum hist_type | |
26 | { | |
27 | HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified | |
28 | interval. */ | |
29 | HIST_TYPE_POW2, /* Histogram of power of 2 values. */ | |
30 | HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost) | |
31 | always constant. */ | |
32 | HIST_TYPE_CONST_DELTA /* Tries to identify the (almost) always constant | |
33 | difference between two evaluations of a value. */ | |
34 | }; | |
35 | ||
cf40db41 | 36 | #define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) |
37 | #define HIST_TYPE_FOR_COUNTER(COUNTER) \ | |
38 | ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) | |
39 | ||
d81602c4 | 40 | /* The value to measure. */ |
d2971487 | 41 | struct histogram_value_t |
d81602c4 | 42 | { |
ed4294da | 43 | struct |
d2971487 | 44 | { |
ed4294da | 45 | tree value; /* The value to profile. */ |
46 | tree stmt; /* Insn containing the value. */ | |
47 | gcov_type *counters; /* Pointer to first counter. */ | |
48 | struct histogram_value_t *next; /* Linked list pointer. */ | |
d2971487 | 49 | } hvalue; |
8a5df2ce | 50 | enum hist_type type; /* Type of information to measure. */ |
51 | unsigned n_counters; /* Number of required counters. */ | |
d81602c4 | 52 | union |
53 | { | |
54 | struct | |
55 | { | |
56 | int int_start; /* First value in interval. */ | |
d2971487 | 57 | unsigned int steps; /* Number of values in it. */ |
d81602c4 | 58 | } intvl; /* Interval histogram data. */ |
d81602c4 | 59 | } hdata; /* Profiled information specific data. */ |
60 | }; | |
61 | ||
8a5df2ce | 62 | typedef struct histogram_value_t *histogram_value; |
63 | ||
046bfc77 | 64 | DEF_VEC_P(histogram_value); |
65 | DEF_VEC_ALLOC_P(histogram_value,heap); | |
8a5df2ce | 66 | |
046bfc77 | 67 | typedef VEC(histogram_value,heap) *histogram_values; |
8a5df2ce | 68 | |
4ee9c684 | 69 | /* Hooks registration. */ |
4ee9c684 | 70 | extern void tree_register_value_prof_hooks (void); |
71 | ||
72 | /* IR-independent entry points. */ | |
8a5df2ce | 73 | extern void find_values_to_profile (histogram_values *); |
1c6a7b8c | 74 | extern bool value_profile_transformations (void); |
4ee9c684 | 75 | \f |
76 | /* External declarations for edge-based profiling. */ | |
77 | struct profile_hooks { | |
4b0a9554 | 78 | |
79 | /* Insert code to initialize edge profiler. */ | |
80 | void (*init_edge_profiler) (void); | |
81 | ||
0bed3869 | 82 | /* Insert code to increment an edge count. */ |
4ee9c684 | 83 | void (*gen_edge_profiler) (int, edge); |
84 | ||
85 | /* Insert code to increment the interval histogram counter. */ | |
8a5df2ce | 86 | void (*gen_interval_profiler) (histogram_value, unsigned, unsigned); |
4ee9c684 | 87 | |
88 | /* Insert code to increment the power of two histogram counter. */ | |
8a5df2ce | 89 | void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned); |
4ee9c684 | 90 | |
0bed3869 | 91 | /* Insert code to find the most common value. */ |
8a5df2ce | 92 | void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned); |
4ee9c684 | 93 | |
94 | /* Insert code to find the most common value of a difference between two | |
95 | evaluations of an expression. */ | |
8a5df2ce | 96 | void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned); |
4ee9c684 | 97 | }; |
98 | ||
99 | /* In profile.c. */ | |
100 | extern void init_branch_prob (void); | |
101 | extern void branch_prob (void); | |
102 | extern void end_branch_prob (void); | |
103 | extern void tree_register_profile_hooks (void); | |
4ee9c684 | 104 | |
105 | /* In tree-profile.c. */ | |
106 | extern struct profile_hooks tree_profile_hooks; | |
107 | ||
4ee9c684 | 108 | #endif /* GCC_VALUE_PROF_H */ |
109 |