value-prof.h revision 132718
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
21/* Supported histogram types.  */
22enum hist_type
23{
24  HIST_TYPE_INTERVAL,	/* Measures histogram of values inside a specified
25			   interval.  */
26  HIST_TYPE_POW2,	/* Histogram of power of 2 values.  */
27  HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost)
28			   always constant.  */
29  HIST_TYPE_CONST_DELTA	/* Tries to identify the (almost) always constant
30			   difference between two evaluations of a value.  */
31};
32
33#define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)
34#define HIST_TYPE_FOR_COUNTER(COUNTER) \
35  ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
36
37/* The value to measure.  */
38struct histogram_value
39{
40  rtx value;		/* The value to profile.  */
41  enum machine_mode mode; /* And its mode.  */
42  rtx seq;		/* Insns required to count the profiled value.  */
43  rtx insn;		/* Insn before that to measure.  */
44  enum hist_type type;	/* Type of information to measure.  */
45  unsigned n_counters;	/* Number of required counters.  */
46  union
47    {
48      struct
49	{
50	  int int_start;	/* First value in interval.  */
51	  int steps;		/* Number of values in it.  */
52	  int may_be_less;	/* May the value be below?  */
53	  int may_be_more;	/* Or above.  */
54	} intvl;	/* Interval histogram data.  */
55      struct
56	{
57	  int may_be_other;	/* If the value may be non-positive or not 2^k.  */
58	} pow2;		/* Power of 2 histogram data.  */
59    } hdata;		/* Profiled information specific data.  */
60};
61
62extern void find_values_to_profile (unsigned *, struct histogram_value **);
63extern void free_profiled_values (unsigned, struct histogram_value *);
64extern bool value_profile_transformations (void);
65