1132718Skan/* Definitions for transformations based on profile information for values. 2169689Skan Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. 3132718Skan 4132718SkanThis file is part of GCC. 5132718Skan 6132718SkanGCC is free software; you can redistribute it and/or modify it under 7132718Skanthe terms of the GNU General Public License as published by the Free 8132718SkanSoftware Foundation; either version 2, or (at your option) any later 9132718Skanversion. 10132718Skan 11132718SkanGCC is distributed in the hope that it will be useful, but WITHOUT ANY 12132718SkanWARRANTY; without even the implied warranty of MERCHANTABILITY or 13132718SkanFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14132718Skanfor more details. 15132718Skan 16132718SkanYou should have received a copy of the GNU General Public License 17132718Skanalong with GCC; see the file COPYING. If not, write to the Free 18169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 19169689Skan02110-1301, USA. */ 20132718Skan 21169689Skan#ifndef GCC_VALUE_PROF_H 22169689Skan#define GCC_VALUE_PROF_H 23169689Skan 24132718Skan/* Supported histogram types. */ 25132718Skanenum hist_type 26132718Skan{ 27132718Skan HIST_TYPE_INTERVAL, /* Measures histogram of values inside a specified 28132718Skan interval. */ 29132718Skan HIST_TYPE_POW2, /* Histogram of power of 2 values. */ 30132718Skan HIST_TYPE_SINGLE_VALUE, /* Tries to identify the value that is (almost) 31132718Skan always constant. */ 32132718Skan HIST_TYPE_CONST_DELTA /* Tries to identify the (almost) always constant 33132718Skan difference between two evaluations of a value. */ 34132718Skan}; 35132718Skan 36132718Skan#define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER) 37132718Skan#define HIST_TYPE_FOR_COUNTER(COUNTER) \ 38132718Skan ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER)) 39132718Skan 40132718Skan/* The value to measure. */ 41169689Skanstruct histogram_value_t 42132718Skan{ 43169689Skan struct 44169689Skan { 45169689Skan tree value; /* The value to profile. */ 46169689Skan tree stmt; /* Insn containing the value. */ 47169689Skan gcov_type *counters; /* Pointer to first counter. */ 48169689Skan struct histogram_value_t *next; /* Linked list pointer. */ 49169689Skan } hvalue; 50169689Skan enum hist_type type; /* Type of information to measure. */ 51169689Skan unsigned n_counters; /* Number of required counters. */ 52132718Skan union 53132718Skan { 54132718Skan struct 55132718Skan { 56132718Skan int int_start; /* First value in interval. */ 57169689Skan unsigned int steps; /* Number of values in it. */ 58132718Skan } intvl; /* Interval histogram data. */ 59132718Skan } hdata; /* Profiled information specific data. */ 60132718Skan}; 61132718Skan 62169689Skantypedef struct histogram_value_t *histogram_value; 63169689Skan 64169689SkanDEF_VEC_P(histogram_value); 65169689SkanDEF_VEC_ALLOC_P(histogram_value,heap); 66169689Skan 67169689Skantypedef VEC(histogram_value,heap) *histogram_values; 68169689Skan 69169689Skan/* Hooks registration. */ 70169689Skanextern void tree_register_value_prof_hooks (void); 71169689Skan 72169689Skan/* IR-independent entry points. */ 73169689Skanextern void find_values_to_profile (histogram_values *); 74132718Skanextern bool value_profile_transformations (void); 75169689Skan 76169689Skan/* External declarations for edge-based profiling. */ 77169689Skanstruct profile_hooks { 78169689Skan 79169689Skan /* Insert code to initialize edge profiler. */ 80169689Skan void (*init_edge_profiler) (void); 81169689Skan 82169689Skan /* Insert code to increment an edge count. */ 83169689Skan void (*gen_edge_profiler) (int, edge); 84169689Skan 85169689Skan /* Insert code to increment the interval histogram counter. */ 86169689Skan void (*gen_interval_profiler) (histogram_value, unsigned, unsigned); 87169689Skan 88169689Skan /* Insert code to increment the power of two histogram counter. */ 89169689Skan void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned); 90169689Skan 91169689Skan /* Insert code to find the most common value. */ 92169689Skan void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned); 93169689Skan 94169689Skan /* Insert code to find the most common value of a difference between two 95169689Skan evaluations of an expression. */ 96169689Skan void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned); 97169689Skan}; 98169689Skan 99169689Skan/* In profile.c. */ 100169689Skanextern void init_branch_prob (void); 101169689Skanextern void branch_prob (void); 102169689Skanextern void end_branch_prob (void); 103169689Skanextern void tree_register_profile_hooks (void); 104169689Skan 105169689Skan/* In tree-profile.c. */ 106169689Skanextern struct profile_hooks tree_profile_hooks; 107169689Skan 108169689Skan#endif /* GCC_VALUE_PROF_H */ 109169689Skan 110