1*e4b17023SJohn Marino /* Definitions for transformations based on profile information for values. 2*e4b17023SJohn Marino Copyright (C) 2003, 2004, 2005, 2007, 2008, 2010 3*e4b17023SJohn Marino Free Software Foundation, Inc. 4*e4b17023SJohn Marino 5*e4b17023SJohn Marino This file is part of GCC. 6*e4b17023SJohn Marino 7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 10*e4b17023SJohn Marino version. 11*e4b17023SJohn Marino 12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15*e4b17023SJohn Marino for more details. 16*e4b17023SJohn Marino 17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 18*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 20*e4b17023SJohn Marino 21*e4b17023SJohn Marino #ifndef GCC_VALUE_PROF_H 22*e4b17023SJohn Marino #define GCC_VALUE_PROF_H 23*e4b17023SJohn Marino 24*e4b17023SJohn Marino /* Supported histogram types. */ 25*e4b17023SJohn Marino enum hist_type 26*e4b17023SJohn Marino { 27*e4b17023SJohn Marino HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified 28*e4b17023SJohn Marino interval. */ 29*e4b17023SJohn Marino HIST_TYPE_POW2, /* Histogram of power of 2 values. */ 30*e4b17023SJohn Marino HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost) 31*e4b17023SJohn Marino always constant. */ 32*e4b17023SJohn Marino HIST_TYPE_CONST_DELTA, /* Tries to identify the (almost) always constant 33*e4b17023SJohn Marino difference between two evaluations of a value. */ 34*e4b17023SJohn Marino HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost) 35*e4b17023SJohn Marino called in indirect call */ 36*e4b17023SJohn Marino HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */ 37*e4b17023SJohn Marino HIST_TYPE_IOR /* Used to compute expected alignment. */ 38*e4b17023SJohn Marino }; 39*e4b17023SJohn Marino 40*e4b17023SJohn Marino #define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) 41*e4b17023SJohn Marino #define HIST_TYPE_FOR_COUNTER(COUNTER) \ 42*e4b17023SJohn Marino ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) 43*e4b17023SJohn Marino 44*e4b17023SJohn Marino 45*e4b17023SJohn Marino /* The value to measure. */ 46*e4b17023SJohn Marino struct histogram_value_t 47*e4b17023SJohn Marino { 48*e4b17023SJohn Marino struct 49*e4b17023SJohn Marino { 50*e4b17023SJohn Marino tree value; /* The value to profile. */ 51*e4b17023SJohn Marino gimple stmt; /* Insn containing the value. */ 52*e4b17023SJohn Marino gcov_type *counters; /* Pointer to first counter. */ 53*e4b17023SJohn Marino struct histogram_value_t *next; /* Linked list pointer. */ 54*e4b17023SJohn Marino } hvalue; 55*e4b17023SJohn Marino enum hist_type type; /* Type of information to measure. */ 56*e4b17023SJohn Marino unsigned n_counters; /* Number of required counters. */ 57*e4b17023SJohn Marino union 58*e4b17023SJohn Marino { 59*e4b17023SJohn Marino struct 60*e4b17023SJohn Marino { 61*e4b17023SJohn Marino int int_start; /* First value in interval. */ 62*e4b17023SJohn Marino unsigned int steps; /* Number of values in it. */ 63*e4b17023SJohn Marino } intvl; /* Interval histogram data. */ 64*e4b17023SJohn Marino } hdata; /* Profiled information specific data. */ 65*e4b17023SJohn Marino }; 66*e4b17023SJohn Marino 67*e4b17023SJohn Marino typedef struct histogram_value_t *histogram_value; 68*e4b17023SJohn Marino typedef const struct histogram_value_t *const_histogram_value; 69*e4b17023SJohn Marino 70*e4b17023SJohn Marino DEF_VEC_P(histogram_value); 71*e4b17023SJohn Marino DEF_VEC_ALLOC_P(histogram_value,heap); 72*e4b17023SJohn Marino 73*e4b17023SJohn Marino typedef VEC(histogram_value,heap) *histogram_values; 74*e4b17023SJohn Marino 75*e4b17023SJohn Marino extern void gimple_find_values_to_profile (histogram_values *); 76*e4b17023SJohn Marino extern bool gimple_value_profile_transformations (void); 77*e4b17023SJohn Marino 78*e4b17023SJohn Marino histogram_value gimple_histogram_value (struct function *, gimple); 79*e4b17023SJohn Marino histogram_value gimple_histogram_value_of_type (struct function *, gimple, 80*e4b17023SJohn Marino enum hist_type); 81*e4b17023SJohn Marino void gimple_add_histogram_value (struct function *, gimple, histogram_value); 82*e4b17023SJohn Marino void dump_histograms_for_stmt (struct function *, FILE *, gimple); 83*e4b17023SJohn Marino void gimple_remove_histogram_value (struct function *, gimple, histogram_value); 84*e4b17023SJohn Marino void gimple_remove_stmt_histograms (struct function *, gimple); 85*e4b17023SJohn Marino void gimple_duplicate_stmt_histograms (struct function *, gimple, 86*e4b17023SJohn Marino struct function *, gimple); 87*e4b17023SJohn Marino void gimple_move_stmt_histograms (struct function *, gimple, gimple); 88*e4b17023SJohn Marino void verify_histograms (void); 89*e4b17023SJohn Marino void free_histograms (void); 90*e4b17023SJohn Marino void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *); 91*e4b17023SJohn Marino 92*e4b17023SJohn Marino /* In tree-profile.c. */ 93*e4b17023SJohn Marino extern void gimple_init_edge_profiler (void); 94*e4b17023SJohn Marino extern void gimple_gen_edge_profiler (int, edge); 95*e4b17023SJohn Marino extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned); 96*e4b17023SJohn Marino extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned); 97*e4b17023SJohn Marino extern void gimple_gen_one_value_profiler (histogram_value, unsigned, unsigned); 98*e4b17023SJohn Marino extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned); 99*e4b17023SJohn Marino extern void gimple_gen_ic_func_profiler (void); 100*e4b17023SJohn Marino extern void gimple_gen_const_delta_profiler (histogram_value, 101*e4b17023SJohn Marino unsigned, unsigned); 102*e4b17023SJohn Marino extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned); 103*e4b17023SJohn Marino extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned); 104*e4b17023SJohn Marino 105*e4b17023SJohn Marino /* In profile.c. */ 106*e4b17023SJohn Marino extern void init_branch_prob (void); 107*e4b17023SJohn Marino extern void branch_prob (void); 108*e4b17023SJohn Marino extern void end_branch_prob (void); 109*e4b17023SJohn Marino 110*e4b17023SJohn Marino #endif /* GCC_VALUE_PROF_H */ 111*e4b17023SJohn Marino 112