MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
add_mem.h
Go to the documentation of this file.
1#pragma once
2
4#include <mim/phase/phase.h>
5
6namespace mim::plug::mem {
7
8/// This phase adds mems to all lambdas and continuations.
9/// It's primarily to be used as preparation for other phases
10/// that rely on all continuations having a mem.
11class AddMem : public ScopePhase {
12public:
14 : ScopePhase(world, "add_mem", true) {
15 dirty_ = true;
16 }
17
18 void visit(const Scope&) override;
19
20private:
21 const Def* add_mem_to_lams(Lam*, const Def*);
22 const Def* rewrite_type(const Def*);
23 const Def* rewrite_pi(const Pi*);
24 /// Return the most recent memory for the given lambda.
25 const Def* mem_for_lam(Lam*) const;
26
27 Scheduler sched_;
28 // Stores the most recent memory for a lambda.
29 Def2Def val2mem_;
30 // Memoization & Association for rewritten defs.
31 Def2Def mem_rewritten_;
32};
33
34} // namespace mim::plug::mem
Base class for all Defs.
Definition def.h:223
A function.
Definition lam.h:103
bool dirty_
Definition phase.h:46
World & world()
Definition phase.h:25
A dependent function type.
Definition lam.h:11
Transitively visits all reachable Scopes in World that do not have free variables.
Definition phase.h:149
A Scope represents a region of Defs that are live from the view of an entry's Var.
Definition scope.h:20
The World represents the whole program and manages creation of MimIR nodes (Defs).
Definition world.h:33
This phase adds mems to all lambdas and continuations.
Definition add_mem.h:11
AddMem(World &world)
Definition add_mem.h:13
void visit(const Scope &) override
Definition add_mem.cpp:66
The mem Plugin
Definition mem.h:11
DefMap< const Def * > Def2Def
Definition def.h:60