MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
eta_exp_phase.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
mim/phase/phase.h
"
4
#include "
mim/util/util.h
"
5
6
namespace
mim
{
7
8
/// Inlines in post-order all Lam%s that occur exactly *once* in the program.
9
class
EtaExpPhase
:
public
FPPhase
{
10
public
:
11
EtaExpPhase
(
World
&);
12
13
private
:
14
enum
Lattice :
u8
{
15
None = 0,
16
Known = 1 << 0,
17
Unknown = 1 << 1,
18
Both = Known | Unknown,
19
};
20
21
static
void
join(Lattice& l1, Lattice l2) { l1 = (Lattice)((
u8
)l1 | (
u8
)l2); }
22
23
void
join(
const
Lam
* lam, Lattice l) {
24
if
(
auto
[i, ins] = lam2lattice_.emplace(lam, l); !ins) join(i->second, l);
25
}
26
27
Lattice lattice(
const
Lam
* lam) {
28
if
(
auto
i = lam2lattice_.find(lam); i != lam2lattice_.end())
return
i->second;
29
return
None;
30
}
31
32
void
reset
()
final
;
33
34
bool
analyze
()
final
;
35
void
analyze
(
const
Def
*);
36
37
void
rewrite_external
(
Def
*)
final
;
38
const
Def
* rewrite_no_eta(
const
Def
*);
39
const
Def
* rewrite(
const
Def
*);
40
const
Def
*
rewrite_imm_App
(
const
App
*)
final
;
41
const
Def
*
rewrite_imm_Var
(
const
Var
*)
final
;
42
43
DefSet
analyzed_;
44
GIDMap<const Lam*, Lattice>
lam2lattice_;
45
GIDMap<const Lam*, const Def*>
lam2eta_;
46
};
47
48
}
// namespace mim
mim::App
Definition
lam.h:221
mim::Def
Base class for all Defs.
Definition
def.h:251
mim::EtaExpPhase::rewrite_imm_Var
const Def * rewrite_imm_Var(const Var *) final
Definition
eta_exp_phase.cpp:67
mim::EtaExpPhase::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
eta_exp_phase.cpp:62
mim::EtaExpPhase::EtaExpPhase
EtaExpPhase(World &)
Definition
eta_exp_phase.cpp:7
mim::EtaExpPhase::reset
void reset() final
Definition
eta_exp_phase.cpp:10
mim::EtaExpPhase::rewrite_external
void rewrite_external(Def *) final
Definition
eta_exp_phase.cpp:48
mim::EtaExpPhase::analyze
bool analyze() final
Definition
eta_exp_phase.cpp:15
mim::FPPhase::FPPhase
FPPhase(World &world, std::string name)
Definition
phase.h:121
mim::Lam
A function.
Definition
lam.h:109
mim::Var
Definition
def.h:688
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:36
mim
Definition
ast.h:14
mim::GIDMap
absl::flat_hash_map< K, V, GIDHash< K > > GIDMap
Definition
util.h:187
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:74
mim::u8
uint8_t u8
Definition
types.h:34
phase.h
util.h
include
mim
phase
eta_exp_phase.h
Generated by
1.13.2