Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
ssa_constr.h
Go to the documentation of this file.
1#pragma once
2
3#include <thorin/pass/pass.h>
4
5namespace thorin {
6
7class EtaExp;
8
9namespace plug::mem {
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 SSAConstr : public FPPass<SSAConstr, Lam> {
16public:
18 : FPPass(man, "ssa_constr")
19 , eta_exp_(eta_exp) {}
20
21 enum : u32 { Phixy, Sloxy, Traxy };
22
23 struct Info {
24 Lam* pred = nullptr;
26 };
27
29
30private:
31 /// @name PassMan hooks
32 ///@{
33 void enter() override;
34 Ref rewrite(const Proxy*) override;
35 Ref rewrite(Ref) override;
36 undo_t analyze(const Proxy*) override;
37 undo_t analyze(Ref) override;
38 ///@}
39
40 /// @name SSA construction helpers - see paper
41 ///@{
42 Ref get_val(Lam*, const Proxy*);
43 Ref set_val(Lam*, const Proxy*, Ref);
44 Ref mem2phi(const App*, Lam*);
45 ///@}
46
47 EtaExp* eta_exp_;
49
50 /// Value numbering table.
52
53 /// Contains the @p Sloxy%s that we need to install as phi in a @c mem_lam to build the @c phi_lam.
55
56 /// Contains @p Sloxy%s we have to keep.
58};
59
60} // namespace plug::mem
61} // namespace thorin
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
Inherit from this class using CRTP, if you do need a Pass with a state and a fixed-point.
Definition pass.h:242
A function.
Definition lam.h:97
An optimizer that combines several optimizations in an optimal way.
Definition pass.h:107
PassMan & man()
Definition pass.h:30
Helper class to retrieve Infer::arg if present.
Definition def.h:85
SSA construction algorithm that promotes slots, loads, and stores to SSA values.
Definition ssa_constr.h:15
Ref rewrite(const Proxy *) override
void enter() override
Invoked just before Pass::rewriteing PassMan::curr_mut's body.
GIDSet< const Proxy * > writable
Definition ssa_constr.h:25
GIDNodeMap< Lam *, Info > Data
Definition ssa_constr.h:28
undo_t analyze(const Proxy *) override
SSAConstr(PassMan &man, EtaExp *eta_exp)
Definition ssa_constr.h:17
Definition cfg.h:11
uint32_t u32
Definition types.h:35
size_t undo_t
Definition pass.h:14
absl::node_hash_map< K, V, GIDHash< K >, GIDEq< K > > GIDNodeMap
Definition util.h:181
GIDMap< Lam *, To > LamMap
Definition lam.h:189
absl::flat_hash_set< K, GIDHash< K >, GIDEq< K > > GIDSet
Definition util.h:180