MimIR
0.5-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 the `clos.anno` annotations (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
using
RWPhase::RWPhase
;
14
15
private
:
16
/// Fills lam2fscope_: assigns each basicblock Lam to its enclosing returning Lam.
17
bool
analyze
()
final
;
18
const
Def
*
rewrite_imm_App
(
const
App
*)
final
;
19
20
const
Def
* rewrite_arg(
const
App
* app,
const
Def
* old_op,
size_t
i,
size_t
n);
21
const
Def
* rewrite_callee_op(
const
Def
* old_op);
22
23
Lam
* scope(
Lam
* lam) {
return
lam2fscope_[lam]; }
24
25
bool
from_outer_scope(
Lam
* lam) {
26
auto
mut =
curr_mut
() ?
curr_mut
()->isa_mut<
Lam
>() :
nullptr
;
27
return
mut && scope(lam) && scope(lam) != scope(mut);
28
}
29
30
const
Def
* eta_wrap(
const
Def
* old_op,
anno
a);
31
32
DefMap<Lam*>
old2wrapper_;
33
Lam2Lam
lam2fscope_;
34
bool
analyzed_ =
false
;
35
};
36
37
}
// namespace mim::plug::clos::phase
mim::App
Definition
lam.h:215
mim::Def
Base class for all Defs.
Definition
def.h:289
mim::Lam
A function.
Definition
lam.h:91
mim::RWPhase::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::Rewriter::curr_mut
D * curr_mut() const
Definition
rewrite.h:98
mim::plug::clos::phase::ClosConvPrep
Wraps operands with the clos.anno annotations (returning, free_bb, fstclass_bb, .....
Definition
clos_conv_prep.h:11
mim::plug::clos::phase::ClosConvPrep::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::plug::clos::phase::ClosConvPrep::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
clos_conv_prep.cpp:108
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:18
clos.h
mim::plug::clos::phase
Definition
branch_clos_elim.h:5
mim::plug::clos::anno
anno
Definition
autogen.h:42
mim::DefMap
GIDMap< const Def *, To > DefMap
Definition
def.h:93
mim::Lam2Lam
LamMap< Lam * > Lam2Lam
Definition
lam.h:212
phase.h
include
mim
plug
clos
phase
clos_conv_prep.h
Generated by
1.18.0