]>
Commit | Line | Data |
---|---|---|
3ea50c01 | 1 | /* pass_manager.h - The pipeline of optimization passes |
3aea1f79 | 2 | Copyright (C) 2013-2014 Free Software Foundation, Inc. |
3ea50c01 | 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 | ||
26 | /* Define a list of pass lists so that both passes.c and plugins can easily | |
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) \ | |
3ea50c01 | 32 | DEF_PASS_LIST (all_passes) |
33 | ||
34 | #define DEF_PASS_LIST(LIST) PASS_LIST_NO_##LIST, | |
35 | enum pass_list | |
36 | { | |
37 | GCC_PASS_LISTS | |
38 | PASS_LIST_NUM | |
39 | }; | |
40 | #undef DEF_PASS_LIST | |
41 | ||
42 | namespace gcc { | |
43 | ||
44 | class context; | |
45 | ||
5d068519 | 46 | class pass_manager |
3ea50c01 | 47 | { |
48 | public: | |
04b48e18 | 49 | void *operator new (size_t sz); |
33c6d8ad | 50 | void operator delete (void *ptr); |
04b48e18 | 51 | |
9af5ce0c | 52 | pass_manager (context *ctxt); |
33c6d8ad | 53 | ~pass_manager (); |
3ea50c01 | 54 | |
55 | void register_pass (struct register_pass_info *pass_info); | |
b23e5d49 | 56 | void register_one_dump_file (opt_pass *pass); |
3ea50c01 | 57 | |
58 | opt_pass *get_pass_for_id (int id) const; | |
59 | ||
60 | void dump_passes () const; | |
61 | ||
62 | void dump_profile_report () const; | |
63 | ||
bcfddb5b | 64 | void finish_optimization_passes (); |
65 | ||
66 | /* Access to specific passes, so that the majority can be private. */ | |
67 | void execute_early_local_passes (); | |
68 | unsigned int execute_pass_mode_switching (); | |
69 | ||
a6ae2cf4 | 70 | /* Various passes are manually cloned by epiphany. */ |
71 | opt_pass *get_pass_split_all_insns () const { | |
72 | return pass_split_all_insns_1; | |
73 | } | |
74 | opt_pass *get_pass_mode_switching () const { | |
75 | return pass_mode_switching_1; | |
76 | } | |
77 | opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; } | |
202c2bd9 | 78 | opt_pass *get_pass_profile () const { return pass_profile_1; } |
a6ae2cf4 | 79 | |
3ea50c01 | 80 | public: |
81 | /* The root of the compilation pass tree, once constructed. */ | |
82 | opt_pass *all_passes; | |
83 | opt_pass *all_small_ipa_passes; | |
84 | opt_pass *all_lowering_passes; | |
85 | opt_pass *all_regular_ipa_passes; | |
3ea50c01 | 86 | opt_pass *all_late_ipa_passes; |
87 | ||
88 | /* A map from static pass id to optimization pass. */ | |
89 | opt_pass **passes_by_id; | |
90 | int passes_by_id_size; | |
91 | ||
92 | opt_pass **pass_lists[PASS_LIST_NUM]; | |
93 | ||
94 | private: | |
95 | void set_pass_for_id (int id, opt_pass *pass); | |
3a8e4375 | 96 | void register_dump_files (opt_pass *pass); |
3ea50c01 | 97 | |
98 | private: | |
ae84f584 | 99 | context *m_ctxt; |
3ea50c01 | 100 | |
bcfddb5b | 101 | /* References to all of the individual passes. |
102 | These fields are generated via macro expansion. | |
103 | ||
104 | For example: | |
105 | NEXT_PASS (pass_build_cfg, 1); | |
106 | within pass-instances.def means that there is a field: | |
107 | opt_pass *pass_build_cfg_1; | |
108 | ||
109 | Similarly, the various: | |
110 | NEXT_PASS (pass_copy_prop, 1); | |
111 | ... | |
112 | NEXT_PASS (pass_copy_prop, 8); | |
113 | in pass-instances.def lead to fields: | |
114 | opt_pass *pass_copy_prop_1; | |
115 | ... | |
116 | opt_pass *pass_copy_prop_8; */ | |
117 | ||
118 | #define INSERT_PASSES_AFTER(PASS) | |
119 | #define PUSH_INSERT_PASSES_WITHIN(PASS) | |
120 | #define POP_INSERT_PASSES() | |
121 | #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM | |
122 | #define TERMINATE_PASS_LIST() | |
123 | ||
124 | #include "pass-instances.def" | |
125 | ||
126 | #undef INSERT_PASSES_AFTER | |
127 | #undef PUSH_INSERT_PASSES_WITHIN | |
128 | #undef POP_INSERT_PASSES | |
129 | #undef NEXT_PASS | |
130 | #undef TERMINATE_PASS_LIST | |
131 | ||
3ea50c01 | 132 | }; // class pass_manager |
133 | ||
134 | } // namespace gcc | |
135 | ||
136 | #endif /* ! GCC_PASS_MANAGER_H */ | |
5d068519 | 137 |