MimIR
0.5-dev
MimIR is my Intermediate Representation
Toggle main menu visibility
Loading...
Searching...
No Matches
sccp.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
mim/phase.h
"
4
5
namespace
mim
{
6
7
/// SCCP - Sparse Conditional Constant Propagation - but propagates **arbitrary expressions**.
8
/// @see [Constant propagation with conditional branches](https://dl.acm.org/doi/pdf/10.1145/103135.103136)
9
///
10
/// Lattice per Lam::var:
11
/// ```
12
/// ⊤ ← Keep as is
13
/// |
14
/// Expr ← Whole expression is propagated (vertically) through var
15
/// |
16
/// ⊥
17
/// ```
18
/// @pre EtaConv ran beforehand, so no rewritable Lam escapes as a value.
19
/// Otherwise, the vars of such unknown functions would have to be pinned to ⊤.
20
class
SCCP
:
public
RWPhase
{
21
private
:
22
class
Analysis :
public
mim::Analysis
{
23
public
:
24
Analysis
(
World
&
world
)
25
:
mim::Analysis
(
world
,
"SCCP::Analyzer"
) {}
26
27
private
:
28
const
Def
* propagate(
Lam
* lam,
const
Def
* var,
const
Def
* def);
29
const
Def
*
rewrite_imm_App
(
const
App
* app)
final
;
30
};
31
32
public
:
33
SCCP
(
World
&
world
,
flags_t
annex
)
34
:
RWPhase
(
world
,
annex
, &analysis_)
35
, analysis_(
world
) {}
36
37
private
:
38
const
Def
*
rewrite_imm_App
(
const
App
* old_app)
final
;
39
40
Analysis
analysis_;
41
Lam2Lam
lam2lam_;
42
};
43
44
}
// namespace mim
mim::Analysis
Traverses the current World using Rewriter infrastructure while staying in the same world.
Definition
phase.h:130
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::Phase::Analysis
friend class Analysis
Definition
phase.h:106
mim::Phase::annex
flags_t annex() const
Definition
phase.h:62
mim::RWPhase::RWPhase
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition
phase.h:334
mim::RWPhase::world
World & world()=delete
Hides both and forbids direct access.
mim::SCCP::SCCP
SCCP(World &world, flags_t annex)
Definition
sccp.h:33
mim::SCCP::rewrite_imm_App
const Def * rewrite_imm_App(const App *old_app) final
Definition
sccp_transform.cpp:5
mim::World
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition
world.h:43
mim
Definition
ast.h:16
mim::flags_t
u64 flags_t
Definition
types.h:39
mim::Lam2Lam
LamMap< Lam * > Lam2Lam
Definition
lam.h:212
phase.h
include
mim
phase
sccp.h
Generated by
1.18.0