xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/value-prof.h (revision 04028aa9310ca9c619eca5cf58ddf1e58624d1d7)
1 /* Definitions for transformations based on profile information for values.
2    Copyright (C) 2003-2013 Free Software Foundation, Inc.
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 3, 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 COPYING3.  If not see
18 <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef GCC_VALUE_PROF_H
21 #define GCC_VALUE_PROF_H
22 
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.  */
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.  */
37 };
38 
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 
43 
44 /* The value to measure.  */
45 struct histogram_value_t
46 {
47   struct
48     {
49       tree value;		/* The value to profile.  */
50       gimple stmt;		/* Insn containing the value.  */
51       gcov_type *counters;		        /* Pointer to first counter.  */
52       struct histogram_value_t *next;		/* Linked list pointer.  */
53     } hvalue;
54   enum hist_type type;			/* Type of information to measure.  */
55   unsigned n_counters;			/* Number of required counters.  */
56   union
57     {
58       struct
59 	{
60 	  int int_start;	/* First value in interval.  */
61 	  unsigned int steps;	/* Number of values in it.  */
62 	} intvl;	/* Interval histogram data.  */
63     } hdata;		/* Profiled information specific data.  */
64 };
65 
66 typedef struct histogram_value_t *histogram_value;
67 typedef const struct histogram_value_t *const_histogram_value;
68 
69 
70 typedef vec<histogram_value> histogram_values;
71 
72 extern void gimple_find_values_to_profile (histogram_values *);
73 extern bool gimple_value_profile_transformations (void);
74 
75 histogram_value gimple_histogram_value (struct function *, gimple);
76 histogram_value gimple_histogram_value_of_type (struct function *, gimple,
77 						enum hist_type);
78 void gimple_add_histogram_value (struct function *, gimple, histogram_value);
79 void dump_histograms_for_stmt (struct function *, FILE *, gimple);
80 void gimple_remove_histogram_value (struct function *, gimple, histogram_value);
81 void gimple_remove_stmt_histograms (struct function *, gimple);
82 void gimple_duplicate_stmt_histograms (struct function *, gimple,
83 				       struct function *, gimple);
84 void gimple_move_stmt_histograms (struct function *, gimple, gimple);
85 void verify_histograms (void);
86 void free_histograms (void);
87 void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *);
88 
89 /* In tree-profile.c.  */
90 extern void gimple_init_edge_profiler (void);
91 extern void gimple_gen_edge_profiler (int, edge);
92 extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned);
93 extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned);
94 extern void gimple_gen_one_value_profiler (histogram_value, unsigned, unsigned);
95 extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned);
96 extern void gimple_gen_ic_func_profiler (void);
97 extern void gimple_gen_const_delta_profiler (histogram_value,
98 					     unsigned, unsigned);
99 extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
100 extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
101 
102 /* In profile.c.  */
103 extern void init_branch_prob (void);
104 extern void branch_prob (void);
105 extern void end_branch_prob (void);
106 
107 #endif	/* GCC_VALUE_PROF_H */
108 
109