predict.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Definitions for branch prediction routines in the GNU compiler.
  2. Copyright (C) 2001-2019 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_PREDICT_H
  16. #define GCC_PREDICT_H
  17. #include "profile-count.h"
  18. /* Random guesstimation given names.
  19. PROB_VERY_UNLIKELY should be small enough so basic block predicted
  20. by it gets below HOT_BB_FREQUENCY_FRACTION. */
  21. #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1)
  22. #define PROB_EVEN (REG_BR_PROB_BASE / 2)
  23. #define PROB_VERY_LIKELY (REG_BR_PROB_BASE - PROB_VERY_UNLIKELY)
  24. #define PROB_ALWAYS (REG_BR_PROB_BASE)
  25. #define PROB_UNLIKELY (REG_BR_PROB_BASE / 5 - 1)
  26. #define PROB_LIKELY (REG_BR_PROB_BASE - PROB_UNLIKELY)
  27. #define PROB_UNINITIALIZED (-1)
  28. #define DEF_PREDICTOR(ENUM, NAME, HITRATE, FLAGS) ENUM,
  29. enum br_predictor
  30. {
  31. #include "predict.def"
  32. /* Upper bound on non-language-specific builtins. */
  33. END_PREDICTORS
  34. };
  35. #undef DEF_PREDICTOR
  36. enum prediction
  37. {
  38. NOT_TAKEN,
  39. TAKEN
  40. };
  41. /* In emit-rtl.c. */
  42. extern profile_probability split_branch_probability;
  43. extern gcov_type get_hot_bb_threshold (void);
  44. extern void set_hot_bb_threshold (gcov_type);
  45. extern bool maybe_hot_count_p (struct function *, profile_count);
  46. extern bool maybe_hot_bb_p (struct function *, const_basic_block);
  47. extern bool maybe_hot_edge_p (edge);
  48. extern bool probably_never_executed_bb_p (struct function *, const_basic_block);
  49. extern bool probably_never_executed_edge_p (struct function *, edge);
  50. extern bool optimize_function_for_size_p (struct function *);
  51. extern bool optimize_function_for_speed_p (struct function *);
  52. extern optimization_type function_optimization_type (struct function *);
  53. extern bool optimize_bb_for_size_p (const_basic_block);
  54. extern bool optimize_bb_for_speed_p (const_basic_block);
  55. extern optimization_type bb_optimization_type (const_basic_block);
  56. extern bool optimize_edge_for_size_p (edge);
  57. extern bool optimize_edge_for_speed_p (edge);
  58. extern bool optimize_insn_for_size_p (void);
  59. extern bool optimize_insn_for_speed_p (void);
  60. extern bool optimize_loop_for_size_p (struct loop *);
  61. extern bool optimize_loop_for_speed_p (struct loop *);
  62. extern bool optimize_loop_nest_for_speed_p (struct loop *);
  63. extern bool optimize_loop_nest_for_size_p (struct loop *);
  64. extern bool predictable_edge_p (edge);
  65. extern void rtl_profile_for_bb (basic_block);
  66. extern void rtl_profile_for_edge (edge);
  67. extern void default_rtl_profile (void);
  68. extern bool rtl_predicted_by_p (const_basic_block, enum br_predictor);
  69. extern bool gimple_predicted_by_p (const_basic_block, enum br_predictor);
  70. extern bool edge_probability_reliable_p (const_edge);
  71. extern bool br_prob_note_reliable_p (const_rtx);
  72. extern void predict_insn_def (rtx_insn *, enum br_predictor, enum prediction);
  73. extern void rtl_predict_edge (edge, enum br_predictor, int);
  74. extern void gimple_predict_edge (edge, enum br_predictor, int);
  75. extern void remove_predictions_associated_with_edge (edge);
  76. extern void predict_edge_def (edge, enum br_predictor, enum prediction);
  77. extern void invert_br_probabilities (rtx);
  78. extern void guess_outgoing_edge_probabilities (basic_block);
  79. extern void tree_guess_outgoing_edge_probabilities (basic_block);
  80. extern void tree_estimate_probability (bool);
  81. extern void handle_missing_profiles (void);
  82. extern bool update_max_bb_count (void);
  83. extern bool expensive_function_p (int);
  84. extern void estimate_bb_frequencies (bool);
  85. extern void compute_function_frequency (void);
  86. extern tree build_predict_expr (enum br_predictor, enum prediction);
  87. extern const char *predictor_name (enum br_predictor);
  88. extern void rebuild_frequencies (void);
  89. extern void report_predictor_hitrates (void);
  90. extern void force_edge_cold (edge, bool);
  91. extern void propagate_unlikely_bbs_forward (void);
  92. extern void add_reg_br_prob_note (rtx_insn *, profile_probability);
  93. /* In ipa-pure-const.c */
  94. extern void warn_function_cold (tree);
  95. #endif /* GCC_PREDICT_H */