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.
8class BetaRed : public InplaceRWPhase {
9public:
11
13 : InplaceRWPhase(world, "BetaRed") {}
16
17private:
18 bool analyze() final;
19 void analyze(const Def*);
20 void visit(const Def*, bool candidate); // lattice: true -> false
21
22 const Def* rewrite(const Def* def) { return def->is_ground() ? def : Super::rewrite(def); }
23 const Def* rewrite_imm_App(const App*) final;
24 bool is_candidate(Lam* lam) const { return fe::assert_lookup(candidates_, lam); }
25
26 DefSet analyzed_;
27 LamMap<bool> candidates_;
28};
29
30} // namespace mim
const Def * rewrite_imm_App(const App *) final
Definition beta_red.cpp:25
InplaceRWPhase Super
Definition beta_red.h:10
BetaRed(World &world)
Definition beta_red.h:12
bool analyze() final
Runs the optional pre-analysis on Phase::world, typically to a fixed point, before rewriting begins.
Definition beta_red.cpp:5
BetaRed(World &world, flags_t annex)
Definition beta_red.h:14
Base class for all Defs.
Definition def.h:273
bool is_ground() const
Immutable that contains neither mutables nor Vars.
Definition def.h:525
InplaceRWPhase(World &world, std::string name, Analysis *analysis=nullptr)
Definition phase.h:489
World & world()
Definition phase.h:77
flags_t annex() const
Definition phase.h:81
virtual const Def * rewrite(const Def *)
Definition rewrite.cpp:55
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:40
Definition ast.h:16
u64 flags_t
Definition types.h:39
GIDSet< const Def * > DefSet
Definition def.h:89