]>
Commit | Line | Data |
---|---|---|
315f8c0e | 1 | /* pass_manager.h - The pipeline of optimization passes |
aeee4812 | 2 | Copyright (C) 2013-2023 Free Software Foundation, Inc. |
315f8c0e DM |
3 | |
4 | This file is part of GCC. | |
5 | ||
6 | GCC is free software; you can redistribute it and/or modify it under | |
7 | the terms of the GNU General Public License as published by the Free | |
8 | Software Foundation; either version 3, or (at your option) any later | |
9 | version. | |
10 | ||
11 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
12 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GCC; see the file COPYING3. If not see | |
18 | <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #ifndef GCC_PASS_MANAGER_H | |
21 | #define GCC_PASS_MANAGER_H | |
22 | ||
23 | class opt_pass; | |
24 | struct register_pass_info; | |
25 | ||
e53b6e56 | 26 | /* Define a list of pass lists so that both passes.cc and plugins can easily |
315f8c0e DM |
27 | find all the pass lists. */ |
28 | #define GCC_PASS_LISTS \ | |
29 | DEF_PASS_LIST (all_lowering_passes) \ | |
30 | DEF_PASS_LIST (all_small_ipa_passes) \ | |
31 | DEF_PASS_LIST (all_regular_ipa_passes) \ | |
1f1e44ed | 32 | DEF_PASS_LIST (all_late_ipa_passes) \ |
315f8c0e DM |
33 | DEF_PASS_LIST (all_passes) |
34 | ||
35 | #define DEF_PASS_LIST(LIST) PASS_LIST_NO_##LIST, | |
36 | enum pass_list | |
37 | { | |
38 | GCC_PASS_LISTS | |
39 | PASS_LIST_NUM | |
40 | }; | |
41 | #undef DEF_PASS_LIST | |
42 | ||
43 | namespace gcc { | |
44 | ||
45 | class context; | |
46 | ||
6cd4d135 | 47 | class pass_manager |
315f8c0e DM |
48 | { |
49 | public: | |
c3284718 | 50 | pass_manager (context *ctxt); |
10fdd6e9 | 51 | ~pass_manager (); |
315f8c0e DM |
52 | |
53 | void register_pass (struct register_pass_info *pass_info); | |
6a5ac314 | 54 | void register_one_dump_file (opt_pass *pass); |
315f8c0e DM |
55 | |
56 | opt_pass *get_pass_for_id (int id) const; | |
57 | ||
58 | void dump_passes () const; | |
59 | ||
60 | void dump_profile_report () const; | |
61 | ||
f7695dbf DM |
62 | void finish_optimization_passes (); |
63 | ||
64 | /* Access to specific passes, so that the majority can be private. */ | |
65 | void execute_early_local_passes (); | |
66 | unsigned int execute_pass_mode_switching (); | |
67 | ||
05555c4a DM |
68 | /* Various passes are manually cloned by epiphany. */ |
69 | opt_pass *get_pass_split_all_insns () const { | |
70 | return pass_split_all_insns_1; | |
71 | } | |
72 | opt_pass *get_pass_mode_switching () const { | |
73 | return pass_mode_switching_1; | |
74 | } | |
75 | opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; } | |
103ff0d6 | 76 | opt_pass *get_pass_profile () const { return pass_profile_1; } |
05555c4a | 77 | |
58d4c836 DM |
78 | void register_pass_name (opt_pass *pass, const char *name); |
79 | ||
80 | opt_pass *get_pass_by_name (const char *name); | |
81 | ||
c2e84327 DM |
82 | opt_pass *get_rest_of_compilation () const |
83 | { | |
84 | return pass_rest_of_compilation_1; | |
85 | } | |
86 | opt_pass *get_clean_slate () const { return pass_clean_state_1; } | |
87 | ||
315f8c0e DM |
88 | public: |
89 | /* The root of the compilation pass tree, once constructed. */ | |
90 | opt_pass *all_passes; | |
91 | opt_pass *all_small_ipa_passes; | |
92 | opt_pass *all_lowering_passes; | |
93 | opt_pass *all_regular_ipa_passes; | |
315f8c0e DM |
94 | opt_pass *all_late_ipa_passes; |
95 | ||
96 | /* A map from static pass id to optimization pass. */ | |
97 | opt_pass **passes_by_id; | |
98 | int passes_by_id_size; | |
99 | ||
100 | opt_pass **pass_lists[PASS_LIST_NUM]; | |
101 | ||
102 | private: | |
103 | void set_pass_for_id (int id, opt_pass *pass); | |
a23c217d | 104 | void register_dump_files (opt_pass *pass); |
58d4c836 | 105 | void create_pass_tab () const; |
315f8c0e DM |
106 | |
107 | private: | |
65d3284b | 108 | context *m_ctxt; |
bc84b61b | 109 | hash_map<free_string_hash, opt_pass *> *m_name_to_pass_map; |
315f8c0e | 110 | |
f7695dbf DM |
111 | /* References to all of the individual passes. |
112 | These fields are generated via macro expansion. | |
113 | ||
114 | For example: | |
115 | NEXT_PASS (pass_build_cfg, 1); | |
116 | within pass-instances.def means that there is a field: | |
117 | opt_pass *pass_build_cfg_1; | |
118 | ||
119 | Similarly, the various: | |
120 | NEXT_PASS (pass_copy_prop, 1); | |
121 | ... | |
122 | NEXT_PASS (pass_copy_prop, 8); | |
123 | in pass-instances.def lead to fields: | |
124 | opt_pass *pass_copy_prop_1; | |
125 | ... | |
126 | opt_pass *pass_copy_prop_8; */ | |
127 | ||
128 | #define INSERT_PASSES_AFTER(PASS) | |
129 | #define PUSH_INSERT_PASSES_WITHIN(PASS) | |
130 | #define POP_INSERT_PASSES() | |
131 | #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM | |
b0c77505 | 132 | #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM) |
17e7ab87 | 133 | #define TERMINATE_PASS_LIST(PASS) |
f7695dbf DM |
134 | |
135 | #include "pass-instances.def" | |
136 | ||
137 | #undef INSERT_PASSES_AFTER | |
138 | #undef PUSH_INSERT_PASSES_WITHIN | |
139 | #undef POP_INSERT_PASSES | |
140 | #undef NEXT_PASS | |
b0c77505 | 141 | #undef NEXT_PASS_WITH_ARG |
f7695dbf DM |
142 | #undef TERMINATE_PASS_LIST |
143 | ||
315f8c0e DM |
144 | }; // class pass_manager |
145 | ||
146 | } // namespace gcc | |
147 | ||
148 | #endif /* ! GCC_PASS_MANAGER_H */ |