]>
Commit | Line | Data |
---|---|---|
1c72f4ef | 1 | /* Definitions for transformations based on profile information for values. |
9dcd6f09 | 2 | Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. |
1c72f4ef ZD |
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 | |
9dcd6f09 | 8 | Software Foundation; either version 3, or (at your option) any later |
1c72f4ef ZD |
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 | |
9dcd6f09 NC |
17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ | |
1c72f4ef | 19 | |
6de9cd9a DN |
20 | #ifndef GCC_VALUE_PROF_H |
21 | #define GCC_VALUE_PROF_H | |
22 | ||
1c72f4ef ZD |
23 | /* Supported histogram types. */ |
24 | enum hist_type | |
25 | { | |
26 | HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified | |
27 | interval. */ | |
28 | HIST_TYPE_POW2, /* Histogram of power of 2 values. */ | |
29 | HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost) | |
30 | always constant. */ | |
6bad2617 | 31 | HIST_TYPE_CONST_DELTA, /* Tries to identify the (almost) always constant |
1c72f4ef | 32 | difference between two evaluations of a value. */ |
079a182e | 33 | HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost) |
6bad2617 | 34 | called in indirect call */ |
079a182e JH |
35 | HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */ |
36 | HIST_TYPE_IOR /* Used to compute expected alignment. */ | |
1c72f4ef ZD |
37 | }; |
38 | ||
6e885ee3 ZD |
39 | #define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) |
40 | #define HIST_TYPE_FOR_COUNTER(COUNTER) \ | |
41 | ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) | |
42 | ||
1c72f4ef | 43 | /* The value to measure. */ |
1f1e8527 | 44 | struct histogram_value_t |
1c72f4ef | 45 | { |
8a76829c | 46 | struct |
1f1e8527 | 47 | { |
8a76829c | 48 | tree value; /* The value to profile. */ |
726a989a | 49 | gimple stmt; /* Insn containing the value. */ |
8a76829c JH |
50 | gcov_type *counters; /* Pointer to first counter. */ |
51 | struct histogram_value_t *next; /* Linked list pointer. */ | |
1f1e8527 | 52 | } hvalue; |
6d9901e7 ZD |
53 | enum hist_type type; /* Type of information to measure. */ |
54 | unsigned n_counters; /* Number of required counters. */ | |
1c72f4ef ZD |
55 | union |
56 | { | |
57 | struct | |
58 | { | |
59 | int int_start; /* First value in interval. */ | |
1f1e8527 | 60 | unsigned int steps; /* Number of values in it. */ |
1c72f4ef | 61 | } intvl; /* Interval histogram data. */ |
1c72f4ef ZD |
62 | } hdata; /* Profiled information specific data. */ |
63 | }; | |
64 | ||
6d9901e7 | 65 | typedef struct histogram_value_t *histogram_value; |
5f754896 | 66 | typedef const struct histogram_value_t *const_histogram_value; |
6d9901e7 | 67 | |
d4e6fecb NS |
68 | DEF_VEC_P(histogram_value); |
69 | DEF_VEC_ALLOC_P(histogram_value,heap); | |
6d9901e7 | 70 | |
d4e6fecb | 71 | typedef VEC(histogram_value,heap) *histogram_values; |
6d9901e7 | 72 | |
6de9cd9a | 73 | /* Hooks registration. */ |
726a989a | 74 | extern void gimple_register_value_prof_hooks (void); |
6de9cd9a DN |
75 | |
76 | /* IR-independent entry points. */ | |
6d9901e7 | 77 | extern void find_values_to_profile (histogram_values *); |
fca9dc00 | 78 | extern bool value_profile_transformations (void); |
6de9cd9a DN |
79 | \f |
80 | /* External declarations for edge-based profiling. */ | |
81 | struct profile_hooks { | |
f3df9541 AK |
82 | |
83 | /* Insert code to initialize edge profiler. */ | |
84 | void (*init_edge_profiler) (void); | |
85 | ||
9cf737f8 | 86 | /* Insert code to increment an edge count. */ |
6de9cd9a DN |
87 | void (*gen_edge_profiler) (int, edge); |
88 | ||
89 | /* Insert code to increment the interval histogram counter. */ | |
6d9901e7 | 90 | void (*gen_interval_profiler) (histogram_value, unsigned, unsigned); |
6de9cd9a DN |
91 | |
92 | /* Insert code to increment the power of two histogram counter. */ | |
6d9901e7 | 93 | void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned); |
6de9cd9a | 94 | |
9cf737f8 | 95 | /* Insert code to find the most common value. */ |
6d9901e7 | 96 | void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned); |
6de9cd9a DN |
97 | |
98 | /* Insert code to find the most common value of a difference between two | |
99 | evaluations of an expression. */ | |
6d9901e7 | 100 | void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned); |
6bad2617 TB |
101 | |
102 | /* Insert code to find the most common indirect call */ | |
103 | void (*gen_ic_profiler) (histogram_value, unsigned, unsigned); | |
079a182e JH |
104 | |
105 | /* Insert code to find the average value of an expression. */ | |
106 | void (*gen_average_profiler) (histogram_value, unsigned, unsigned); | |
107 | ||
108 | /* Insert code to ior value of an expression. */ | |
109 | void (*gen_ior_profiler) (histogram_value, unsigned, unsigned); | |
6de9cd9a DN |
110 | }; |
111 | ||
726a989a RB |
112 | histogram_value gimple_histogram_value (struct function *, gimple); |
113 | histogram_value gimple_histogram_value_of_type (struct function *, gimple, | |
114 | enum hist_type); | |
115 | void gimple_add_histogram_value (struct function *, gimple, histogram_value); | |
116 | void dump_histograms_for_stmt (struct function *, FILE *, gimple); | |
117 | void gimple_remove_histogram_value (struct function *, gimple, histogram_value); | |
118 | void gimple_remove_stmt_histograms (struct function *, gimple); | |
119 | void gimple_duplicate_stmt_histograms (struct function *, gimple, | |
120 | struct function *, gimple); | |
121 | void gimple_move_stmt_histograms (struct function *, gimple, gimple); | |
6946b3f7 JH |
122 | void verify_histograms (void); |
123 | void free_histograms (void); | |
726a989a | 124 | void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *); |
6946b3f7 | 125 | |
6de9cd9a DN |
126 | /* In profile.c. */ |
127 | extern void init_branch_prob (void); | |
128 | extern void branch_prob (void); | |
129 | extern void end_branch_prob (void); | |
130 | extern void tree_register_profile_hooks (void); | |
6de9cd9a DN |
131 | |
132 | /* In tree-profile.c. */ | |
133 | extern struct profile_hooks tree_profile_hooks; | |
134 | ||
6de9cd9a DN |
135 | #endif /* GCC_VALUE_PROF_H */ |
136 |