MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
eta_red_phase.cpp
Go to the documentation of this file.
2
3namespace mim {
4
6 auto new_mut = rewrite_no_eta(old_mut)->as_mut();
7 if (old_mut->is_external()) new_mut->make_external();
8}
9
10const Def* EtaRedPhase::rewrite(const Def* old_def) {
11 if (auto lam = old_def->isa<Lam>()) {
12 if (auto callee = lam->eta_reduce()) {
13 DLOG("eta-reduce: `{}` -> `{}`", lam, callee);
14 todo_ = true;
15 return rewrite(callee);
16 }
17 }
18
19 return Rewriter::rewrite(old_def);
20}
21
23 return new_world().var(rewrite_no_eta(var->mut())->as_mut());
24}
25
26} // namespace mim
Base class for all Defs.
Definition def.h:251
bool is_external() const noexcept
Definition def.h:467
const Def * rewrite_imm_Var(const Var *) final
void rewrite_external(Def *) final
A function.
Definition lam.h:111
bool todo_
Set to true to indicate that you want to rerun all Phasees in current your fixed-point PhaseMan.
Definition phase.h:57
World & new_world()
Create new Defs into this.
Definition phase.h:100
virtual const Def * rewrite(const Def *)
Definition rewrite.cpp:27
A variable introduced by a binder (mutable).
Definition def.h:700
Def * mut() const
Definition def.h:712
const Def * var(Def *mut)
Definition world.cpp:178
#define DLOG(...)
Vaporizes to nothingness in Debug build.
Definition log.h:95
Definition ast.h:14