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
5void EtaRedPhase::rewrite_external(Def* mut) { mut->transfer_external(rewrite_no_eta(mut)->as_mut()); }
6
7const Def* EtaRedPhase::rewrite(const Def* old_def) {
8 if (auto lam = old_def->isa<Lam>()) {
9 if (auto callee = lam->eta_reduce()) return todo_ = true, rewrite(callee);
10 }
11
12 return Rewriter::rewrite(old_def);
13}
14
16 return new_world().var(rewrite(var->type()), rewrite_no_eta(var->mut())->as_mut());
17}
18
19} // namespace mim
Base class for all Defs.
Definition def.h:251
void transfer_external(Def *to)
Definition def.cpp:566
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
Definition def.h:295
const Def * rewrite_imm_Var(const Var *) final
void rewrite_external(Def *) final
A function.
Definition lam.h:109
bool todo_
Set to true to indicate that you want to rerun all Phasees in current your fixed-point PhaseMan.
Definition phase.h:55
World & new_world()
Create new Defs into this.
Definition phase.h:99
virtual const Def * rewrite(const Def *)
Definition rewrite.cpp:14
Def * mut() const
Definition def.h:698
const Def * var(const Def *type, Def *mut)
Definition world.cpp:177
Definition ast.h:14