value-prof.h 5.0 KB

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