GCC Middle and Back End API Reference
pass_manager.h
Go to the documentation of this file.
1/* pass_manager.h - The pipeline of optimization passes
2 Copyright (C) 2013-2025 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along 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
23class opt_pass;
25
26/* Define a list of pass lists so that both passes.cc 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)
34
35#define DEF_PASS_LIST(LIST) PASS_LIST_NO_##LIST,
41#undef DEF_PASS_LIST
42
43namespace gcc {
44
45class context;
46
48{
49public:
50 pass_manager (context *ctxt);
52
53 void register_pass (struct register_pass_info *pass_info);
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
63
64 /* Access to specific passes, so that the majority can be private. */
66 unsigned int execute_pass_mode_switching ();
67
68 /* Various passes are manually cloned by avr and epiphany. */
70 return m_pass_split_all_insns_1;
71 }
73 return m_pass_mode_switching_1;
74 }
75 opt_pass *get_pass_peephole2 () const { return m_pass_peephole2_1; }
76 opt_pass *get_pass_profile () const { return m_pass_profile_1; }
77 opt_pass *get_pass_auto_profile () const { return m_pass_ipa_auto_profile_1; }
78
79 void register_pass_name (opt_pass *pass, const char *name);
80
81 opt_pass *get_pass_by_name (const char *name);
82
84 {
85 return m_pass_rest_of_compilation_1;
86 }
87 opt_pass *get_clean_slate () const { return m_pass_clean_state_1; }
88
89public:
90 /* The root of the compilation pass tree, once constructed. */
96
97 /* A map from static pass id to optimization pass. */
100
102
103private:
104 void set_pass_for_id (int id, opt_pass *pass);
105 void register_dump_files (opt_pass *pass);
106 void create_pass_tab () const;
107
108private:
111
112 /* References to all of the individual passes.
113 These fields are generated via macro expansion.
114
115 For example:
116 NEXT_PASS (pass_build_cfg, 1);
117 within pass-instances.def means that there is a field:
118 opt_pass *m_pass_build_cfg_1;
119
120 Similarly, the various:
121 NEXT_PASS (pass_copy_prop, 1);
122 ...
123 NEXT_PASS (pass_copy_prop, 8);
124 in pass-instances.def lead to fields:
125 opt_pass *m_pass_copy_prop_1;
126 ...
127 opt_pass *m_pass_copy_prop_8; */
128
129#define INSERT_PASSES_AFTER(PASS)
130#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM)
131#define POP_INSERT_PASSES()
132#define NEXT_PASS(PASS, NUM) opt_pass *m_ ## PASS ## _ ## NUM
133#define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
134#define NEXT_PASS_WITH_ARGS(PASS, NUM, ...) NEXT_PASS (PASS, NUM)
135#define TERMINATE_PASS_LIST(PASS)
136
137#include "pass-instances.def"
138
139}; // class pass_manager
140
141} // namespace gcc
142
143#endif /* ! GCC_PASS_MANAGER_H */
Definition context.h:32
void register_one_dump_file(opt_pass *pass)
Definition passes.cc:837
void dump_profile_report() const
Definition passes.cc:1944
opt_pass * get_pass_auto_profile() const
Definition pass_manager.h:77
opt_pass ** pass_lists[PASS_LIST_NUM]
Definition pass_manager.h:101
pass_manager(context *ctxt)
Definition passes.cc:1581
opt_pass * get_clean_slate() const
Definition pass_manager.h:87
hash_map< free_string_hash, opt_pass * > * m_name_to_pass_map
Definition pass_manager.h:110
unsigned int execute_pass_mode_switching()
Definition passes.cc:127
opt_pass * get_pass_peephole2() const
Definition pass_manager.h:75
void create_pass_tab() const
Definition passes.cc:952
void dump_passes() const
Definition passes.cc:1012
void set_pass_for_id(int id, opt_pass *pass)
Definition passes.cc:803
void finish_optimization_passes()
Definition passes.cc:350
void register_pass_name(opt_pass *pass, const char *name)
Definition passes.cc:918
opt_pass * all_regular_ipa_passes
Definition pass_manager.h:94
opt_pass * get_pass_split_all_insns() const
Definition pass_manager.h:69
opt_pass * get_pass_for_id(int id) const
Definition passes.cc:819
opt_pass * all_small_ipa_passes
Definition pass_manager.h:92
~pass_manager()
Definition passes.cc:1682
opt_pass * get_pass_profile() const
Definition pass_manager.h:76
opt_pass * all_lowering_passes
Definition pass_manager.h:93
context * m_ctxt
Definition pass_manager.h:109
opt_pass ** passes_by_id
Definition pass_manager.h:98
void register_dump_files(opt_pass *pass)
Definition passes.cc:900
opt_pass * get_pass_by_name(const char *name)
Definition passes.cc:1032
void execute_early_local_passes()
Definition passes.cc:120
opt_pass * get_rest_of_compilation() const
Definition pass_manager.h:83
opt_pass * all_late_ipa_passes
Definition pass_manager.h:95
opt_pass * all_passes
Definition pass_manager.h:91
void register_pass(struct register_pass_info *pass_info)
Definition passes.cc:1503
opt_pass * get_pass_mode_switching() const
Definition pass_manager.h:72
int passes_by_id_size
Definition pass_manager.h:99
Definition hash-map.h:40
Definition tree-pass.h:74
Definition context.h:23
#define GCC_PASS_LISTS
Definition pass_manager.h:28
pass_list
Definition pass_manager.h:37
@ PASS_LIST_NUM
Definition pass_manager.h:39
Definition tree-pass.h:331