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
3#include <mim/schedule.h>
4
5#include <mim/phase/phase.h>
6
7namespace mim::plug::mem {
8
9/// This phase adds mems to all lambdas and continuations.
10/// It's primarily to be used as preparation for other phases
11/// that rely on all continuations having a mem.
12class AddMem : public NestPhase<Lam> {
13public:
15 : NestPhase(world, "add_mem", true, true) {}
16
17 void visit(const Nest&) override;
18
19private:
20 const Def* add_mem_to_lams(Lam*, const Def*);
21 const Def* rewrite_type(const Def*);
22 const Def* rewrite_pi(const Pi*);
23 /// Return the most recent memory for the given lambda.
24 const Def* mem_for_lam(Lam*) const;
25
26 Scheduler sched_;
27 // Stores the most recent memory for a lambda.
28 Def2Def val2mem_;
29 // Memoization & Association for rewritten defs.
30 Def2Def mem_rewritten_;
31};
32
33} // namespace mim::plug::mem
Base class for all Defs.
Definition def.h:212
A function.
Definition lam.h:105
Like ClosedMutPhase but computes a Nest for each NestPhase::visit.
Definition phase.h:198
Builds a nesting tree of all immutables‍/binders.
Definition nest.h:11
World & world()
Definition phase.h:27
A dependent function type.
Definition lam.h:11
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:12
AddMem(World &world)
Definition add_mem.h:14
void visit(const Nest &) override
Definition add_mem.cpp:64
The mem Plugin
Definition mem.h:11
DefMap< const Def * > Def2Def
Definition def.h:60