You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.7KB

  1. /* Definitions for transformations based on profile information for values.
  2. Copyright (C) 2003-2020 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_TOPN_VALUES, /* Tries to identify the N most common values. */
  24. HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost)
  25. called in indirect call */
  26. HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */
  27. HIST_TYPE_IOR, /* Used to compute expected alignment. */
  28. HIST_TYPE_TIME_PROFILE, /* Used for time profile */
  29. HIST_TYPE_MAX
  30. };
  31. #define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)
  32. #define HIST_TYPE_FOR_COUNTER(COUNTER) \
  33. ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
  34. /* The value to measure. */
  35. struct histogram_value_t
  36. {
  37. struct
  38. {
  39. tree value; /* The value to profile. */
  40. gimple *stmt; /* Insn containing the value. */
  41. gcov_type *counters; /* Pointer to first counter. */
  42. struct histogram_value_t *next; /* Linked list pointer. */
  43. } hvalue;
  44. enum hist_type type; /* Type of information to measure. */
  45. unsigned n_counters; /* Number of required counters. */
  46. struct function *fun;
  47. union
  48. {
  49. struct
  50. {
  51. int int_start; /* First value in interval. */
  52. unsigned int steps; /* Number of values in it. */
  53. } intvl; /* Interval histogram data. */
  54. } hdata; /* Profiled information specific data. */
  55. };
  56. typedef struct histogram_value_t *histogram_value;
  57. typedef const struct histogram_value_t *const_histogram_value;
  58. typedef vec<histogram_value> histogram_values;
  59. extern void gimple_find_values_to_profile (histogram_values *);
  60. extern bool gimple_value_profile_transformations (void);
  61. histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type,
  62. gimple *stmt = NULL,
  63. tree value = NULL_TREE);
  64. histogram_value gimple_histogram_value (struct function *, gimple *);
  65. histogram_value gimple_histogram_value_of_type (struct function *, gimple *,
  66. enum hist_type);
  67. void gimple_add_histogram_value (struct function *, gimple *, histogram_value);
  68. void dump_histograms_for_stmt (struct function *, FILE *, gimple *);
  69. void gimple_remove_histogram_value (struct function *, gimple *, histogram_value);
  70. void gimple_remove_stmt_histograms (struct function *, gimple *);
  71. void gimple_duplicate_stmt_histograms (struct function *, gimple *,
  72. struct function *, gimple *);
  73. void gimple_move_stmt_histograms (struct function *, gimple *, gimple *);
  74. void verify_histograms (void);
  75. void free_histograms (function *);
  76. void stringop_block_profile (gimple *, unsigned int *, HOST_WIDE_INT *);
  77. gcall *gimple_ic (gcall *, struct cgraph_node *, profile_probability);
  78. bool get_nth_most_common_value (gimple *stmt, const char *counter_type,
  79. histogram_value hist, gcov_type *value,
  80. gcov_type *count, gcov_type *all,
  81. unsigned n = 0);
  82. /* In tree-profile.c. */
  83. extern void gimple_init_gcov_profiler (void);
  84. extern void gimple_gen_edge_profiler (int, edge);
  85. extern void gimple_gen_interval_profiler (histogram_value, unsigned);
  86. extern void gimple_gen_pow2_profiler (histogram_value, unsigned);
  87. extern void gimple_gen_topn_values_profiler (histogram_value, unsigned);
  88. extern void gimple_gen_ic_profiler (histogram_value, unsigned);
  89. extern void gimple_gen_ic_func_profiler (void);
  90. extern void gimple_gen_time_profiler (unsigned);
  91. extern void gimple_gen_average_profiler (histogram_value, unsigned);
  92. extern void gimple_gen_ior_profiler (histogram_value, unsigned);
  93. extern void stream_out_histogram_value (struct output_block *, histogram_value);
  94. extern void stream_in_histogram_value (class lto_input_block *, gimple *);
  95. extern struct cgraph_node* find_func_by_profile_id (int func_id);
  96. /* In profile.c. */
  97. extern void init_branch_prob (void);
  98. extern void branch_prob (bool);
  99. extern void read_thunk_profile (struct cgraph_node *);
  100. extern void end_branch_prob (void);
  101. #endif /* GCC_VALUE_PROF_H */