MimIR
0.4-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
beta_red.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
mim/phase.h
"
4
5
namespace
mim
{
6
7
/// Inlines in post-order all Lam%s that occur exactly *once* in the program.
8
class
BetaRed
:
public
InplaceRWPhase
{
9
public
:
10
using
Super
=
InplaceRWPhase
;
11
12
BetaRed
(
World
&
world
)
13
:
InplaceRWPhase
(
world
,
"BetaRed"
) {}
14
BetaRed
(
World
&
world
,
flags_t
annex
)
15
:
InplaceRWPhase
(
world
,
annex
) {}
16
17
private
:
18
bool
analyze
() final;
19
void
analyze
(const
Def
*);
20
void
visit(const
Def
*,
bool
candidate);
// lattice: true -> false
21
22
const
Def
* rewrite(const
Def
* def) {
return
def->
is_ground
() ? def :
Super::rewrite
(def); }
23
const
Def*
rewrite_imm_App
(
const
App*)
final
;
24
bool
is_candidate(Lam* lam)
const
{
return
fe::assert_lookup(candidates_, lam); }
25
26
DefSet
analyzed_;
27
LamMap<bool> candidates_;
28
};
29
30
}
// namespace mim
mim::BetaRed::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
beta_red.cpp:25
mim::BetaRed::Super
InplaceRWPhase Super
Definition
beta_red.h:10
mim::BetaRed::BetaRed
BetaRed(World &world)
Definition
beta_red.h:12
mim::BetaRed::analyze
bool analyze() final
Runs the optional pre-analysis on Phase::world, typically to a fixed point, before rewriting begins.
Definition
beta_red.cpp:5
mim::BetaRed::BetaRed
BetaRed(World &world, flags_t annex)
Definition
beta_red.h:14
mim::Def
Base class for all Defs.
Definition
def.h:273
mim::Def::is_ground
bool is_ground() const
Immutable that contains neither mutables nor Vars.
Definition
def.h:525
mim::InplaceRWPhase::InplaceRWPhase
InplaceRWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:489
mim::InplaceRWPhase::world
World & world()
Definition
phase.h:77
mim::Phase::annex
flags_t annex() const
Definition
phase.h:81
mim::Rewriter::rewrite
virtual const Def * rewrite(const Def *)
Definition
rewrite.cpp:55
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:40
mim
Definition
ast.h:16
mim::flags_t
u64 flags_t
Definition
types.h:39
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:89
phase.h
include
mim
phase
beta_red.h
Generated by
1.18.0