]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/value-prof.h
Merge tree-ssa-20020619-branch into mainline.
[thirdparty/gcc.git] / gcc / value-prof.h
CommitLineData
1c72f4ef
ZD
1/* Definitions for transformations based on profile information for values.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 2, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING. If not, write to the Free
18Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
6de9cd9a
DN
21#ifndef GCC_VALUE_PROF_H
22#define GCC_VALUE_PROF_H
23
1c72f4ef
ZD
24/* Supported histogram types. */
25enum hist_type
26{
27 HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified
28 interval. */
29 HIST_TYPE_POW2, /* Histogram of power of 2 values. */
30 HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost)
31 always constant. */
32 HIST_TYPE_CONST_DELTA /* Tries to identify the (almost) always constant
33 difference between two evaluations of a value. */
34};
35
6e885ee3
ZD
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))
39
1c72f4ef 40/* The value to measure. */
6de9cd9a 41/* The void *'s are either rtx or tree, depending on which IR is in use. */
1c72f4ef
ZD
42struct histogram_value
43{
6de9cd9a 44 void * value; /* The value to profile. */
1c72f4ef 45 enum machine_mode mode; /* And its mode. */
6de9cd9a
DN
46 void * seq; /* Insns required to count the profiled value. */
47 void * insn; /* Insn before that to measure. */
1c72f4ef 48 enum hist_type type; /* Type of information to measure. */
e0bb17a8 49 unsigned n_counters; /* Number of required counters. */
1c72f4ef
ZD
50 union
51 {
52 struct
53 {
54 int int_start; /* First value in interval. */
55 int steps; /* Number of values in it. */
56 int may_be_less; /* May the value be below? */
57 int may_be_more; /* Or above. */
58 } intvl; /* Interval histogram data. */
59 struct
60 {
61 int may_be_other; /* If the value may be non-positive or not 2^k. */
62 } pow2; /* Power of 2 histogram data. */
63 } hdata; /* Profiled information specific data. */
64};
65
6de9cd9a
DN
66/* Hooks registration. */
67extern void rtl_register_value_prof_hooks (void);
68extern void tree_register_value_prof_hooks (void);
69
70/* IR-independent entry points. */
1c72f4ef
ZD
71extern void find_values_to_profile (unsigned *, struct histogram_value **);
72extern void free_profiled_values (unsigned, struct histogram_value *);
fca9dc00 73extern bool value_profile_transformations (void);
6de9cd9a
DN
74\f
75/* External declarations for edge-based profiling. */
76struct profile_hooks {
77 /* Insert code to increment an edge count. */
78 void (*gen_edge_profiler) (int, edge);
79
80 /* Insert code to increment the interval histogram counter. */
81 void (*gen_interval_profiler) (struct histogram_value *, unsigned, unsigned);
82
83 /* Insert code to increment the power of two histogram counter. */
84 void (*gen_pow2_profiler) (struct histogram_value *, unsigned, unsigned);
85
86 /* Insert code to find the most common value. */
87 void (*gen_one_value_profiler) (struct histogram_value *, unsigned, unsigned);
88
89 /* Insert code to find the most common value of a difference between two
90 evaluations of an expression. */
91 void (*gen_const_delta_profiler) (struct histogram_value *, unsigned,
92 unsigned);
93 FILE * (*profile_dump_file) (void);
94};
95
96/* In profile.c. */
97extern void init_branch_prob (void);
98extern void branch_prob (void);
99extern void end_branch_prob (void);
100extern void tree_register_profile_hooks (void);
101extern void rtl_register_profile_hooks (void);
102
103/* In tree-profile.c. */
104extern struct profile_hooks tree_profile_hooks;
105
106/* In rtl-profile.c. */
107extern struct profile_hooks rtl_profile_hooks;
108
109#endif /* GCC_VALUE_PROF_H */
110