MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
ssa.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/pass.h>
4
5namespace mim {
6
7class EtaExp;
8
9namespace plug::mem::pass {
10
11/// SSA construction algorithm that promotes slot%s, load%s, and store%s to SSA values.
12/// This is loosely based upon:
13/// "Simple and Efficient Construction of Static Single Assignment Form"
14/// by Braun, Buchwald, Hack, Leißa, Mallon, Zwinkau.
15class SSA : public FPPass<SSA, Lam> {
16public:
19
20 void init(PassMan*) final;
21
22 enum : u32 { Phixy, Sloxy, Traxy };
23
24 struct Info {
25 Lam* pred = nullptr;
27 };
28
30
31private:
32 /// @name PassMan hooks
33 ///@{
34 void enter() override;
35 const Def* rewrite(const Proxy*) override;
36 const Def* rewrite(const Def*) override;
37 undo_t analyze(const Proxy*) override;
38 undo_t analyze(const Def*) override;
39 ///@}
40
41 /// @name SSA construction helpers - see paper
42 ///@{
43 const Def* get_val(Lam*, const Proxy*);
44 const Def* set_val(Lam*, const Proxy*, const Def*);
45 const Def* mem2phi(const App*, Lam*);
46 ///@}
47
48 EtaExp* eta_exp_;
50
51 /// Value numbering table.
53
54 /// Contains the @p Sloxy%s that we need to install as phi in a @c mem_lam to build the @c phi_lam.
56
57 /// Contains @p Sloxy%s we have to keep.
59};
60
61} // namespace plug::mem::pass
62} // namespace mim
Base class for all Defs.
Definition def.h:251
Performs η-expansion: f -> λx.f x, if f is a Lam with more than one user and does not appear in calle...
Definition eta_exp.h:13
FPPass(World &world, std::string name)
Definition pass.h:323
A function.
Definition lam.h:111
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:172
World & world()
Definition pass.h:64
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:36
GIDSet< const Proxy * > writable
Definition ssa.h:26
const Def * rewrite(const Proxy *) override
Definition ssa.cpp:24
GIDNodeMap< Lam *, Info > Data
Definition ssa.h:29
void init(PassMan *) final
Definition ssa.cpp:17
SSA(World &world, flags_t annex)
Definition ssa.h:17
undo_t analyze(const Proxy *) override
Definition ssa.cpp:143
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
Definition ssa.cpp:22
Definition ast.h:14
u64 flags_t
Definition types.h:45
GIDMap< Lam *, To > LamMap
Definition lam.h:220
size_t undo_t
Definition pass.h:21
uint32_t u32
Definition types.h:34
absl::node_hash_map< K, V, GIDHash< K > > GIDNodeMap
Definition util.h:197
absl::flat_hash_set< K, GIDHash< K > > GIDSet
Definition util.h:196