]>
Commit | Line | Data |
---|---|---|
315f8c0e DM |
1 | /* pass_manager.h - The pipeline of optimization passes |
2 | Copyright (C) 2013 Free Software Foundation, Inc. | |
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) \ | |
32 | DEF_PASS_LIST (all_lto_gen_passes) \ | |
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 | ||
e42c64cb | 47 | class GTY((user)) pass_manager |
315f8c0e DM |
48 | { |
49 | public: | |
e42c64cb | 50 | /* Ensure that instances are allocated in the GC-managed heap. */ |
6a389ed5 DM |
51 | void *operator new (size_t sz); |
52 | ||
315f8c0e DM |
53 | pass_manager(context *ctxt); |
54 | ||
e42c64cb DM |
55 | /* GTY((user)) methods. */ |
56 | void gt_ggc_mx (); | |
57 | void gt_pch_nx (); | |
58 | void gt_pch_nx_with_op (gt_pointer_operator op, void *cookie); | |
59 | ||
315f8c0e DM |
60 | void register_pass (struct register_pass_info *pass_info); |
61 | void register_one_dump_file (struct opt_pass *pass); | |
62 | ||
63 | opt_pass *get_pass_for_id (int id) const; | |
64 | ||
65 | void dump_passes () const; | |
66 | ||
67 | void dump_profile_report () const; | |
68 | ||
f7695dbf DM |
69 | void finish_optimization_passes (); |
70 | ||
71 | /* Access to specific passes, so that the majority can be private. */ | |
72 | void execute_early_local_passes (); | |
73 | unsigned int execute_pass_mode_switching (); | |
74 | ||
05555c4a DM |
75 | /* Various passes are manually cloned by epiphany. */ |
76 | opt_pass *get_pass_split_all_insns () const { | |
77 | return pass_split_all_insns_1; | |
78 | } | |
79 | opt_pass *get_pass_mode_switching () const { | |
80 | return pass_mode_switching_1; | |
81 | } | |
82 | opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; } | |
83 | ||
315f8c0e DM |
84 | public: |
85 | /* The root of the compilation pass tree, once constructed. */ | |
86 | opt_pass *all_passes; | |
87 | opt_pass *all_small_ipa_passes; | |
88 | opt_pass *all_lowering_passes; | |
89 | opt_pass *all_regular_ipa_passes; | |
90 | opt_pass *all_lto_gen_passes; | |
91 | opt_pass *all_late_ipa_passes; | |
92 | ||
93 | /* A map from static pass id to optimization pass. */ | |
94 | opt_pass **passes_by_id; | |
95 | int passes_by_id_size; | |
96 | ||
97 | opt_pass **pass_lists[PASS_LIST_NUM]; | |
98 | ||
99 | private: | |
100 | void set_pass_for_id (int id, opt_pass *pass); | |
101 | int register_dump_files_1 (struct opt_pass *pass, int properties); | |
102 | void register_dump_files (struct opt_pass *pass, int properties); | |
103 | ||
104 | private: | |
105 | context *ctxt_; | |
106 | ||
f7695dbf DM |
107 | /* References to all of the individual passes. |
108 | These fields are generated via macro expansion. | |
109 | ||
110 | For example: | |
111 | NEXT_PASS (pass_build_cfg, 1); | |
112 | within pass-instances.def means that there is a field: | |
113 | opt_pass *pass_build_cfg_1; | |
114 | ||
115 | Similarly, the various: | |
116 | NEXT_PASS (pass_copy_prop, 1); | |
117 | ... | |
118 | NEXT_PASS (pass_copy_prop, 8); | |
119 | in pass-instances.def lead to fields: | |
120 | opt_pass *pass_copy_prop_1; | |
121 | ... | |
122 | opt_pass *pass_copy_prop_8; */ | |
123 | ||
124 | #define INSERT_PASSES_AFTER(PASS) | |
125 | #define PUSH_INSERT_PASSES_WITHIN(PASS) | |
126 | #define POP_INSERT_PASSES() | |
127 | #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM | |
128 | #define TERMINATE_PASS_LIST() | |
129 | ||
130 | #include "pass-instances.def" | |
131 | ||
132 | #undef INSERT_PASSES_AFTER | |
133 | #undef PUSH_INSERT_PASSES_WITHIN | |
134 | #undef POP_INSERT_PASSES | |
135 | #undef NEXT_PASS | |
136 | #undef TERMINATE_PASS_LIST | |
137 | ||
315f8c0e DM |
138 | }; // class pass_manager |
139 | ||
140 | } // namespace gcc | |
141 | ||
142 | #endif /* ! GCC_PASS_MANAGER_H */ |