pass_manager.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* pass_manager.h - The pipeline of optimization passes
  2. Copyright (C) 2013-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_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. void *operator new (size_t sz);
  40. void operator delete (void *ptr);
  41. pass_manager (context *ctxt);
  42. ~pass_manager ();
  43. void register_pass (struct register_pass_info *pass_info);
  44. void register_one_dump_file (opt_pass *pass);
  45. opt_pass *get_pass_for_id (int id) const;
  46. void dump_passes () const;
  47. void dump_profile_report () const;
  48. void finish_optimization_passes ();
  49. /* Access to specific passes, so that the majority can be private. */
  50. void execute_early_local_passes ();
  51. unsigned int execute_pass_mode_switching ();
  52. /* Various passes are manually cloned by epiphany. */
  53. opt_pass *get_pass_split_all_insns () const {
  54. return pass_split_all_insns_1;
  55. }
  56. opt_pass *get_pass_mode_switching () const {
  57. return pass_mode_switching_1;
  58. }
  59. opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; }
  60. opt_pass *get_pass_profile () const { return pass_profile_1; }
  61. public:
  62. /* The root of the compilation pass tree, once constructed. */
  63. opt_pass *all_passes;
  64. opt_pass *all_small_ipa_passes;
  65. opt_pass *all_lowering_passes;
  66. opt_pass *all_regular_ipa_passes;
  67. opt_pass *all_late_ipa_passes;
  68. /* A map from static pass id to optimization pass. */
  69. opt_pass **passes_by_id;
  70. int passes_by_id_size;
  71. opt_pass **pass_lists[PASS_LIST_NUM];
  72. private:
  73. void set_pass_for_id (int id, opt_pass *pass);
  74. void register_dump_files (opt_pass *pass);
  75. private:
  76. context *m_ctxt;
  77. /* References to all of the individual passes.
  78. These fields are generated via macro expansion.
  79. For example:
  80. NEXT_PASS (pass_build_cfg, 1);
  81. within pass-instances.def means that there is a field:
  82. opt_pass *pass_build_cfg_1;
  83. Similarly, the various:
  84. NEXT_PASS (pass_copy_prop, 1);
  85. ...
  86. NEXT_PASS (pass_copy_prop, 8);
  87. in pass-instances.def lead to fields:
  88. opt_pass *pass_copy_prop_1;
  89. ...
  90. opt_pass *pass_copy_prop_8; */
  91. #define INSERT_PASSES_AFTER(PASS)
  92. #define PUSH_INSERT_PASSES_WITHIN(PASS)
  93. #define POP_INSERT_PASSES()
  94. #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
  95. #define TERMINATE_PASS_LIST()
  96. #include "pass-instances.def"
  97. #undef INSERT_PASSES_AFTER
  98. #undef PUSH_INSERT_PASSES_WITHIN
  99. #undef POP_INSERT_PASSES
  100. #undef NEXT_PASS
  101. #undef TERMINATE_PASS_LIST
  102. }; // class pass_manager
  103. } // namespace gcc
  104. #endif /* ! GCC_PASS_MANAGER_H */