Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
beta_red.h
Go to the documentation of this file.
1#pragma once
2
3#include "thorin/pass/pass.h"
4
5namespace thorin {
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 thorin
Optimistically performs β-reduction (aka inlining).
Definition beta_red.h:9
void keep(Lam *lam)
Definition beta_red.h:16
Ref rewrite(Ref) override
Definition beta_red.cpp:7
undo_t analyze(const Proxy *) override
Definition beta_red.cpp:20
BetaRed(PassMan &man)
Definition beta_red.h:11
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:87
Definition cfg.h:11
size_t undo_t
Definition pass.h:14
GIDSet< Lam * > LamSet
Definition lam.h:190