MimIR
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/phase.h"
4
5namespace mim {
6
7/// Inlines in post-order all Lam%s that occur exactly *once* in the program or are trivial forwarders.
8class BetaRed : public RWPhase {
9public:
10 using RWPhase::RWPhase;
11
12private:
13 bool analyze() final;
14 void analyze(const Def*);
15 void visit(const Def*, bool candidate); // lattice: true -> false
16
17 const Def* rewrite_imm_App(const App*) final;
18 const Def* reduce(Lam*, const Def* old_arg);
19 bool is_once(Lam* lam) const { return fe::assert_lookup(once_, lam); }
20 bool is_candidate(Lam* lam) const { return !cyclic_.contains(lam) && (is_once(lam) || trivial_.contains(lam)); }
21
22 DefSet analyzed_;
23 DefSet on_stack_;
24 LamMap<bool> once_;
25 LamSet trivial_;
26 LamSet cyclic_;
27};
28
29} // namespace mim
Inlines in post-order all Lams that occur exactly once in the program or are trivial forwarders.
Definition beta_red.h:8
const Def * rewrite_imm_App(const App *) final
Definition beta_red.cpp:67
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
bool analyze() final
Runs the optional pre-analysis on old_world(), typically to a fixed point, before rewriting begins.
Definition beta_red.cpp:19
Base class for all Defs.
Definition def.h:289
A function.
Definition lam.h:91
RWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:334
Definition ast.h:16
GIDSet< Lam * > LamSet
Definition lam.h:211
GIDMap< Lam *, To > LamMap
Definition lam.h:210
GIDSet< const Def * > DefSet
Definition def.h:94