1 /* Definitions for transformations based on profile information for values.
2 Copyright (C) 2003 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 2, or (at your option) any later
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
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
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 #ifndef GCC_VALUE_PROF_H
22 #define GCC_VALUE_PROF_H
24 /* Supported histogram types. */
27 HIST_TYPE_INTERVAL
, /* Measures histogram of values inside a specified
29 HIST_TYPE_POW2
, /* Histogram of power of 2 values. */
30 HIST_TYPE_SINGLE_VALUE
, /* Tries to identify the value that is (almost)
32 HIST_TYPE_CONST_DELTA
/* Tries to identify the (almost) always constant
33 difference between two evaluations of a value. */
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))
40 /* The value to measure. */
41 /* The void *'s are either rtx or tree, depending on which IR is in use. */
42 struct histogram_value_t
GTY(())
44 PTR
GTY ((skip (""))) value
; /* The value to profile. */
45 enum machine_mode mode
; /* And its mode. */
46 PTR
GTY ((skip (""))) seq
; /* Insns required to count the
48 PTR
GTY ((skip (""))) insn
; /* Insn before that to measure. */
49 enum hist_type type
; /* Type of information to measure. */
50 unsigned n_counters
; /* Number of required counters. */
55 int int_start
; /* First value in interval. */
56 int steps
; /* Number of values in it. */
57 int may_be_less
; /* May the value be below? */
58 int may_be_more
; /* Or above. */
59 } intvl
; /* Interval histogram data. */
62 int may_be_other
; /* If the value may be non-positive or not 2^k. */
63 } pow2
; /* Power of 2 histogram data. */
64 } hdata
; /* Profiled information specific data. */
67 typedef struct histogram_value_t
*histogram_value
;
69 DEF_VEC_P(histogram_value
);
71 typedef VEC(histogram_value
) *histogram_values
;
73 /* Hooks registration. */
74 extern void rtl_register_value_prof_hooks (void);
75 extern void tree_register_value_prof_hooks (void);
77 /* IR-independent entry points. */
78 extern void find_values_to_profile (histogram_values
*);
79 extern bool value_profile_transformations (void);
81 /* External declarations for edge-based profiling. */
82 struct profile_hooks
{
83 /* Insert code to increment an edge count. */
84 void (*gen_edge_profiler
) (int, edge
);
86 /* Insert code to increment the interval histogram counter. */
87 void (*gen_interval_profiler
) (histogram_value
, unsigned, unsigned);
89 /* Insert code to increment the power of two histogram counter. */
90 void (*gen_pow2_profiler
) (histogram_value
, unsigned, unsigned);
92 /* Insert code to find the most common value. */
93 void (*gen_one_value_profiler
) (histogram_value
, unsigned, unsigned);
95 /* Insert code to find the most common value of a difference between two
96 evaluations of an expression. */
97 void (*gen_const_delta_profiler
) (histogram_value
, unsigned, unsigned);
98 FILE * (*profile_dump_file
) (void);
102 extern void init_branch_prob (void);
103 extern void branch_prob (void);
104 extern void end_branch_prob (void);
105 extern void tree_register_profile_hooks (void);
106 extern void rtl_register_profile_hooks (void);
108 /* In tree-profile.c. */
109 extern struct profile_hooks tree_profile_hooks
;
111 /* In rtl-profile.c. */
112 extern struct profile_hooks rtl_profile_hooks
;
114 #endif /* GCC_VALUE_PROF_H */