MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
beta_red_phase.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 BetaRedPhase : public RWPhase {
9public:
12
13private:
14 bool analyze() final;
15 void analyze(const Def*);
16 void visit(const Def*, bool candidate = true); // lattice: true -> false
17
18 const Def* rewrite_imm_App(const App*) final;
19 bool is_candidate(Lam* lam) const { return assert_lookup(candidates_, lam); }
20
21 DefSet analyzed_;
22 LamMap<bool> candidates_;
23};
24
25} // namespace mim
bool analyze() final
You can do an optional fixed-point loop on the RWPhase::old_world before rewriting.
BetaRedPhase(World &world, flags_t annex)
const Def * rewrite_imm_App(const App *) final
Base class for all Defs.
Definition def.h:251
A function.
Definition lam.h:111
RWPhase(World &world, std::string name)
Definition phase.h:71
World & world()=delete
Hides both and forbids direct access.
flags_t annex() const
Definition pass.h:68
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:32
Definition ast.h:14
bool visit(IndexSet< Indexer, Key > &set, const Key &key)
Definition indexset.h:100
u64 flags_t
Definition types.h:45
GIDSet< const Def * > DefSet
Definition def.h:74
auto assert_lookup(C &container, const K &key)
Looks up key in container, asserts that it exists, and returns the mapped value.
Definition util.h:110