39 bool early_exit_flag =
false;
40 mutable int never_backtracks_cache = -1;
46 bool stop_on_error =
true;
49 void runDebugHooks(
const char *visitorName,
const IR::Node *node);
52 return Visitor::init_apply(root);
67 BUG_CHECK(visitor->check_clone(&v),
"Incorrect clone in PassManager");
74 typename std::enable_if<
75 std::is_convertible<
decltype(t(
nullptr)),
const IR::Node *>::value,
int>::type = 0)
80 typename std::enable_if<std::is_same<
decltype(t(
nullptr)),
void>::value,
int>::type = 0)
88 typename std::enable_if<std::is_same<
decltype(t()),
void>::value,
int>::type = 0)
95 PassManager(
const std::initializer_list<VisitorRef> &init) { addPasses(init); }
96 void addPasses(
const std::initializer_list<VisitorRef> &init) {
97 never_backtracks_cache = -1;
99 if (p.visitor) passes.emplace_back(p.visitor);
101 void removePasses(
const std::vector<cstring> &exclude);
102 void listPasses(std::ostream &,
cstring sep)
const;
104 bool backtrack(trigger &trig)
override;
105 bool never_backtracks()
override;
106 void setStopOnError(
bool stop) { stop_on_error = stop; }
107 void addDebugHook(DebugHook h,
bool recursive =
false) {
108 debugHooks.push_back(h);
110 for (
auto pass : passes)
111 if (auto child = dynamic_cast<
PassManager *>(pass))
112 child->addDebugHook(h, recursive);
114 void addDebugHooks(std::vector<DebugHook> hooks,
bool recursive =
false) {
115 debugHooks.insert(debugHooks.end(), hooks.begin(), hooks.end());
117 for (
auto pass : passes)
118 if (auto child = dynamic_cast<
PassManager *>(pass))
119 child->addDebugHooks(hooks, recursive);
121 void early_exit() { early_exit_flag =
true; }