c-decl.c (merge_decls): Use DECL_USER_ALIGN() on olddecl to update the respective...
[official-gcc.git] / gcc / value-prof.h
bloba01919bb3f941e99a41f9aa385006b334685436e
1 /* Definitions for transformations based on profile information for values.
2 Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
4 This file is part of GCC.
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 3, or (at your option) any later
9 version.
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.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_VALUE_PROF_H
21 #define GCC_VALUE_PROF_H
23 /* Supported histogram types. */
24 enum hist_type
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. */
31 HIST_TYPE_CONST_DELTA, /* Tries to identify the (almost) always constant
32 difference between two evaluations of a value. */
33 HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost)
34 called in indirect call */
35 HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */
36 HIST_TYPE_IOR /* Used to compute expected alignment. */
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))
43 /* The value to measure. */
44 struct histogram_value_t
46 struct
48 tree value; /* The value to profile. */
49 tree stmt; /* Insn containing the value. */
50 gcov_type *counters; /* Pointer to first counter. */
51 struct histogram_value_t *next; /* Linked list pointer. */
52 } hvalue;
53 enum hist_type type; /* Type of information to measure. */
54 unsigned n_counters; /* Number of required counters. */
55 union
57 struct
59 int int_start; /* First value in interval. */
60 unsigned int steps; /* Number of values in it. */
61 } intvl; /* Interval histogram data. */
62 } hdata; /* Profiled information specific data. */
65 typedef struct histogram_value_t *histogram_value;
66 typedef const struct histogram_value_t *const_histogram_value;
68 DEF_VEC_P(histogram_value);
69 DEF_VEC_ALLOC_P(histogram_value,heap);
71 typedef VEC(histogram_value,heap) *histogram_values;
73 /* Hooks registration. */
74 extern void tree_register_value_prof_hooks (void);
76 /* IR-independent entry points. */
77 extern void find_values_to_profile (histogram_values *);
78 extern bool value_profile_transformations (void);
80 /* External declarations for edge-based profiling. */
81 struct profile_hooks {
83 /* Insert code to initialize edge profiler. */
84 void (*init_edge_profiler) (void);
86 /* Insert code to increment an edge count. */
87 void (*gen_edge_profiler) (int, edge);
89 /* Insert code to increment the interval histogram counter. */
90 void (*gen_interval_profiler) (histogram_value, unsigned, unsigned);
92 /* Insert code to increment the power of two histogram counter. */
93 void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned);
95 /* Insert code to find the most common value. */
96 void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned);
98 /* Insert code to find the most common value of a difference between two
99 evaluations of an expression. */
100 void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned);
102 /* Insert code to find the most common indirect call */
103 void (*gen_ic_profiler) (histogram_value, unsigned, unsigned);
105 /* Insert code to find the average value of an expression. */
106 void (*gen_average_profiler) (histogram_value, unsigned, unsigned);
108 /* Insert code to ior value of an expression. */
109 void (*gen_ior_profiler) (histogram_value, unsigned, unsigned);
112 histogram_value gimple_histogram_value (struct function *, tree);
113 histogram_value gimple_histogram_value_of_type (struct function *, tree, enum hist_type);
114 void gimple_add_histogram_value (struct function *, tree, histogram_value);
115 void dump_histograms_for_stmt (struct function *, FILE *, tree);
116 void gimple_remove_histogram_value (struct function *, tree, histogram_value);
117 void gimple_remove_stmt_histograms (struct function *, tree);
118 void gimple_duplicate_stmt_histograms (struct function *, tree, struct function *, tree);
119 void verify_histograms (void);
120 void free_histograms (void);
121 void stringop_block_profile (tree, unsigned int *, HOST_WIDE_INT *);
123 /* In profile.c. */
124 extern void init_branch_prob (void);
125 extern void branch_prob (void);
126 extern void end_branch_prob (void);
127 extern void tree_register_profile_hooks (void);
129 /* In tree-profile.c. */
130 extern struct profile_hooks tree_profile_hooks;
132 #endif /* GCC_VALUE_PROF_H */