value-prof.h revision 169689
1292928Sdim/* Definitions for transformations based on profile information for values. 2292928Sdim Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. 3292928Sdim 4353358SdimThis file is part of GCC. 5353358Sdim 6353358SdimGCC is free software; you can redistribute it and/or modify it under 7292928Sdimthe terms of the GNU General Public License as published by the Free 8292928SdimSoftware Foundation; either version 2, or (at your option) any later 9292928Sdimversion. 10292928Sdim 11292928SdimGCC is distributed in the hope that it will be useful, but WITHOUT ANY 12292928SdimWARRANTY; without even the implied warranty of MERCHANTABILITY or 13292928SdimFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14292928Sdimfor more details. 15292928Sdim 16292928SdimYou should have received a copy of the GNU General Public License 17292928Sdimalong with GCC; see the file COPYING. If not, write to the Free 18292928SdimSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 19292928Sdim02110-1301, USA. */ 20292928Sdim 21292928Sdim#ifndef GCC_VALUE_PROF_H 22292928Sdim#define GCC_VALUE_PROF_H 23292928Sdim 24292928Sdim/* Supported histogram types. */ 25292928Sdimenum hist_type 26292928Sdim{ 27292928Sdim HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified 28292928Sdim interval. */ 29292928Sdim HIST_TYPE_POW2, /* Histogram of power of 2 values. */ 30292928Sdim HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost) 31292928Sdim always constant. */ 32292928Sdim HIST_TYPE_CONST_DELTA /* Tries to identify the (almost) always constant 33292928Sdim difference between two evaluations of a value. */ 34292928Sdim}; 35292928Sdim 36292928Sdim#define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) 37292928Sdim#define HIST_TYPE_FOR_COUNTER(COUNTER) \ 38292928Sdim ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) 39292928Sdim 40292928Sdim/* The value to measure. */ 41292928Sdimstruct histogram_value_t 42292928Sdim{ 43292928Sdim struct 44292928Sdim { 45292928Sdim tree value; /* The value to profile. */ 46292928Sdim tree stmt; /* Insn containing the value. */ 47292928Sdim gcov_type *counters; /* Pointer to first counter. */ 48292928Sdim struct histogram_value_t *next; /* Linked list pointer. */ 49292928Sdim } hvalue; 50292928Sdim enum hist_type type; /* Type of information to measure. */ 51292928Sdim unsigned n_counters; /* Number of required counters. */ 52292928Sdim union 53292928Sdim { 54292928Sdim struct 55292928Sdim { 56292928Sdim int int_start; /* First value in interval. */ 57292928Sdim unsigned int steps; /* Number of values in it. */ 58292928Sdim } intvl; /* Interval histogram data. */ 59292928Sdim } hdata; /* Profiled information specific data. */ 60292928Sdim}; 61292928Sdim 62292928Sdimtypedef struct histogram_value_t *histogram_value; 63292928Sdim 64292928SdimDEF_VEC_P(histogram_value); 65292928SdimDEF_VEC_ALLOC_P(histogram_value,heap); 66292928Sdim 67292928Sdimtypedef VEC(histogram_value,heap) *histogram_values; 68292928Sdim 69292928Sdim/* Hooks registration. */ 70292928Sdimextern void tree_register_value_prof_hooks (void); 71292928Sdim 72292928Sdim/* IR-independent entry points. */ 73292928Sdimextern void find_values_to_profile (histogram_values *); 74292928Sdimextern bool value_profile_transformations (void); 75292928Sdim 76292928Sdim/* External declarations for edge-based profiling. */ 77292928Sdimstruct profile_hooks { 78292928Sdim 79292928Sdim /* Insert code to initialize edge profiler. */ 80292928Sdim void (*init_edge_profiler) (void); 81292928Sdim 82292928Sdim /* Insert code to increment an edge count. */ 83292928Sdim void (*gen_edge_profiler) (int, edge); 84292928Sdim 85292928Sdim /* Insert code to increment the interval histogram counter. */ 86292928Sdim void (*gen_interval_profiler) (histogram_value, unsigned, unsigned); 87292928Sdim 88292928Sdim /* Insert code to increment the power of two histogram counter. */ 89292928Sdim void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned); 90292928Sdim 91292928Sdim /* Insert code to find the most common value. */ 92292928Sdim void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned); 93292928Sdim 94292928Sdim /* Insert code to find the most common value of a difference between two 95292928Sdim evaluations of an expression. */ 96292928Sdim void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned); 97292928Sdim}; 98292928Sdim 99292928Sdim/* In profile.c. */ 100292928Sdimextern void init_branch_prob (void); 101292928Sdimextern void branch_prob (void); 102292928Sdimextern void end_branch_prob (void); 103292928Sdimextern void tree_register_profile_hooks (void); 104292928Sdim 105292928Sdim/* In tree-profile.c. */ 106292928Sdimextern struct profile_hooks tree_profile_hooks; 107292928Sdim 108292928Sdim#endif /* GCC_VALUE_PROF_H */ 109292928Sdim 110292928Sdim