MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
sccp.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/phase.h"
4
5namespace mim {
6
7/// Sparse Conditional Constant Propagation.
8class SCCP : public RWPhase {
9private:
10 class Analysis : public mim::Analysis {
11 public:
12 Analysis(World& world)
13 : mim::Analysis(world, "SCCP::Analyzer") {}
14
15 auto& lattice() { return lattice_; }
16
17 private:
18 const Def* join(const Def*, const Def*);
19 Def* rewrite_mut(Def*) final;
20 const Def* rewrite_imm_App(const App*) final;
21
22 Def2Def lattice_;
23 };
24
25public:
27 : RWPhase(world, annex, &analysis_)
28 , analysis_(world) {}
29
30private:
31 const Def* lattice(const Def* def) { return analysis_.lattice()[def]; }
32 const Def* rewrite_imm_App(const App*) final;
33
34 Analysis analysis_;
35 Lam2Lam lam2lam_;
36};
37
38} // namespace mim
This Phase will recursively Rewriter::rewrite.
Definition phase.h:64
Base class for all Defs.
Definition def.h:251
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:111
World & world()=delete
Hides both and forbids direct access.
virtual const Def * rewrite_mut(Def *)
Definition rewrite.cpp:48
SCCP(World &world, flags_t annex)
Definition sccp.h:26
const Def * rewrite_imm_App(const App *) final
Definition sccp.cpp:66
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:31
Definition ast.h:14
DefMap< const Def * > Def2Def
Definition def.h:75
u64 flags_t
Definition types.h:45
LamMap< Lam * > Lam2Lam
Definition lam.h:221
@ App
Definition def.h:114