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.

150 lines
4.0KB

  1. /* pass_manager.h - The pipeline of optimization passes
  2. Copyright (C) 2013-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_PASS_MANAGER_H
  16. #define GCC_PASS_MANAGER_H
  17. class opt_pass;
  18. struct register_pass_info;
  19. /* Define a list of pass lists so that both passes.c and plugins can easily
  20. find all the pass lists. */
  21. #define GCC_PASS_LISTS \
  22. DEF_PASS_LIST (all_lowering_passes) \
  23. DEF_PASS_LIST (all_small_ipa_passes) \
  24. DEF_PASS_LIST (all_regular_ipa_passes) \
  25. DEF_PASS_LIST (all_late_ipa_passes) \
  26. DEF_PASS_LIST (all_passes)
  27. #define DEF_PASS_LIST(LIST) PASS_LIST_NO_##LIST,
  28. enum pass_list
  29. {
  30. GCC_PASS_LISTS
  31. PASS_LIST_NUM
  32. };
  33. #undef DEF_PASS_LIST
  34. namespace gcc {
  35. class context;
  36. class pass_manager
  37. {
  38. public:
  39. pass_manager (context *ctxt);
  40. ~pass_manager ();
  41. void register_pass (struct register_pass_info *pass_info);
  42. void register_one_dump_file (opt_pass *pass);
  43. opt_pass *get_pass_for_id (int id) const;
  44. void dump_passes () const;
  45. void dump_profile_report () const;
  46. void finish_optimization_passes ();
  47. /* Access to specific passes, so that the majority can be private. */
  48. void execute_early_local_passes ();
  49. unsigned int execute_pass_mode_switching ();
  50. /* Various passes are manually cloned by epiphany. */
  51. opt_pass *get_pass_split_all_insns () const {
  52. return pass_split_all_insns_1;
  53. }
  54. opt_pass *get_pass_mode_switching () const {
  55. return pass_mode_switching_1;
  56. }
  57. opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; }
  58. opt_pass *get_pass_profile () const { return pass_profile_1; }
  59. void register_pass_name (opt_pass *pass, const char *name);
  60. opt_pass *get_pass_by_name (const char *name);
  61. opt_pass *get_rest_of_compilation () const
  62. {
  63. return pass_rest_of_compilation_1;
  64. }
  65. opt_pass *get_clean_slate () const { return pass_clean_state_1; }
  66. public:
  67. /* The root of the compilation pass tree, once constructed. */
  68. opt_pass *all_passes;
  69. opt_pass *all_small_ipa_passes;
  70. opt_pass *all_lowering_passes;
  71. opt_pass *all_regular_ipa_passes;
  72. opt_pass *all_late_ipa_passes;
  73. /* A map from static pass id to optimization pass. */
  74. opt_pass **passes_by_id;
  75. int passes_by_id_size;
  76. opt_pass **pass_lists[PASS_LIST_NUM];
  77. private:
  78. void set_pass_for_id (int id, opt_pass *pass);
  79. void register_dump_files (opt_pass *pass);
  80. void create_pass_tab () const;
  81. private:
  82. context *m_ctxt;
  83. hash_map<nofree_string_hash, opt_pass *> *m_name_to_pass_map;
  84. /* References to all of the individual passes.
  85. These fields are generated via macro expansion.
  86. For example:
  87. NEXT_PASS (pass_build_cfg, 1);
  88. within pass-instances.def means that there is a field:
  89. opt_pass *pass_build_cfg_1;
  90. Similarly, the various:
  91. NEXT_PASS (pass_copy_prop, 1);
  92. ...
  93. NEXT_PASS (pass_copy_prop, 8);
  94. in pass-instances.def lead to fields:
  95. opt_pass *pass_copy_prop_1;
  96. ...
  97. opt_pass *pass_copy_prop_8; */
  98. #define INSERT_PASSES_AFTER(PASS)
  99. #define PUSH_INSERT_PASSES_WITHIN(PASS)
  100. #define POP_INSERT_PASSES()
  101. #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
  102. #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
  103. #define TERMINATE_PASS_LIST(PASS)
  104. #include "pass-instances.def"
  105. #undef INSERT_PASSES_AFTER
  106. #undef PUSH_INSERT_PASSES_WITHIN
  107. #undef POP_INSERT_PASSES
  108. #undef NEXT_PASS
  109. #undef NEXT_PASS_WITH_ARG
  110. #undef TERMINATE_PASS_LIST
  111. }; // class pass_manager
  112. } // namespace gcc
  113. #endif /* ! GCC_PASS_MANAGER_H */