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/phase.h>
4#include <mim/schedule.h>
5
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 NestPhase<Lam> {
12public:
15
16 void visit(const Nest&) override;
17
18private:
19 const Def* add_mem_to_lams(Lam*, const Def*);
20 const Def* rewrite_type(const Def*);
21 const Def* rewrite_pi(const Pi*);
22 /// Return the most recent memory for the given lambda.
23 const Def* mem_for_lam(Lam*) const;
24
25 Scheduler sched_;
26 // Stores the most recent memory for a lambda.
27 Def2Def val2mem_;
28 // Memoization & Association for rewritten defs.
29 Def2Def mem_rewritten_;
30};
31
32} // namespace mim::plug::mem::phase
Base class for all Defs.
Definition def.h:251
A function.
Definition lam.h:111
NestPhase(World &world, std::string name, bool elide_empty)
Definition phase.h:268
Builds a nesting tree of all immutables‍/binders.
Definition nest.h:11
A dependent function type.
Definition lam.h:15
World & world()
Definition pass.h:64
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
void visit(const Nest &) override
Definition add_mem.cpp:66
AddMem(World &world, flags_t annex)
Definition add_mem.h:13
DefMap< const Def * > Def2Def
Definition def.h:75
u64 flags_t
Definition types.h:45