20 if (
auto [_, ins] = analyzed_.emplace(def); !ins)
return;
22 if (
auto var = def->isa<
Var>())
return analyze(var->type());
24 for (
auto d : def->
deps()) {
25 if (
auto lam = d->isa_mut<
Lam>())
visit(lam);
30void BetaRedPhase::visit(
Lam* lam) {
31 if (lam->is_external())
return;
32 if (
auto [i, ins] = candidates_.emplace(lam,
true); !ins) i->second =
false;
37 if (
auto var = old_lam->has_var()) {
41 auto res =
rewrite(old_lam->body());
47 return rewrite(old_lam->body());
51 return Rewriter::rewrite_imm_App(app);
54bool BetaRedPhase::is_candidate(
Lam* lam)
const {
57 auto i = candidates_.find(lam);
58 assert(i != candidates_.end());
const Def * callee() const
const Def * rewrite_imm_App(const App *) final
bool is_set() const
Yields true if empty or the last op is set.
Defs deps() const noexcept
T * isa_mut() const
If this is mutable, it will cast constness away and perform a dynamic_cast to T.
bool is_external() const noexcept
FPPhase(World &world, std::string name)
bool todo_
Set to true to indicate that you want to rerun all Phasees in current your fixed-point PhaseMan.
World & world()=delete
Hides both and forbids direct access.
World & old_world()
Get old Defs from here.
const Def * map(const Def *old_def, const Def *new_def)
Map old_def to new_def and returns new_def.
virtual const Def * rewrite(const Def *)
The World represents the whole program and manages creation of MimIR nodes (Defs).
bool visit(IndexSet< Indexer, Key > &set, const Key &key)