Definition at line 196 of file PassManager.h.
◆ AddPass()
template<typename T , typename... Args>
requires PassType<T> T& utils::PassManager::AddPass |
( |
Args &&... |
args | ) |
|
|
inline |
Adds a pass to the pass manager.
- Template Parameters
-
- Parameters
-
...args | The remaining arguments to pass to the pass constructor. The pass manager will be passed to the pass as the first argument. |
Definition at line 244 of file PassManager.h.
245 passes_.emplace_back(
new T(*
this, std::forward<Args>(args)...));
246 T& result = *cast<T*>(passes_.back().get());
249 if(!result.Name().empty()) result.RegisterCLI();
Wraps a value for expression evaluation. This distinguishes an LValue from an RValue,...
◆ LastRun()
Pass const* utils::PassManager::LastRun |
( |
| ) |
const |
|
inline |
- Returns
- The last pass that was run by the pass manager
Definition at line 221 of file PassManager.h.
◆ Run()
bool utils::PassManager::Run |
( |
| ) |
|
Runs all the passes in the pass manager.
- Returns
- True if all passes ran successfully
Definition at line 123 of file PassManager.cc.
124 std::vector<Pass*> S;
125 std::vector<Pass*> L;
127 for(
auto& pass : passes_) {
128 pass->state = Pass::PropagateEnabled;
129 pass->computeDependencies();
132 for(
auto& pass : passes_) {
134 if(
PO().IsPassDisabled(pass.get()))
continue;
135 pass->state = Pass::AcquireResources;
139 for(
auto& pass : passes_) {
140 if(
PO().IsPassDisabled(pass.get()))
continue;
141 pass->computeDependencies();
143 if(
Diag().Verbose(2)) {
144 for(
auto& heap : heaps_) {
145 Diag().ReportDebug(2) <<
"[=>] Heap Owner: \"" << heap.owner->Desc()
146 <<
"\" RefCount: " << heap.refCount;
150 size_t NumEnabledPasses = 0;
151 for(
auto& pass : passes_) {
152 if(
PO().IsPassDisabled(pass.get()))
continue;
154 passDeps_[pass.get()] = 0;
155 pass->state = Pass::RegisterDependencies;
156 pass->computeDependencies();
158 if(passDeps_[pass.get()] == 0) S.push_back(pass.get());
162 auto* n = *S.begin();
165 for(
auto* m : depgraph_[n]) {
166 if(--passDeps_[m] == 0) S.push_back(m);
168 depgraph_[n].clear();
171 if(L.size() != NumEnabledPasses)
174 for(
auto& pass : L) {
175 assert(pass->state != Pass::Valid &&
"Pass already run");
176 pass->state = Pass::Running;
177 if(
Diag().Verbose()) {
178 Diag().ReportDebug() <<
"[=>] Running " << pass->Desc() <<
" Pass";
182 if(
Diag().hasErrors()) {
183 pass->state = Pass::Invalid;
185 }
else if(
Diag().hasWarnings()) {
186 pass->state = Pass::Invalid;
191 pass->state = Pass::Cleanup;
192 pass->computeDependencies();
194 pass->state = Pass::Valid;
diagnostics::DiagnosticEngine & Diag()
Gets a reference to the diagnostic engine.
PassOptions & PO()
Gets the pass options.
The documentation for this class was generated from the following files: