predict.h 3.8 KB

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