MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
ret_wrap.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
mim/phase.h
"
4
5
namespace
mim
{
6
7
class
RetWrap
:
public
RWPhase
{
8
public
:
9
using
RWPhase::RWPhase
;
10
11
private
:
12
enum
Lattice :
u8
{ Bot, Single, Eta };
13
14
static
Lattice join(Lattice l1, Lattice l2) {
15
if
(l1 == Bot)
return
l2;
16
if
(l2 == Bot)
return
l1;
17
return
Eta;
18
}
19
20
void
join(
const
Def
* def, Lattice l) {
21
if
(
auto
[i, ins] = def2lattice_.emplace(def, l); !ins) i->second = join(i->second, l);
22
}
23
24
Lattice lattice(
const
Def
* def) {
25
if
(
auto
l = fe::lookup(def2lattice_, def))
return
*l;
26
return
Bot;
27
}
28
29
bool
analyze
()
final
;
30
void
analyze
(
const
Def
*);
31
void
visit(
const
Def
*, Lattice = Eta);
32
33
const
Def
*
rewrite
(
const
Def
*)
final
;
34
const
Def
*
rewrite_mut_Lam
(
Lam
*)
final
;
35
const
Def
* rewrite_no_eta(
const
Def
* old_def) {
return
RWPhase::rewrite
(old_def); }
36
37
DefSet
analyzed_;
38
DefMap<Lattice>
def2lattice_;
39
DefMap<const Def*>
def2eta_;
40
VarMap<const Def*>
var2def_;
// vars that contain a ret_var
41
LamSet
split_;
42
};
43
44
}
// namespace mim
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::RetWrap
Definition
ret_wrap.h:7
mim::RetWrap::rewrite_mut_Lam
const Def * rewrite_mut_Lam(Lam *) final
Definition
ret_wrap.cpp:60
mim::RetWrap::analyze
bool analyze() final
Runs the optional pre-analysis on old_world(), typically to a fixed point, before rewriting begins.
Definition
ret_wrap.cpp:5
mim::RetWrap::rewrite
const Def * rewrite(const Def *) final
Definition
ret_wrap.cpp:50
mim::RetWrap::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::Rewriter::rewrite
virtual const Def * rewrite(const Def *)
Definition
rewrite.cpp:62
mim
Definition
ast.h:16
mim::LamSet
GIDSet< Lam * > LamSet
Definition
lam.h:211
mim::VarMap
GIDMap< const Var *, To > VarMap
Definition
def.h:114
mim::DefMap
GIDMap< const Def *, To > DefMap
Definition
def.h:93
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:94
mim::u8
uint8_t u8
Definition
types.h:27
phase.h
include
mim
phase
ret_wrap.h
Generated by
1.18.0