MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
clos_conv_prep.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
mim/phase.h
>
4
5
#include "
mim/plug/clos/clos.h
"
6
7
namespace
mim::plug::clos::phase
{
8
9
/// Wraps operands with `clos.attr` markers (returning, free_bb, fstclass_bb, ...) and eta-expands
10
/// branches and continuations so that ClosConv sees a canonical program.
11
class
ClosConvPrep
:
public
RWPhase
{
12
public
:
13
ClosConvPrep
(
World
&
world
,
flags_t
annex
)
14
:
RWPhase
(
world
,
annex
) {}
15
16
private
:
17
/// Fills lam2fscope_: assigns each basicblock Lam to its enclosing returning Lam.
18
bool
analyze
() final;
19
const
Def
*
rewrite_imm_App
(const
App
*) final;
20
21
const
Def
* rewrite_arg(const
App
* app, const
Def
* old_op);
22
const
Def
* rewrite_callee_op(const
Def
* old_op);
23
24
Lam
* scope(
Lam
* lam) {
return
lam2fscope_[lam]; }
25
26
bool
from_outer_scope(
Lam
* lam) {
27
auto
mut =
curr_mut
() ?
curr_mut
()->isa_mut<
Lam
>() : nullptr;
28
return
mut && scope(lam) && scope(lam) != scope(mut);
29
}
30
31
const
Def
* eta_wrap(
const
Def
* old_op,
attr
a);
32
33
DefMap<Lam*>
old2wrapper_;
34
Lam2Lam
lam2fscope_;
35
bool
analyzed_ =
false
;
36
};
37
38
}
// namespace mim::plug::clos::phase
mim::App
Definition
lam.h:224
mim::Def
Base class for all Defs.
Definition
def.h:273
mim::Lam
A function.
Definition
lam.h:113
mim::Phase::annex
flags_t annex() const
Definition
phase.h:81
mim::RWPhase::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:431
mim::RWPhase::world
World & world()=delete
Hides both and forbids direct access.
mim::Rewriter::curr_mut
D * curr_mut() const
Definition
rewrite.h:96
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:40
mim::plug::clos::phase::ClosConvPrep::ClosConvPrep
ClosConvPrep(World &world, flags_t annex)
Definition
clos_conv_prep.h:13
mim::plug::clos::phase::ClosConvPrep::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
clos_conv_prep.cpp:130
mim::plug::clos::phase::ClosConvPrep::analyze
bool analyze() final
Fills lam2fscope_: assigns each basicblock Lam to its enclosing returning Lam.
Definition
clos_conv_prep.cpp:33
clos.h
mim::plug::clos::phase
Definition
branch_clos_elim.h:5
mim::plug::clos::attr
attr
Definition
autogen.h:42
mim::flags_t
u64 flags_t
Definition
types.h:39
mim::DefMap
GIDMap< const Def *, To > DefMap
Definition
def.h:88
mim::Lam2Lam
LamMap< Lam * > Lam2Lam
Definition
lam.h:221
phase.h
include
mim
plug
clos
phase
clos_conv_prep.h
Generated by
1.18.0