Daily bump.
[official-gcc.git] / gcc / pass_manager.h
blobae97cd411e216eec6f57749c911dbbf44b698778
1 /* pass_manager.h - The pipeline of optimization passes
2 Copyright (C) 2013-2017 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #ifndef GCC_PASS_MANAGER_H
21 #define GCC_PASS_MANAGER_H
23 class opt_pass;
24 struct register_pass_info;
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_late_ipa_passes) \
33 DEF_PASS_LIST (all_passes)
35 #define DEF_PASS_LIST(LIST) PASS_LIST_NO_##LIST,
36 enum pass_list
38 GCC_PASS_LISTS
39 PASS_LIST_NUM
41 #undef DEF_PASS_LIST
43 namespace gcc {
45 class context;
47 class pass_manager
49 public:
50 void *operator new (size_t sz);
51 void operator delete (void *ptr);
53 pass_manager (context *ctxt);
54 ~pass_manager ();
56 void register_pass (struct register_pass_info *pass_info);
57 void register_one_dump_file (opt_pass *pass);
59 opt_pass *get_pass_for_id (int id) const;
61 void dump_passes () const;
63 void dump_profile_report () const;
65 void finish_optimization_passes ();
67 /* Access to specific passes, so that the majority can be private. */
68 void execute_early_local_passes ();
69 unsigned int execute_pass_mode_switching ();
71 /* Various passes are manually cloned by epiphany. */
72 opt_pass *get_pass_split_all_insns () const {
73 return pass_split_all_insns_1;
75 opt_pass *get_pass_mode_switching () const {
76 return pass_mode_switching_1;
78 opt_pass *get_pass_peephole2 () const { return pass_peephole2_1; }
79 opt_pass *get_pass_profile () const { return pass_profile_1; }
81 void register_pass_name (opt_pass *pass, const char *name);
83 opt_pass *get_pass_by_name (const char *name);
85 opt_pass *get_rest_of_compilation () const
87 return pass_rest_of_compilation_1;
89 opt_pass *get_clean_slate () const { return pass_clean_state_1; }
91 public:
92 /* The root of the compilation pass tree, once constructed. */
93 opt_pass *all_passes;
94 opt_pass *all_small_ipa_passes;
95 opt_pass *all_lowering_passes;
96 opt_pass *all_regular_ipa_passes;
97 opt_pass *all_late_ipa_passes;
99 /* A map from static pass id to optimization pass. */
100 opt_pass **passes_by_id;
101 int passes_by_id_size;
103 opt_pass **pass_lists[PASS_LIST_NUM];
105 private:
106 void set_pass_for_id (int id, opt_pass *pass);
107 void register_dump_files (opt_pass *pass);
108 void create_pass_tab () const;
110 private:
111 context *m_ctxt;
112 hash_map<nofree_string_hash, opt_pass *> *m_name_to_pass_map;
114 /* References to all of the individual passes.
115 These fields are generated via macro expansion.
117 For example:
118 NEXT_PASS (pass_build_cfg, 1);
119 within pass-instances.def means that there is a field:
120 opt_pass *pass_build_cfg_1;
122 Similarly, the various:
123 NEXT_PASS (pass_copy_prop, 1);
125 NEXT_PASS (pass_copy_prop, 8);
126 in pass-instances.def lead to fields:
127 opt_pass *pass_copy_prop_1;
129 opt_pass *pass_copy_prop_8; */
131 #define INSERT_PASSES_AFTER(PASS)
132 #define PUSH_INSERT_PASSES_WITHIN(PASS)
133 #define POP_INSERT_PASSES()
134 #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
135 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
136 #define TERMINATE_PASS_LIST(PASS)
138 #include "pass-instances.def"
140 #undef INSERT_PASSES_AFTER
141 #undef PUSH_INSERT_PASSES_WITHIN
142 #undef POP_INSERT_PASSES
143 #undef NEXT_PASS
144 #undef NEXT_PASS_WITH_ARG
145 #undef TERMINATE_PASS_LIST
147 }; // class pass_manager
149 } // namespace gcc
151 #endif /* ! GCC_PASS_MANAGER_H */