]>
Commit | Line | Data |
---|---|---|
d81602c4 | 1 | /* Definitions for transformations based on profile information for values. |
f1717362 | 2 | Copyright (C) 2003-2016 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 | |
8c4c00c1 | 8 | Software Foundation; either version 3, or (at your option) any later |
d81602c4 | 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 | |
8c4c00c1 | 17 | along with GCC; see the file COPYING3. If not see |
18 | <http://www.gnu.org/licenses/>. */ | |
d81602c4 | 19 | |
4ee9c684 | 20 | #ifndef GCC_VALUE_PROF_H |
21 | #define GCC_VALUE_PROF_H | |
22 | ||
d81602c4 | 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. */ | |
167b550b | 31 | HIST_TYPE_CONST_DELTA, /* Tries to identify the (almost) always constant |
d81602c4 | 32 | difference between two evaluations of a value. */ |
48e1416a | 33 | HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost) |
167b550b | 34 | called in indirect call */ |
162719b3 | 35 | HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */ |
fc44a215 | 36 | HIST_TYPE_IOR, /* Used to compute expected alignment. */ |
38fe12e3 | 37 | HIST_TYPE_TIME_PROFILE, /* Used for time profile */ |
b74245ec | 38 | HIST_TYPE_INDIR_CALL_TOPN, /* Tries to identify the top N most frequently |
39 | called functions in indirect call. */ | |
fc44a215 | 40 | HIST_TYPE_MAX |
d81602c4 | 41 | }; |
42 | ||
cf40db41 | 43 | #define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) |
44 | #define HIST_TYPE_FOR_COUNTER(COUNTER) \ | |
45 | ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) | |
46 | ||
fc49fbc1 | 47 | \f |
d81602c4 | 48 | /* The value to measure. */ |
d2971487 | 49 | struct histogram_value_t |
d81602c4 | 50 | { |
ed4294da | 51 | struct |
d2971487 | 52 | { |
ed4294da | 53 | tree value; /* The value to profile. */ |
42acab1c | 54 | gimple *stmt; /* Insn containing the value. */ |
ed4294da | 55 | gcov_type *counters; /* Pointer to first counter. */ |
56 | struct histogram_value_t *next; /* Linked list pointer. */ | |
d2971487 | 57 | } hvalue; |
8a5df2ce | 58 | enum hist_type type; /* Type of information to measure. */ |
59 | unsigned n_counters; /* Number of required counters. */ | |
38fe12e3 | 60 | struct function *fun; |
d81602c4 | 61 | union |
62 | { | |
63 | struct | |
64 | { | |
65 | int int_start; /* First value in interval. */ | |
d2971487 | 66 | unsigned int steps; /* Number of values in it. */ |
d81602c4 | 67 | } intvl; /* Interval histogram data. */ |
d81602c4 | 68 | } hdata; /* Profiled information specific data. */ |
69 | }; | |
70 | ||
8a5df2ce | 71 | typedef struct histogram_value_t *histogram_value; |
c1fdef8e | 72 | typedef const struct histogram_value_t *const_histogram_value; |
8a5df2ce | 73 | |
8a5df2ce | 74 | |
f1f41a6c | 75 | typedef vec<histogram_value> histogram_values; |
8a5df2ce | 76 | |
fc49fbc1 | 77 | extern void gimple_find_values_to_profile (histogram_values *); |
78 | extern bool gimple_value_profile_transformations (void); | |
4ee9c684 | 79 | |
94bed7c3 | 80 | histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type, |
42acab1c | 81 | gimple *stmt, tree); |
82 | histogram_value gimple_histogram_value (struct function *, gimple *); | |
83 | histogram_value gimple_histogram_value_of_type (struct function *, gimple *, | |
75a70cf9 | 84 | enum hist_type); |
42acab1c | 85 | void gimple_add_histogram_value (struct function *, gimple *, histogram_value); |
86 | void dump_histograms_for_stmt (struct function *, FILE *, gimple *); | |
87 | void gimple_remove_histogram_value (struct function *, gimple *, histogram_value); | |
88 | void gimple_remove_stmt_histograms (struct function *, gimple *); | |
89 | void gimple_duplicate_stmt_histograms (struct function *, gimple *, | |
90 | struct function *, gimple *); | |
91 | void gimple_move_stmt_histograms (struct function *, gimple *, gimple *); | |
4992f399 | 92 | void verify_histograms (void); |
d4f078b5 | 93 | void free_histograms (function *); |
42acab1c | 94 | void stringop_block_profile (gimple *, unsigned int *, HOST_WIDE_INT *); |
1a91d914 | 95 | gcall *gimple_ic (gcall *, struct cgraph_node *, int, gcov_type, |
96 | gcov_type); | |
97 | bool check_ic_target (gcall *, struct cgraph_node *); | |
4d044066 | 98 | |
4992f399 | 99 | |
fc49fbc1 | 100 | /* In tree-profile.c. */ |
101 | extern void gimple_init_edge_profiler (void); | |
102 | extern void gimple_gen_edge_profiler (int, edge); | |
103 | extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned); | |
104 | extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned); | |
105 | extern void gimple_gen_one_value_profiler (histogram_value, unsigned, unsigned); | |
106 | extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned); | |
107 | extern void gimple_gen_ic_func_profiler (void); | |
38fe12e3 | 108 | extern void gimple_gen_time_profiler (unsigned, unsigned, |
109 | gimple_stmt_iterator &); | |
fc49fbc1 | 110 | extern void gimple_gen_const_delta_profiler (histogram_value, |
111 | unsigned, unsigned); | |
112 | extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned); | |
113 | extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned); | |
fc44a215 | 114 | extern void stream_out_histogram_value (struct output_block *, histogram_value); |
42acab1c | 115 | extern void stream_in_histogram_value (struct lto_input_block *, gimple *); |
fe37be54 | 116 | extern struct cgraph_node* find_func_by_profile_id (int func_id); |
117 | ||
fc49fbc1 | 118 | |
4ee9c684 | 119 | /* In profile.c. */ |
120 | extern void init_branch_prob (void); | |
121 | extern void branch_prob (void); | |
122 | extern void end_branch_prob (void); | |
4ee9c684 | 123 | |
4ee9c684 | 124 | #endif /* GCC_VALUE_PROF_H */ |
125 |