MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
copy_prop.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/pass/pass.h"
4
5namespace mim {
6
7class BetaRed;
8class EtaExp;
9
10namespace plug::mem {
11
12/// This FPPass is similar to sparse conditional constant propagation (SCCP).
13/// However, this optmization also works on all Lam%s alike and does not only consider basic blocks as opposed to
14/// traditional SCCP. What is more, this optimization will also propagate arbitrary Def%s and not only constants.
15/// Finally, it will also remove dead Var%s.
16class CopyProp : public FPPass<CopyProp, Lam> {
17public:
18 CopyProp(PassMan& man, bool bb_only = false);
19
21
22private:
23 /// Lattice used for this Pass:
24 /// ```
25 /// Keep <-- We cannot do anything here.
26 /// |
27 /// Prop <-- Var is live but the same Def everywhere.
28 /// |
29 /// Dead <-- Var is dead.
30 /// ```
31 enum Lattice : u8 { Dead, Prop, Keep };
32 enum : u32 { Varxy, Appxy };
33 using Lattices = Vector<Lattice>;
34
35 /// @name PassMan hooks
36 ///@{
37 const Def* rewrite(const Def*) override;
38 undo_t analyze(const Proxy*) override;
39 ///@}
40
41 BetaRed* beta_red_;
42 EtaExp* eta_exp_;
44 const bool bb_only_;
45};
46
47} // namespace plug::mem
48} // namespace mim
Optimistically performs β-reduction (aka inlining).
Definition beta_red.h:9
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(PassMan &man, std::string name)
Definition pass.h:268
PassMan & man()
Definition pass.h:34
friend class PassMan
Definition pass.h:105
This is a thin wrapper for absl::InlinedVector<T, N, A> which is a drop-in replacement for std::vecto...
Definition vector.h:18
const Def * rewrite(const Def *) override
Definition copy_prop.cpp:16
undo_t analyze(const Proxy *) override
Definition copy_prop.cpp:99
CopyProp(PassMan &man, bool bb_only=false)
Definition copy_prop.cpp:10
LamMap< DefVec > Data
Definition copy_prop.h:20
The mem Plugin
Definition mem.h:11
Definition ast.h:14
GIDMap< Lam *, To > LamMap
Definition lam.h:216
size_t undo_t
Definition pass.h:18
uint32_t u32
Definition types.h:34
uint8_t u8
Definition types.h:34