MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
beta_red.h
Go to the documentation of this file.
1#pragma once
2
3#include "mim/pass/pass.h"
4
5namespace mim {
6
7/// Optimistically performs β-reduction (aka inlining).
8/// β-reduction of `f e` happens if `f` only occurs exactly once in the program in callee position.
9class BetaRed : public FPPass<BetaRed, Def> {
10public:
12 : FPPass(man, "beta_red") {}
13
14 using Data = LamSet;
15
16 void keep(Lam* lam) { keep_.emplace(lam); }
17
18private:
19 Ref rewrite(Ref) override;
20 undo_t analyze(const Proxy*) override;
21 undo_t analyze(Ref) override;
22
23 LamSet keep_;
24};
25
26} // namespace mim
Optimistically performs β-reduction (aka inlining).
Definition beta_red.h:9
void keep(Lam *lam)
Definition beta_red.h:16
LamSet Data
Definition beta_red.h:14
BetaRed(PassMan &man)
Definition beta_red.h:11
undo_t analyze(const Proxy *) override
Definition beta_red.cpp:20
Ref rewrite(Ref) override
Definition beta_red.cpp:7
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:103
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:86
Definition cfg.h:11
GIDSet< Lam * > LamSet
Definition lam.h:200
size_t undo_t
Definition pass.h:14