MimIR
0.5-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 or are trivial forwarders.
8
class
BetaRed
:
public
RWPhase
{
9
public
:
10
using
RWPhase::RWPhase
;
11
12
private
:
13
bool
analyze
()
final
;
14
void
analyze
(
const
Def
*);
15
void
visit(
const
Def
*,
bool
candidate);
// lattice: true -> false
16
17
const
Def
*
rewrite_imm_App
(
const
App
*)
final
;
18
const
Def
* reduce(
Lam
*,
const
Def
* old_arg);
19
bool
is_once(
Lam
* lam)
const
{
return
fe::assert_lookup(once_, lam); }
20
bool
is_candidate(
Lam
* lam)
const
{
return
!cyclic_.contains(lam) && (is_once(lam) || trivial_.contains(lam)); }
21
22
DefSet
analyzed_;
23
DefSet
on_stack_;
24
LamMap<bool>
once_;
25
LamSet
trivial_;
26
LamSet
cyclic_;
27
};
28
29
}
// namespace mim
mim::App
Definition
lam.h:215
mim::BetaRed
Inlines in post-order all Lams that occur exactly once in the program or are trivial forwarders.
Definition
beta_red.h:8
mim::BetaRed::rewrite_imm_App
const Def * rewrite_imm_App(const App *) final
Definition
beta_red.cpp:67
mim::BetaRed::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::BetaRed::analyze
bool analyze() final
Runs the optional pre-analysis on old_world(), typically to a fixed point, before rewriting begins.
Definition
beta_red.cpp:19
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
Definition
ast.h:16
mim::LamSet
GIDSet< Lam * > LamSet
Definition
lam.h:211
mim::LamMap
GIDMap< Lam *, To > LamMap
Definition
lam.h:210
mim::DefSet
GIDSet< const Def * > DefSet
Definition
def.h:94
phase.h
include
mim
phase
beta_red.h
Generated by
1.18.0